filter-arraylike-iterable
Advanced tools
Comparing version 0.1.3 to 0.1.4
23
index.js
@@ -15,2 +15,6 @@ const InmutableArray = require('array-inmutable') | ||
function apply (value) { | ||
return this.ps.every(p => p(value)) ? {value} : undefined | ||
} | ||
Object.defineProperties(FilterArrayLikeIterable.prototype, { | ||
@@ -21,10 +25,17 @@ filter: { | ||
[Symbol.iterator]: { | ||
* value () { | ||
value () { | ||
const self = this | ||
const iterable = this.iterable | ||
const length = iterable.length | ||
const ps = this.ps | ||
for (let i = 0; i < length; ++i) { | ||
const val = iterable[i] | ||
if (ps.every(p => p(val))) { | ||
yield val | ||
let i = 0 | ||
return { | ||
next () { | ||
while (i < length) { | ||
const status = apply.call(self, iterable[i]) | ||
++i | ||
if (status) { | ||
return status | ||
} | ||
} | ||
return {done: true} | ||
} | ||
@@ -31,0 +42,0 @@ } |
{ | ||
"name": "filter-arraylike-iterable", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"description": "array like iterable decorated with filter method", | ||
@@ -33,6 +33,6 @@ "main": "index.js", | ||
"babel-register": "^6.26.0", | ||
"coveralls": "^2.13.1", | ||
"eslint": "^4.5.0", | ||
"npm-check": "^5.4.5", | ||
"nyc": "^11.1.0", | ||
"coveralls": "^3.0.0", | ||
"eslint": "^4.16.0", | ||
"npm-check": "^5.5.2", | ||
"nyc": "^11.4.1", | ||
"pre-commit": "^1.2.2", | ||
@@ -46,4 +46,4 @@ "tap-spec": "^4.1.1", | ||
"dependencies": { | ||
"array-inmutable": "^0.1.0" | ||
"array-inmutable": "^0.1.2" | ||
} | ||
} |
11085
129
6
Updatedarray-inmutable@^0.1.2