array-entries
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -18,6 +18,17 @@ ;(function (exports) { | ||
function NonEnumerable(obj) { | ||
Object.keys(obj).forEach(function (key) { | ||
Object.defineProperty(obj, key, { | ||
value: obj[key], | ||
writable: true, | ||
enumerable: false | ||
}); | ||
}); | ||
return obj; | ||
} | ||
function ArrayIterator(obj) { | ||
this.iteratedObject = ToObject(obj); | ||
this.index = 0; | ||
this.kind = "key+value"; | ||
this.kind = 'key+value'; | ||
} | ||
@@ -48,11 +59,11 @@ | ||
if (kind === "key") { | ||
if (kind === 'key') { | ||
return { value: index, done: false }; | ||
} | ||
if (kind === "value") { | ||
if (kind === 'value') { | ||
return { value: object[index], done: false }; | ||
} | ||
if (kind === "key+value") { | ||
if (kind === 'key+value') { | ||
return { value: [ index, object[index] ], done: false }; | ||
@@ -67,3 +78,3 @@ } | ||
Array.prototype.entries = function entries() { | ||
return new ArrayIterator(this); | ||
return NonEnumerable(new ArrayIterator(this)); | ||
}; | ||
@@ -70,0 +81,0 @@ } |
{ | ||
"name": "array-entries", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "[].entries() polyfill.", | ||
@@ -12,3 +12,3 @@ "main": "array-entries.js", | ||
"cover": "istanbul cover tape -- test/*.js", | ||
"lint": "jshint -c .jshintrc arra-entries.js" | ||
"lint": "jshint -c .jshintrc array-entries.js" | ||
}, | ||
@@ -15,0 +15,0 @@ "repository": { |
@@ -1,2 +0,5 @@ | ||
Array.entries() polyfill | ||
[].entries() polyfill | ||
---- | ||
Per [this](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/entries) and | ||
[this](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-array.prototype.entries) |
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
5096
62
6