js-list-lazy
Advanced tools
Comparing version 0.0.3 to 0.1.0
/* | ||
* $Id: list-lazy.js,v 0.3 2013/03/10 18:19:52 dankogai Exp dankogai $ | ||
* $Id: list-lazy.js,v 0.10 2013/03/11 01:38:16 dankogai Exp dankogai $ | ||
* | ||
@@ -40,3 +40,3 @@ * Licensed under the MIT license. | ||
if (!o) o = this; | ||
return i < o.length ? | ||
return i < o.length ? | ||
oget.call(this, v) : u ? new Undef : undefined; | ||
@@ -87,4 +87,4 @@ }; | ||
var gv = g(v, i, o, true); | ||
return gv instanceof Undef | ||
? u ? gv : undefined | ||
return gv instanceof Undef | ||
? u ? gv : undefined | ||
: f.call(this, gv, i, o, u); | ||
@@ -104,4 +104,4 @@ }, | ||
return gv instanceof Undef | ||
? u ? gv : undefined | ||
: f.call(this, gv, i, o, u) | ||
? u ? gv : undefined | ||
: f.call(this, gv, i, o, u) | ||
? gv : u ? new Undef : undefined; | ||
@@ -116,2 +116,5 @@ }, | ||
}, | ||
has: function(v, i, o) { | ||
return !(this.get(v, i, o, true) instanceof Undef); | ||
}, | ||
take: function(n) { | ||
@@ -153,8 +156,8 @@ var ret = [], | ||
if (v instanceof Undef) { l--; } | ||
else { | ||
if( f.call(this, v, i) === false) break loop; | ||
else { | ||
if (f.call(this, v, i) === false) break loop; | ||
} | ||
i++; | ||
} | ||
}, | ||
} | ||
}); | ||
@@ -166,7 +169,7 @@ /* remaining iteration methods */ | ||
defineProperty(Lazy.prototype, k, { | ||
value: function(){ | ||
return ap.apply(this.toArray(), slice.call(arguments)) | ||
value: function() { | ||
return ap.apply(this.toArray(), slice.call(arguments)); | ||
} | ||
}); | ||
}); | ||
}); | ||
})('some every reduce reduceRight'.split(' ')); | ||
@@ -173,0 +176,0 @@ /* install it to List */ |
{ | ||
"name": "js-list-lazy", | ||
"version": "0.0.3", | ||
"version": "0.1.0", | ||
"description": "Lazy List in JavaScript", | ||
@@ -5,0 +5,0 @@ "main": "list-lazy.js", |
@@ -42,2 +42,4 @@ /* | ||
it('l.filter(iseven).get(41)', is(l.filter(iseven).get(41), undefined)); | ||
it('l.filter(iseven).has(42)', is(l.filter(iseven).has(42), true)); | ||
it('l.filter(iseven).has(41)', is(l.filter(iseven).has(41), false)); | ||
it('l.filter(iseven).take(4)', | ||
@@ -44,0 +46,0 @@ is_deeply(l.filter(iseven).take(4), [0, 2, 4, 6])); |
19706
453