4 ms·
Or if you're into MooTools checkout http://github.com/ShiftSpace/functools http://github.com/ShiftSpace/functools for decorators, pre & postconditions, memoize,
by swannodette 17y ago
Or if you're into MooTools checkout http://github.com/ShiftSpace/functools http://github.com/ShiftSpace/functools for decorators, pre & postconditions, memoize, arrays and hashes as functions, currying any function parameter, function composition, arity dispatch, etc.
Check out http://github.com/ShiftSpace/promises http://github.com/ShiftSpace/promises for bringing functional sanity to AJAX requests as well support for lazy values:
function example() {
var remotes = ['a', 'b', 'c', 'd', 'e', 'f'];
var result = "";
while(remotev = remotes.shift()) {
result = add(result, get(remotev)); // get is an async request! ;)
}
show(result); // -> console.logs "abcdef"
}
No callbacks, your code looks like (and _is_) regular javascript even though this triggers 6 requests. AJAX callback code is the new spaghetti and this is an antidote.
And finally a http://github.com/ShiftSpace/set http://github.com/ShiftSpace/set for a Set datastructure :)
- osteele 17y agoPromises looks fun! You might also be interested in http://osteele.com/sources/javascript/concurrent/ http://osteele.com/sources/javascript/concurrent/ for another approach to this. [later, after reading more:] Actually, Promises looks much more complete and useful.
- swannodette 17y agoThanks for this! I recall reading over your article, http://osteele.com/sources/javascript/functional/ http://osteele.com/sources/javascript/functional/, back in the day and being completely baffled and intrigued. These days I've been hacking with Clojure and wanting to bring some of that FP sanity back to my daily work ;)