This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
XMLHttpRequest = require("browser/xhr").XMLHttpRequest; | |
var request = require("jsgi-client").request; | |
var when = require("promise").when; | |
var queue = require("event-queue"); | |
when(request({ | |
method: "GET", | |
url: "http://google.com/" | |
}), function(response) { | |
print("Google responded with " + response.body); | |
queue.shutdown(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require("./jsgi-node").start(function(request){ | |
var requestBody = request.input.read().decodeToString(); | |
return { | |
status:200, | |
headers:{}, | |
body:["echo: " + requestBody] | |
}; | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
return [200, headers:{}, body:{ | |
forEach: function(write){ | |
var promise = new Promise; | |
someEventEmitter.addListener("data", function(data){ | |
write(data); | |
} | |
someEventEmitter.addListener("complete", function(){ | |
promise.resolve(); | |
} | |
return promise; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// new syntax | |
function addOne(value){ | |
return (when <: value) + 1; | |
} | |
// as effectively sugar for: | |
function addOne(value){ | |
return when(value, function(value){ | |
return value + 1; | |
}); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sys = require("sys"); | |
var promise = require('/home/benjamin/programming/tools/bomberjs/bundled/promise/promise'); | |
var p = new promise.Promise(); | |
var p2 = p.then( | |
function () { | |
return '1'; | |
}) | |
.then( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// simple repl test | |
var test = require("model").Model("test", require("store/js-file").JSFile(), | |
{ | |
properties: { | |
foo: {type: "string"}, | |
bar: {type: "integer", optional: true} | |
}, | |
prototype: {} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void addListener(PropertyChangeSetListener listener) { | |
Map<ObjectId, Set<String>> readSet = readSets.get(); | |
Map<ObjectId, Set<String>> watchSet = watchSets.get(listener); | |
if (watchSet == null){ | |
synchronized(watchSets){ | |
watchSets.put(listener,watchSet = new HashMap<ObjectId, Set<String>>()); | |
} | |
} | |
for (Map.Entry<ObjectId, Set<String>> entry : readSet.entrySet()) { | |
ObjectId key = entry.getKey(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require.paths.push(".", "folder1"); | |
require("folder1/c"); | |
require("c"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"a!=aaa" is sugar for (identical to) "a.ne(aaa)" parses to: | |
[{ | |
property:"a", | |
operator:"ne", | |
values: ["aaa"] | |
}] | |
"a=aaa" is sugar for (identical to) "a.eq(aaa)" parses to: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This module provides querying functionality | |
*/ | |
exports.jsonQueryCompatible = true; | |
var operatorMap = { | |
"": "eq", | |
"!": "ne", | |
} |