js-list-lazy
Advanced tools
Comparing version 0.0.1 to 0.0.2
/* | ||
* $Id: list-lazy.js,v 0.1 2013/03/10 12:35:28 dankogai Exp dankogai $ | ||
* $Id: list-lazy.js,v 0.2 2013/03/10 13:43:15 dankogai Exp dankogai $ | ||
* | ||
@@ -12,3 +12,3 @@ * Licensed under the MIT license. | ||
*/ | ||
(function(global) { | ||
(function(global) { | ||
if (!global.List) global.List = Object.create(null); | ||
@@ -40,3 +40,4 @@ if (global.List.Lazy) return; | ||
if (!o) o = this; | ||
return i < o.length ? oget.call(this, v) : u ? new Undef : undefined; | ||
return i < o.length ? | ||
oget.call(this, v) : u ? new Undef : undefined; | ||
}; | ||
@@ -73,3 +74,4 @@ defineProperty(o, 'get', { | ||
}; | ||
/* prototypal properties */ (function(o) { | ||
/* prototypal properties */ | ||
(function(o) { | ||
for (p in o) defineProperty(Lazy.prototype, p, { | ||
@@ -85,3 +87,6 @@ value: o[p] | ||
fg = function(v, i, o, u) { | ||
return f.call(this, g(v), i, o, u); | ||
var gv = g(v, i, o, true); | ||
return gv instanceof Undef | ||
? u ? gv : undefined | ||
: f.call(this, gv, i, o, u); | ||
}, | ||
@@ -98,6 +103,7 @@ that = new Lazy(this); | ||
fg = function(v, i, o, u) { | ||
var gv = g(v); | ||
return f.call(this, gv, i, o) | ||
? gv | ||
: u ? new Undef : undefined; | ||
var gv = g(v, i, o, true); | ||
return gv instanceof Undef | ||
? u ? gv : undefined | ||
: f.call(this, gv, i, o, u) | ||
? gv : u ? new Undef : undefined; | ||
}, | ||
@@ -104,0 +110,0 @@ that = new Lazy(this); |
{ | ||
"name": "js-list-lazy", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Lazy List in JavaScript", | ||
@@ -5,0 +5,0 @@ "main": "list-lazy.js", |
@@ -44,4 +44,16 @@ /* | ||
is_deeply(l.filter(iseven).take(4), [0, 2, 4, 6])); | ||
it('l.map(square).filter(iseven).get(6)', | ||
is(l.map(square).filter(iseven).get(6), 36)); | ||
it('l.map(square).filter(iseven).get(5)', | ||
is(l.map(square).filter(iseven).get(5), undefined)); | ||
it('l.map(square).filter(iseven).take(5)', | ||
is_deeply(l.map(square).filter(iseven).take(5), [0,4,16,36,64])); | ||
var sqrt = Math.sqrt; | ||
it('l.map(square).filter(iseven).map(sqrt).get(6)', | ||
is(l.map(square).filter(iseven).map(sqrt).get(6), 6)); | ||
it('l.map(square).filter(iseven).map(sqrt).get(5)', | ||
is(l.map(square).filter(iseven).map(sqrt).get(5), undefined)); | ||
it('l.map(square).filter(iseven).map(sqrt).take(5)', | ||
is_deeply(l.map(square).filter(iseven).map(sqrt).take(5), | ||
[0,2,4,6,8])); | ||
var a, err; | ||
@@ -48,0 +60,0 @@ try { |
15578
316