es-iterator-helpers
Advanced tools
Comparing version 1.0.4 to 1.0.5
@@ -8,2 +8,9 @@ # Changelog | ||
## [v1.0.5](https://github.com/es-shims/iterator-helpers/compare/v1.0.4...v1.0.5) - 2023-03-22 | ||
### Commits | ||
- [Tests] add passing tests for 4240029 [`c2082fe`](https://github.com/es-shims/iterator-helpers/commit/c2082fee3e73dc1998a67fbe0014e3ebdceb8ec0) | ||
- [Fix] properly allow subclasses of Iterator to be constructed [`5cebe2a`](https://github.com/es-shims/iterator-helpers/commit/5cebe2a5767393696d0ce4e9325edf78c300f938) | ||
## [v1.0.4](https://github.com/es-shims/iterator-helpers/compare/v1.0.3...v1.0.4) - 2023-03-21 | ||
@@ -10,0 +17,0 @@ |
@@ -10,5 +10,14 @@ 'use strict'; | ||
var iterProto = require('iterator.prototype'); | ||
var callBound = require('call-bind/callBound'); | ||
var $isPrototypeOf = callBound('Object.prototype.isPrototypeOf'); | ||
var $Iterator = typeof Iterator === 'function' ? Iterator : function Iterator() { | ||
throw new $TypeError('`Iterator` can not be called directly'); | ||
if ( | ||
!(this instanceof Iterator) | ||
|| this.constructor === Iterator | ||
|| !$isPrototypeOf(Iterator, this.constructor) | ||
) { | ||
throw new $TypeError('`Iterator` can not be called or constructed directly'); | ||
} | ||
}; | ||
@@ -15,0 +24,0 @@ |
{ | ||
"name": "es-iterator-helpers", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "An ESnext spec-compliant iterator helpers shim/polyfill/replacement that works as far down as ES3.", | ||
@@ -5,0 +5,0 @@ "main": "index.json", |
@@ -27,2 +27,23 @@ 'use strict'; | ||
); | ||
var SubIter; | ||
var SubSubIter; | ||
try { | ||
/* eslint no-new-func: 0 */ | ||
SubIter = Function('Iter', 'return class SubIter extends Iter {};')(Iter); | ||
SubSubIter = Function('SubIter', 'return class SubSubIter extends SubIter {};')(SubIter); | ||
} catch (e) { /**/ } | ||
t.test('class inheritance', { skip: !SubIter }, function (st) { | ||
st.doesNotThrow( | ||
function () { return new SubIter(); }, | ||
'Extending ' + name + ' does not throw when Construct-ed' | ||
); | ||
st.doesNotThrow( | ||
function () { return new SubSubIter(); }, | ||
'Extending ' + name + ' twice does not throw when Construct-ed' | ||
); | ||
st.end(); | ||
}); | ||
}, | ||
@@ -29,0 +50,0 @@ index: function () { |
@@ -40,2 +40,30 @@ 'use strict'; | ||
t.test('observable lookups', { skip: !hasPropertyDescriptors }, function (st) { | ||
var effects = []; | ||
var obj = {}; | ||
Object.defineProperty(obj, 'next', { | ||
configurable: true, | ||
enumerable: true, | ||
get: function next() { | ||
effects.push('get next'); | ||
return function () { | ||
return { done: true, value: undefined }; | ||
}; | ||
} | ||
}); | ||
drop(obj, { | ||
valueOf: function valueOf() { | ||
effects.push('ToNumber limit'); | ||
return 0; | ||
} | ||
}); | ||
st.deepEqual(effects, [ | ||
'ToNumber limit', | ||
'get next' | ||
]); | ||
st.end(); | ||
}); | ||
var iterator = [1, 2, 3]; | ||
@@ -42,0 +70,0 @@ |
@@ -12,2 +12,3 @@ 'use strict'; | ||
var hasSymbols = require('has-symbols/shams')(); | ||
var hasPropertyDescriptors = require('has-property-descriptors')(); | ||
@@ -48,2 +49,27 @@ var index = require('../Iterator.prototype.every'); | ||
t.test('observable lookups', { skip: !hasPropertyDescriptors }, function (st) { | ||
var effects = []; | ||
var obj = {}; | ||
Object.defineProperty(obj, 'next', { | ||
configurable: true, | ||
enumerable: true, | ||
get: function next() { | ||
effects.push('get next'); | ||
return function () { | ||
return { done: true, value: undefined }; | ||
}; | ||
} | ||
}); | ||
st['throws']( | ||
function () { every(obj, null); }, | ||
TypeError | ||
); | ||
st.deepEqual(effects, []); | ||
st.end(); | ||
}); | ||
t.test('actual iteration', { skip: !hasSymbols }, function (st) { | ||
@@ -50,0 +76,0 @@ var arr = [1, 2, 3]; |
@@ -48,2 +48,27 @@ 'use strict'; | ||
t.test('observable lookups', { skip: !hasPropertyDescriptors }, function (st) { | ||
var effects = []; | ||
var obj = {}; | ||
Object.defineProperty(obj, 'next', { | ||
configurable: true, | ||
enumerable: true, | ||
get: function next() { | ||
effects.push('get next'); | ||
return function () { | ||
return { done: true, value: undefined }; | ||
}; | ||
} | ||
}); | ||
st['throws']( | ||
function () { filter(obj, null); }, | ||
TypeError | ||
); | ||
st.deepEqual(effects, []); | ||
st.end(); | ||
}); | ||
t.test('actual iteration', { skip: !hasSymbols }, function (st) { | ||
@@ -50,0 +75,0 @@ var arr = [1, 2, 3]; |
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
Uses eval
Supply chain riskPackage uses eval() which is a dangerous function. This prevents the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
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
135886
3252
2