Socket
Socket
Sign inDemoInstall

es-iterator-helpers

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

es-iterator-helpers - npm Package Compare versions

Comparing version 1.0.4 to 1.0.5

7

CHANGELOG.md

@@ -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 @@

11

Iterator/implementation.js

@@ -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 @@

2

package.json
{
"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];

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc