es6-iterator
Advanced tools
Comparing version 0.1.3 to 1.0.0
'use strict'; | ||
var callable = require('es5-ext/object/valid-callable') | ||
, isString = require('es5-ext/string/is-string') | ||
, get = require('./get') | ||
var isArguments = require('es5-ext/function/is-arguments') | ||
, callable = require('es5-ext/object/valid-callable') | ||
, isString = require('es5-ext/string/is-string') | ||
, get = require('./get') | ||
, isArray = Array.isArray, call = Function.prototype.call; | ||
, isArray = Array.isArray, call = Function.prototype.call | ||
, some = Array.prototype.some; | ||
module.exports = function (iterable, cb/*, thisArg*/) { | ||
var mode, thisArg = arguments[2], result, doBreak, broken, i, l, char, code; | ||
if (isArray(iterable)) mode = 'array'; | ||
if (isArray(iterable) || isArguments(iterable)) mode = 'array'; | ||
else if (isString(iterable)) mode = 'string'; | ||
@@ -18,3 +20,3 @@ else iterable = get(iterable); | ||
if (mode === 'array') { | ||
iterable.some(function (value) { | ||
some.call(iterable, function (value) { | ||
call.call(cb, thisArg, value, doBreak); | ||
@@ -21,0 +23,0 @@ if (broken) return true; |
'use strict'; | ||
var isString = require('es5-ext/string/is-string') | ||
var isArguments = require('es5-ext/function/is-arguments') | ||
, isString = require('es5-ext/string/is-string') | ||
, ArrayIterator = require('./array') | ||
@@ -11,4 +12,5 @@ , StringIterator = require('./string') | ||
if (typeof iterable(obj)[iteratorSymbol] === 'function') return obj[iteratorSymbol](); | ||
if (isArguments(obj)) return new ArrayIterator(obj); | ||
if (isString(obj)) return new StringIterator(obj); | ||
return new ArrayIterator(obj); | ||
}; |
'use strict'; | ||
var isString = require('es5-ext/string/is-string') | ||
var isArguments = require('es5-ext/function/is-arguments') | ||
, isString = require('es5-ext/string/is-string') | ||
, iteratorSymbol = require('es6-symbol').iterator | ||
@@ -12,3 +13,4 @@ | ||
if (isString(value)) return true; | ||
if (isArguments(value)) return true; | ||
return (typeof value[iteratorSymbol] === 'function'); | ||
}; |
{ | ||
"name": "es6-iterator", | ||
"version": "0.1.3", | ||
"version": "1.0.0", | ||
"description": "Iterator abstraction based on ES6 specification", | ||
@@ -19,11 +19,11 @@ "author": "Mariusz Nowak <medyk@medikoo.com> (http://www.medikoo.com/)", | ||
"dependencies": { | ||
"d": "~0.1.1", | ||
"es5-ext": "~0.10.5", | ||
"es6-symbol": "~2.0.1" | ||
"d": "^0.1.1", | ||
"es5-ext": "^0.10.7", | ||
"es6-symbol": "^2.0.1" | ||
}, | ||
"devDependencies": { | ||
"event-emitter": "~0.3.3", | ||
"tad": "~0.2.1", | ||
"xlint": "~0.2.2", | ||
"xlint-jslint-medikoo": "~0.1.2" | ||
"event-emitter": "^0.3.3", | ||
"tad": "^0.2.3", | ||
"xlint": "^0.2.2", | ||
"xlint-jslint-medikoo": "^0.1.3" | ||
}, | ||
@@ -30,0 +30,0 @@ "scripts": { |
@@ -14,2 +14,7 @@ 'use strict'; | ||
i = 0; | ||
t((function () { return arguments; }('raz', 'dwa', 'trzy')), function () { | ||
a.deep(slice.call(arguments, 0, 1), [x[i]], "Arguments" + i + "#"); | ||
a(this, y, "Arguments: context: " + (i++) + "#"); | ||
}, y); | ||
i = 0; | ||
t(x = 'foo', function () { | ||
@@ -16,0 +21,0 @@ a.deep(slice.call(arguments, 0, 1), [x[i]], "String " + i + "#"); |
@@ -15,3 +15,4 @@ 'use strict'; | ||
a(String(t([])), '[object Array Iterator]', " Array"); | ||
a(String(t((function () { return arguments; }()))), '[object Array Iterator]', " Arguments"); | ||
a(String(t('foo')), '[object String Iterator]', "String"); | ||
}; |
@@ -18,2 +18,3 @@ 'use strict'; | ||
a(t(''), true, "Empty string"); | ||
a(t((function () { return arguments; }())), true, "Arguments"); | ||
}; |
@@ -16,2 +16,4 @@ 'use strict'; | ||
a(t(obj), obj, 'Array'); | ||
obj = (function () { return arguments; }()); | ||
a(t(obj), obj, "Arguments"); | ||
}; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
27343
524
1
Updatedd@^0.1.1
Updatedes5-ext@^0.10.7
Updatedes6-symbol@^2.0.1