Skip to content

Get an iterator for an array that's robust against prototype modification.

License

Notifications You must be signed in to change notification settings

ljharb/safe-array-iterator

Repository files navigation

safe-array-iterator Version Badge

github actions coverage License Downloads

npm badge

Get an iterator for an array that's robust against prototype modification.

Getting started

npm install --save safe-array-iterator

Usage/Examples

var safeArrayIterator = require('safe-array-iterator');
var assert = require('assert');

delete Array.prototype[Symbol.iterator];

const arr = [1, 2, 3];
const results = [];
for (const x of safeArrayIterator(arr)) {
    results.push(x);
}

assert.deepEqual(results, arr);

Tests

Simply clone the repo, npm install, and run npm test

About

Get an iterator for an array that's robust against prototype modification.

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks