https://github.com/ljharb/safe-array-iterator
Get an iterator for an array that's robust against prototype modification.
https://github.com/ljharb/safe-array-iterator
Last synced: 28 days ago
JSON representation
Get an iterator for an array that's robust against prototype modification.
- Host: GitHub
- URL: https://github.com/ljharb/safe-array-iterator
- Owner: ljharb
- License: mit
- Created: 2024-12-19T16:53:28.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-12-19T18:58:33.000Z (10 months ago)
- Last Synced: 2025-01-11T01:48:14.604Z (9 months ago)
- Language: JavaScript
- Homepage:
- Size: 11.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# safe-array-iterator [![Version Badge][npm-version-svg]][package-url]
[![github actions][actions-image]][actions-url]
[![coverage][codecov-image]][codecov-url]
[![License][license-image]][license-url]
[![Downloads][downloads-image]][downloads-url][![npm badge][npm-badge-png]][package-url]
Get an iterator for an array that's robust against prototype modification.
## Getting started
```sh
npm install --save safe-array-iterator
```## Usage/Examples
```js
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`[package-url]: https://npmjs.org/package/safe-array-iterator
[npm-version-svg]: https://versionbadg.es/ljharb/safe-array-iterator.svg
[deps-svg]: https://david-dm.org/ljharb/safe-array-iterator.svg
[deps-url]: https://david-dm.org/ljharb/safe-array-iterator
[dev-deps-svg]: https://david-dm.org/ljharb/safe-array-iterator/dev-status.svg
[dev-deps-url]: https://david-dm.org/ljharb/safe-array-iterator#info=devDependencies
[npm-badge-png]: https://nodei.co/npm/safe-array-iterator.png?downloads=true&stars=true
[license-image]: https://img.shields.io/npm/l/safe-array-iterator.svg
[license-url]: LICENSE
[downloads-image]: https://img.shields.io/npm/dm/safe-array-iterator.svg
[downloads-url]: https://npm-stat.com/charts.html?package=safe-array-iterator
[codecov-image]: https://codecov.io/gh/ljharb/safe-array-iterator/branch/main/graphs/badge.svg
[codecov-url]: https://app.codecov.io/gh/ljharb/safe-array-iterator/
[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/ljharb/safe-array-iterator
[actions-url]: https://github.com/ljharb/safe-array-iterator/actions