Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[minor] minor fixes to code

  • Loading branch information...
commit 26ac1c9336832507858e1111c9b1cd88b8a0f2d9 1 parent bac5d61
@dscape authored
Showing with 12 additions and 13 deletions.
  1. +5 −6 pattern.js
  2. +3 −3 samples/map.js
  3. +4 −4 samples/nodetuts.js
View
11 pattern.js
@@ -24,18 +24,17 @@
ok = true; // set our flag to matching
log('', s[i], '===', arguments[i]);
j=0;
- log('aa',arguments.length, (i+1))
- if(arguments.length !== i+1) { continue ol; } }
+ if(arguments.length !== i+1) { log(''); continue ol; } }
else { // if it doesnt match try next pattern in stack
log('', s[i], '===', arguments[i]);
// dont break and set ok to false if this is the last element
- if(stack.length !== j+1) { ok = false; continue; } } }
- if(stack.length === j+1 || arguments.length === i+1) {
+ if(stack.length!==j+1) { log(''); ok = false; continue; } } }
+ //if(stack.length === j+1) {
// decide on the function base ok if its a match or not
var f = ok ? arguments[arguments.length-1] : s[s.length-1];
- log(' ' + (ok ? 'λ' : 'ƒ'), f);
+ log(' ' + (ok ? 'λ' : 'ƒ'), f.name || f);
// execute whatever is the last argument on last pattern of stack
- return f.apply(this, [].slice.call(arguments,0)); } } }
+ return f.apply(this, [].slice.call(arguments,0)); } } //}
} else {
stack.push([].slice.call(arguments,0)); // initializing add pattern
log('', [].slice.call(arguments,0));
View
6 samples/map.js
@@ -2,10 +2,10 @@ var map = require('../pattern')
, _
;
-map(_, [], _, function(cb,ac) { return cb(ac); });
-map(function(f, l, ac) {
+map(_, [], _, function stop(cb,ac) { return cb(ac); });
+map(function all(f, l, ac) {
ac.push(f(l.shift())); // head
map(f, l, ac); // l is now tail
});
-map(function(x) { return x*2; }, [1,2,3], []);
+map(function duplicate(x) { console.log(x); return x*2; }, [1,2,3], []);
View
8 samples/nodetuts.js
@@ -8,16 +8,16 @@ function insert_element(data, callback) {
Math.ceil(Math.random() * 1000));
}
-insert_all([], _, function (cb) { cb(); });
-insert_all(function (l,cb) {
+insert_all([], _, function finish(cb) { cb(); });
+insert_all(function catchall(l,cb) {
var elem = l.shift(); // head
- insert_element(elem, function(err, elem) {
+ insert_element(elem, function elem_cb(err, elem) {
if(err) { return cb(err); }
console.log(elem + ' inserted');
insert_all(l, cb);
});
});
-insert_all([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], function () {
+insert_all([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], function done() {
console.log('done');
});
Please sign in to comment.
Something went wrong with that request. Please try again.