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.10 to 1.0.11

6

CHANGELOG.md

@@ -8,2 +8,8 @@ # Changelog

## [v1.0.11](https://github.com/es-shims/iterator-helpers/compare/v1.0.10...v1.0.11) - 2023-05-22
### Commits
- [Fix] iterator helpers are not a constructor [`8a7f999`](https://github.com/es-shims/iterator-helpers/commit/8a7f9996ba3600ef30f3a9c75f9f994e88d075c6)
## [v1.0.10](https://github.com/es-shims/iterator-helpers/compare/v1.0.9...v1.0.10) - 2023-05-18

@@ -10,0 +16,0 @@

'use strict';
var GetIntrinsic = require('get-intrinsic');
var $TypeError = GetIntrinsic('%TypeError%');
var OrdinaryHasInstance = require('es-abstract/2022/OrdinaryHasInstance');

@@ -16,2 +20,6 @@ var OrdinaryObjectCreate = require('es-abstract/2022/OrdinaryObjectCreate');

module.exports = function from(O) {
if (this instanceof from) {
throw new $TypeError('`Iterator.from` is not a constructor');
}
if (Type(O) === 'String') {

@@ -18,0 +26,0 @@ // eslint-disable-next-line no-param-reassign

4

Iterator.prototype.drop/implementation.js

@@ -26,2 +26,6 @@ 'use strict';

module.exports = function drop(limit) {
if (this instanceof drop) {
throw new $TypeError('`drop` is not a constructor');
}
var O = this; // step 1

@@ -28,0 +32,0 @@ if (Type(O) !== 'Object') {

@@ -19,2 +19,6 @@ 'use strict';

module.exports = function every(predicate) {
if (this instanceof every) {
throw new $TypeError('`every` is not a constructor');
}
var O = this; // step 1

@@ -21,0 +25,0 @@ if (Type(O) !== 'Object') {

@@ -24,2 +24,6 @@ 'use strict';

module.exports = function filter(predicate) {
if (this instanceof filter) {
throw new $TypeError('`filter` is not a constructor');
}
var O = this; // step 1

@@ -26,0 +30,0 @@ if (Type(O) !== 'Object') {

@@ -19,2 +19,6 @@ 'use strict';

module.exports = function find(predicate) {
if (this instanceof find) {
throw new $TypeError('`find` is not a constructor');
}
var O = this; // step 1

@@ -21,0 +25,0 @@

@@ -24,2 +24,6 @@ 'use strict';

module.exports = function flatMap(mapper) {
if (this instanceof flatMap) {
throw new $TypeError('`flatMap` is not a constructor');
}
var O = this; // step 1

@@ -26,0 +30,0 @@ if (Type(O) !== 'Object') {

@@ -17,2 +17,6 @@ 'use strict';

module.exports = function forEach(fn) {
if (this instanceof forEach) {
throw new $TypeError('`forEach` is not a constructor');
}
var O = this; // step 1

@@ -19,0 +23,0 @@ if (Type(O) !== 'Object') {

@@ -23,2 +23,6 @@ 'use strict';

module.exports = function map(mapper) {
if (this instanceof map) {
throw new $TypeError('`map` is not a constructor');
}
var O = this; // step 1

@@ -25,0 +29,0 @@ if (Type(O) !== 'Object') {

@@ -17,2 +17,6 @@ 'use strict';

module.exports = function reduce(reducer) {
if (this instanceof reduce) {
throw new $TypeError('`reduce` is not a constructor');
}
var O = this; // step 1

@@ -19,0 +23,0 @@ if (Type(O) !== 'Object') {

@@ -19,2 +19,6 @@ 'use strict';

module.exports = function some(predicate) {
if (this instanceof some) {
throw new $TypeError('`some` is not a constructor');
}
var O = this; // step 1

@@ -21,0 +25,0 @@ if (Type(O) !== 'Object') {

@@ -26,2 +26,6 @@ 'use strict';

module.exports = function take(limit) {
if (this instanceof take) {
throw new $TypeError('`take` is not a constructor');
}
var O = this; // step 1

@@ -28,0 +32,0 @@ if (Type(O) !== 'Object') {

@@ -17,2 +17,6 @@ 'use strict';

module.exports = function toArray() {
if (this instanceof toArray) {
throw new $TypeError('`toArray` is not a constructor');
}
var O = this; // step 1

@@ -19,0 +23,0 @@

2

package.json
{
"name": "es-iterator-helpers",
"version": "1.0.10",
"version": "1.0.11",
"description": "An ESnext spec-compliant iterator helpers shim/polyfill/replacement that works as far down as ES3.",

@@ -5,0 +5,0 @@ "main": "index.json",

@@ -42,2 +42,13 @@ 'use strict';

tests: function (from, name, t) {
t['throws'](
function () { return new from(); }, // eslint-disable-line new-cap
TypeError,
'`' + name + '` itself is not a constructor'
);
t['throws'](
function () { return new from({}); }, // eslint-disable-line new-cap
TypeError,
'`' + name + '` itself is not a constructor, with an argument'
);
forEach(v.primitives.concat(v.objects), function (nonIterator) {

@@ -64,2 +75,8 @@ if (typeof nonIterator !== 'string') {

// st['throws'](
// function () { return new from([]); }, // eslint-disable-line new-cap
// RangeError,
// '`' + name + '` iterator is not a constructor'
// );
forEach(v.strings, function (string) {

@@ -104,3 +121,3 @@ var stringIt = from(string);

test('Iterator.from: implementation', function (t) {
module.exports.tests(callBind(impl, null), 'Iterator.from', t);
module.exports.tests(impl, 'Iterator.from', t);

@@ -107,0 +124,0 @@ t.end();

@@ -26,2 +26,8 @@ 'use strict';

tests: function (drop, name, t) {
t['throws'](
function () { return new drop(); }, // eslint-disable-line new-cap
TypeError,
'`' + name + '` itself is not a constructor'
);
forEach(v.primitives.concat(v.objects), function (nonIterator) {

@@ -70,7 +76,9 @@ t['throws'](

var iterator = [1, 2, 3];
var arr = [1, 2, 3];
t.test('actual iteration', { skip: !hasSymbols }, function (st) {
var iterator = callBind(arr[Symbol.iterator], arr);
st['throws'](
function () { drop(iterator[Symbol.iterator](), -3); },
function () { drop(iterator(), -3); },
RangeError,

@@ -80,9 +88,20 @@ '-3 is not >= 0'

testIterator(iterator[Symbol.iterator](), [1, 2, 3], st, 'original');
testIterator(drop(iterator[Symbol.iterator](), 0), [1, 2, 3], st, 'drop 0');
testIterator(drop(iterator[Symbol.iterator](), 1), [2, 3], st, 'drop 1');
testIterator(drop(iterator[Symbol.iterator](), 2), [3], st, 'drop 2');
testIterator(drop(iterator[Symbol.iterator](), 3), [], st, 'drop 3');
testIterator(drop(iterator[Symbol.iterator](), Infinity), [], st, 'drop ∞');
st['throws'](
function () { return new drop(iterator()); }, // eslint-disable-line new-cap
TypeError,
'`' + name + '` iterator is not a constructor'
);
st['throws'](
function () { return new drop(iterator(), 0); }, // eslint-disable-line new-cap
TypeError,
'`' + name + '` iterator is not a constructor'
);
testIterator(iterator(), [1, 2, 3], st, 'original');
testIterator(drop(iterator(), 0), [1, 2, 3], st, 'drop 0');
testIterator(drop(iterator(), 1), [2, 3], st, 'drop 1');
testIterator(drop(iterator(), 2), [3], st, 'drop 2');
testIterator(drop(iterator(), 3), [], st, 'drop 3');
testIterator(drop(iterator(), Infinity), [], st, 'drop ∞');
st.end();

@@ -89,0 +108,0 @@ });

@@ -25,2 +25,8 @@ 'use strict';

tests: function (every, name, t) {
t['throws'](
function () { return new every(); }, // eslint-disable-line new-cap
TypeError,
'`' + name + '` is not a constructor'
);
forEach(v.primitives.concat(v.objects), function (nonIterator) {

@@ -78,2 +84,13 @@ t['throws'](

st['throws'](
function () { return new every(iterator()); }, // eslint-disable-line new-cap
TypeError,
'`' + name + '` iterator is not a constructor'
);
st['throws'](
function () { return new every(iterator(), function () {}); }, // eslint-disable-line new-cap
TypeError,
'`' + name + '` iterator is not a constructor'
);
testIterator(iterator(), [1, 2, 3], st, 'original');

@@ -80,0 +97,0 @@ st.equal(every(iterator(), function () { return false; }), false, 'every for always-false');

@@ -25,2 +25,8 @@ 'use strict';

tests: function (filter, name, t) {
t['throws'](
function () { return new filter(); }, // eslint-disable-line new-cap
TypeError,
'`' + name + '` is not a constructor'
);
forEach(v.primitives.concat(v.objects), function (nonIterator) {

@@ -78,2 +84,13 @@ t['throws'](

st['throws'](
function () { return new filter(iterator()); }, // eslint-disable-line new-cap
TypeError,
'`' + name + '` iterator is not a constructor'
);
st['throws'](
function () { return new filter(iterator(), function () {}); }, // eslint-disable-line new-cap
TypeError,
'`' + name + '` iterator is not a constructor'
);
testIterator(iterator(), [1, 2, 3], st, 'original');

@@ -80,0 +97,0 @@ testIterator(filter(iterator(), function () { return false; }), [], st, 'filter for always-false');

@@ -24,2 +24,8 @@ 'use strict';

tests: function (find, name, t) {
t['throws'](
function () { return new find(); }, // eslint-disable-line new-cap
TypeError,
'`' + name + '` is not a constructor'
);
forEach(v.primitives.concat(v.objects), function (nonIterator) {

@@ -52,2 +58,13 @@ t['throws'](

st['throws'](
function () { return new find(iterator()); }, // eslint-disable-line new-cap
TypeError,
'`' + name + '` iterator is not a constructor'
);
st['throws'](
function () { return new find(iterator(), function () {}); }, // eslint-disable-line new-cap
TypeError,
'`' + name + '` iterator is not a constructor'
);
testIterator(iterator(), [1, 2, 3], st, 'original');

@@ -54,0 +71,0 @@ st.equal(find(iterator(), function () { return false; }), undefined, 'find for always-false');

@@ -25,2 +25,8 @@ 'use strict';

tests: function (flatMap, name, t) {
t['throws'](
function () { return new flatMap(); }, // eslint-disable-line new-cap
TypeError,
'`' + name + '` is not a constructor'
);
forEach(v.primitives.concat(v.objects), function (nonIterator) {

@@ -53,2 +59,13 @@ t['throws'](

st['throws'](
function () { return new flatMap(iterator()); }, // eslint-disable-line new-cap
TypeError,
'`' + name + '` iterator is not a constructor'
);
st['throws'](
function () { return new flatMap(iterator(), function () {}); }, // eslint-disable-line new-cap
TypeError,
'`' + name + '` iterator is not a constructor'
);
testIterator(iterator(), [1, 2, 3], st, 'original');

@@ -55,0 +72,0 @@

@@ -24,2 +24,8 @@ 'use strict';

tests: function (forEach, name, t) {
t['throws'](
function () { return new forEach(); }, // eslint-disable-line new-cap
TypeError,
'`' + name + '` is not a constructor'
);
forEachNormal(v.primitives.concat(v.objects), function (nonIterator) {

@@ -52,2 +58,13 @@ t['throws'](

st['throws'](
function () { return new forEach(iterator()); }, // eslint-disable-line new-cap
TypeError,
'`' + name + '` iterator is not a constructor'
);
st['throws'](
function () { return new forEach(iterator(), function () {}); }, // eslint-disable-line new-cap
TypeError,
'`' + name + '` iterator is not a constructor'
);
testIterator(iterator(), [1, 2, 3], st, 'original');

@@ -54,0 +71,0 @@

@@ -24,2 +24,8 @@ 'use strict';

tests: function (map, name, t) {
t['throws'](
function () { return new map(); }, // eslint-disable-line new-cap
TypeError,
'`' + name + '` itself is not a constructor'
);
forEach(v.primitives.concat(v.objects), function (nonIterator) {

@@ -85,2 +91,13 @@ t['throws'](

st['throws'](
function () { return new map(iterator()); }, // eslint-disable-line new-cap
TypeError,
'`' + name + '` iterator is not a constructor'
);
st['throws'](
function () { return new map(iterator(), function () {}); }, // eslint-disable-line new-cap
TypeError,
'`' + name + '` iterator is not a constructor'
);
testIterator(iterator(), [1, 2, 3], st, 'original');

@@ -87,0 +104,0 @@ testIterator(map(iterator(), function (x) { return x; }), [1, 2, 3], st, 'identity mapper');

@@ -24,2 +24,8 @@ 'use strict';

tests: function (reduce, name, t) {
t['throws'](
function () { return new reduce(); }, // eslint-disable-line new-cap
TypeError,
'`' + name + '` is not a constructor'
);
forEach(v.primitives.concat(v.objects), function (nonIterator) {

@@ -52,2 +58,13 @@ t['throws'](

st['throws'](
function () { return new reduce(iterator()); }, // eslint-disable-line new-cap
TypeError,
'`' + name + '` iterator is not a constructor'
);
st['throws'](
function () { return new reduce(iterator(), function () {}); }, // eslint-disable-line new-cap
TypeError,
'`' + name + '` iterator is not a constructor'
);
testIterator(iterator(), [1, 2, 3], st, 'original');

@@ -54,0 +71,0 @@

@@ -24,2 +24,8 @@ 'use strict';

tests: function (some, name, t) {
t['throws'](
function () { return new some(); }, // eslint-disable-line new-cap
TypeError,
'`' + name + '` is not a constructor'
);
forEach(v.primitives.concat(v.objects), function (nonIterator) {

@@ -52,2 +58,13 @@ t['throws'](

st['throws'](
function () { return new some(iterator()); }, // eslint-disable-line new-cap
TypeError,
'`' + name + '` iterator is not a constructor'
);
st['throws'](
function () { return new some(iterator(), function () {}); }, // eslint-disable-line new-cap
TypeError,
'`' + name + '` iterator is not a constructor'
);
testIterator(iterator(), [1, 2, 3], st, 'original');

@@ -54,0 +71,0 @@ st.equal(some(iterator(), function () { return false; }), false, 'some for always-false');

@@ -24,2 +24,8 @@ 'use strict';

tests: function (take, name, t) {
t['throws'](
function () { return new take(); }, // eslint-disable-line new-cap
TypeError,
'`' + name + '` itself is not a constructor'
);
forEach(v.primitives.concat(v.objects), function (nonIterator) {

@@ -42,7 +48,9 @@ t['throws'](

var iterator = [1, 2, 3];
var arr = [1, 2, 3];
t.test('actual iteration', { skip: !hasSymbols }, function (st) {
var iterator = callBind(arr[Symbol.iterator], arr);
st['throws'](
function () { take(iterator[Symbol.iterator](), -3); },
function () { take(iterator(), -3); },
RangeError,

@@ -52,9 +60,20 @@ '-3 is not >= 0'

testIterator(iterator[Symbol.iterator](), [1, 2, 3], st, 'original');
testIterator(take(iterator[Symbol.iterator](), 0), [], st, 'take 0');
testIterator(take(iterator[Symbol.iterator](), 1), [1], st, 'take 1');
testIterator(take(iterator[Symbol.iterator](), 2), [1, 2], st, 'take 2');
testIterator(take(iterator[Symbol.iterator](), 3), [1, 2, 3], st, 'take 3');
testIterator(take(iterator[Symbol.iterator](), Infinity), [1, 2, 3], st, 'take ∞');
st['throws'](
function () { return new take(iterator()); }, // eslint-disable-line new-cap
TypeError,
'`' + name + '` iterator is not a constructor'
);
st['throws'](
function () { return new take(iterator(), 0); }, // eslint-disable-line new-cap
TypeError,
'`' + name + '` iterator is not a constructor'
);
testIterator(iterator(), [1, 2, 3], st, 'original');
testIterator(take(iterator(), 0), [], st, 'take 0');
testIterator(take(iterator(), 1), [1], st, 'take 1');
testIterator(take(iterator(), 2), [1, 2], st, 'take 2');
testIterator(take(iterator(), 3), [1, 2, 3], st, 'take 3');
testIterator(take(iterator(), Infinity), [1, 2, 3], st, 'take ∞');
st.end();

@@ -61,0 +80,0 @@ });

@@ -24,2 +24,8 @@ 'use strict';

tests: function (toArray, name, t) {
t['throws'](
function () { return new toArray(); }, // eslint-disable-line new-cap
TypeError,
'`' + name + '` is not a constructor'
);
forEach(v.primitives.concat(v.objects), function (nonIterator) {

@@ -44,2 +50,8 @@ t['throws'](

st['throws'](
function () { return new toArray(iterator()); }, // eslint-disable-line new-cap
TypeError,
'`' + name + '` iterator is not a constructor'
);
testIterator(iterator(), [1, 2, 3], st, 'original');

@@ -46,0 +58,0 @@

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc