{"_id":"safe-push-apply","_rev":"3745014","name":"safe-push-apply","description":"Push an array of items into an array, while being robust against prototype modification","dist-tags":{"latest":"1.0.0"},"maintainers":[{"name":"ljharb","email":""}],"time":{"modified":"2025-02-13T06:28:18.000Z","created":"2024-12-29T03:51:58.209Z","1.0.0":"2024-12-29T03:51:58.209Z"},"users":{},"author":{"name":"Jordan Harband","email":"ljharb@gmail.com"},"repository":{"type":"git","url":"git+https://github.com/ljharb/safe-push-apply.git"},"versions":{"1.0.0":{"name":"safe-push-apply","version":"1.0.0","description":"Push an array of items into an array, while being robust against prototype modification","main":"index.js","exports":{".":"./index.js","./package.json":"./package.json"},"sideEffects":false,"scripts":{"prepack":"npmignore --auto --commentLines=autogenerated","version":"auto-changelog && git add CHANGELOG.md","postversion":"auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\"","prelint":"evalmd README.md","lint":"eslint --ext=js,mjs .","postlint":"tsc && attw -P","prepublish":"not-in-publish || npm run prepublishOnly","prepublishOnly":"safe-publish-latest","pretest":"npm run lint","tests-only":"nyc tape test","test":"npm run tests-only","posttest":"npx npm@'>= 10.2' audit --production"},"keywords":["array","push","apply","pushApply","safe"],"author":{"name":"Jordan Harband","email":"ljharb@gmail.com"},"funding":{"url":"https://github.com/sponsors/ljharb"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/ljharb/safe-push-apply.git"},"bugs":{"url":"https://github.com/ljharb/safe-push-apply/issues"},"homepage":"https://github.com/ljharb/safe-push-apply#readme","dependencies":{"es-errors":"^1.3.0","isarray":"^2.0.5"},"devDependencies":{"@arethetypeswrong/cli":"^0.17.1","@ljharb/eslint-config":"^21.1.1","@ljharb/tsconfig":"^0.2.2","@types/isarray":"^2.0.3","@types/tape":"^5.6.5","auto-changelog":"^2.5.0","encoding":"^0.1.13","eslint":"=8.8.0","evalmd":"^0.0.19","in-publish":"^2.0.1","npmignore":"^0.3.1","nyc":"^10.3.2","safe-publish-latest":"^2.0.0","tape":"^5.9.0","typescript":"next"},"engines":{"node":">= 0.4"},"auto-changelog":{"output":"CHANGELOG.md","template":"keepachangelog","unreleased":false,"commitLimit":false,"backfillLimit":false,"hideCredit":true},"publishConfig":{"ignore":[".github/workflows"]},"_id":"safe-push-apply@1.0.0","gitHead":"ad4e4467f70f7d8da81fd30a36347b35d8c8850c","types":"./index.d.ts","_nodeVersion":"23.5.0","_npmVersion":"10.9.2","dist":{"shasum":"01850e981c1602d398c85081f360e4e6d03d27f5","size":4053,"noattachment":false,"key":"/safe-push-apply/-/safe-push-apply-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/safe-push-apply/download/safe-push-apply-1.0.0.tgz"},"_npmUser":{"name":"ljharb","email":"ljharb@gmail.com"},"directories":{},"maintainers":[{"name":"ljharb","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/safe-push-apply_1.0.0_1735444318029_0.956433941949417"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2024-12-29T03:51:58.209Z","publish_time":1735444318209,"_source_registry_name":"default","_cnpm_publish_time":1735444318209}},"readme":"# safe-push-apply <sup>[![Version Badge][npm-version-svg]][package-url]</sup>\n\n[![github actions][actions-image]][actions-url]\n[![coverage][codecov-image]][codecov-url]\n[![License][license-image]][license-url]\n[![Downloads][downloads-image]][downloads-url]\n\n[![npm badge][npm-badge-png]][package-url]\n\nPush an array of items into an array, while being robust against prototype modification.\n\n## Getting started\n\n```sh\nnpm install --save safe-push-apply\n```\n\n## Usage/Examples\n\n```js\nvar safePushApply = require('safe-push-apply');\nvar assert = require('assert');\n\nvar arr = [1, 2, 3];\n\nvar orig = Array.prototype[Symbol.iterator];\ndelete Array.prototype[Symbol.iterator];\nassert.throws(() => {\n    try {\n        arr.push(...[3, 4, 5]);\n    } finally {\n        Array.prototype[Symbol.iterator] = orig;\n    }\n}, 'array is not iterable anymore');\n\ndelete Array.prototype.push;\nsafePushApply(arr, [3, 4, 5]);\n\nassert.deepEqual(arr, [1, 2, 3, 3, 4, 5]);\n```\n\n## Tests\nSimply clone the repo, `npm install`, and run `npm test`\n\n[package-url]: https://npmjs.org/package/safe-push-apply\n[npm-version-svg]: https://versionbadg.es/ljharb/safe-push-apply.svg\n[deps-svg]: https://david-dm.org/ljharb/safe-push-apply.svg\n[deps-url]: https://david-dm.org/ljharb/safe-push-apply\n[dev-deps-svg]: https://david-dm.org/ljharb/safe-push-apply/dev-status.svg\n[dev-deps-url]: https://david-dm.org/ljharb/safe-push-apply#info=devDependencies\n[npm-badge-png]: https://nodei.co/npm/safe-push-apply.png?downloads=true&stars=true\n[license-image]: https://img.shields.io/npm/l/safe-push-apply.svg\n[license-url]: LICENSE\n[downloads-image]: https://img.shields.io/npm/dm/safe-push-apply.svg\n[downloads-url]: https://npm-stat.com/charts.html?package=safe-push-apply\n[codecov-image]: https://codecov.io/gh/ljharb/safe-push-apply/branch/main/graphs/badge.svg\n[codecov-url]: https://app.codecov.io/gh/ljharb/safe-push-apply/\n[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/ljharb/safe-push-apply\n[actions-url]: https://github.com/ljharb/safe-push-apply/actions\n","_attachments":{},"homepage":"https://github.com/ljharb/safe-push-apply#readme","bugs":{"url":"https://github.com/ljharb/safe-push-apply/issues"},"license":"MIT"}