pax_global_header00006660000000000000000000000064142251064510014512gustar00rootroot0000000000000052 comment=4927833211c6ca86d5a892b979b6804f1edc4c71 es-shim-unscopables-1.0.0/000077500000000000000000000000001422510645100153715ustar00rootroot00000000000000es-shim-unscopables-1.0.0/.eslintrc000066400000000000000000000011111422510645100172070ustar00rootroot00000000000000{ "root": true, "extends": "@ljharb", "env": { "es6": true, "es2017": true, "es2020": true, "es2021": true, "es2022": true, }, "rules": { "array-bracket-newline": 0, "complexity": 0, "eqeqeq": [2, "allow-null"], "func-name-matching": 0, "id-length": 0, "max-lines-per-function": [2, 80], "max-params": [2, 4], "max-statements": 0, "max-statements-per-line": [2, { "max": 2 }], "multiline-comment-style": 0, "no-magic-numbers": 0, "sort-keys": 0, }, "overrides": [ { "files": "test/**", "rules": { "new-cap": 0, }, }, ], } es-shim-unscopables-1.0.0/.github/000077500000000000000000000000001422510645100167315ustar00rootroot00000000000000es-shim-unscopables-1.0.0/.github/FUNDING.yml000066400000000000000000000011161422510645100205450ustar00rootroot00000000000000# These are supported funding model platforms github: [ljharb] patreon: # Replace with a single Patreon username open_collective: # Replace with a single Open Collective username ko_fi: # Replace with a single Ko-fi username tidelift: npm/es-shim-unscopables community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry liberapay: # Replace with a single Liberapay username issuehunt: # Replace with a single IssueHunt username otechie: # Replace with a single Otechie username custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] es-shim-unscopables-1.0.0/.github/workflows/000077500000000000000000000000001422510645100207665ustar00rootroot00000000000000es-shim-unscopables-1.0.0/.github/workflows/node-aught.yml000066400000000000000000000005161422510645100235460ustar00rootroot00000000000000name: 'Tests: node.js < 10' on: [pull_request, push] jobs: tests: uses: ljharb/actions/.github/workflows/node.yml@main with: range: '< 10' type: minors command: npm run tests-only node: name: 'node < 10' needs: [tests] runs-on: ubuntu-latest steps: - run: 'echo tests completed' es-shim-unscopables-1.0.0/.github/workflows/node-pretest.yml000066400000000000000000000002061422510645100241200ustar00rootroot00000000000000name: 'Tests: pretest/posttest' on: [pull_request, push] jobs: tests: uses: ljharb/actions/.github/workflows/pretest.yml@main es-shim-unscopables-1.0.0/.github/workflows/node-tens.yml000066400000000000000000000005211422510645100234030ustar00rootroot00000000000000name: 'Tests: node.js >= 10' on: [pull_request, push] jobs: tests: uses: ljharb/actions/.github/workflows/node.yml@main with: range: '>= 10' type: minors command: npm run tests-only node: name: 'node >= 10' needs: [tests] runs-on: ubuntu-latest steps: - run: 'echo tests completed' es-shim-unscopables-1.0.0/.github/workflows/rebase.yml000066400000000000000000000004111422510645100227460ustar00rootroot00000000000000name: Automatic Rebase on: [pull_request_target] jobs: _: name: "Automatic Rebase" runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - uses: ljharb/rebase@master env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} es-shim-unscopables-1.0.0/.github/workflows/require-allow-edits.yml000066400000000000000000000003031422510645100254030ustar00rootroot00000000000000name: Require “Allow Edits” on: [pull_request_target] jobs: _: name: "Require “Allow Edits”" runs-on: ubuntu-latest steps: - uses: ljharb/require-allow-edits@main es-shim-unscopables-1.0.0/.gitignore000066400000000000000000000032351422510645100173640ustar00rootroot00000000000000# Logs logs *.log npm-debug.log* yarn-debug.log* yarn-error.log* lerna-debug.log* # Diagnostic reports (https://nodejs.org/api/report.html) report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json # Runtime data pids *.pid *.seed *.pid.lock # Directory for instrumented libs generated by jscoverage/JSCover lib-cov # Coverage directory used by tools like istanbul coverage *.lcov # nyc test coverage .nyc_output # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) .grunt # Bower dependency directory (https://bower.io/) bower_components # node-waf configuration .lock-wscript # Compiled binary addons (https://nodejs.org/api/addons.html) build/Release # Dependency directories node_modules/ jspm_packages/ # TypeScript v1 declaration files typings/ # TypeScript cache *.tsbuildinfo # Optional npm cache directory .npm # Optional eslint cache .eslintcache # Microbundle cache .rpt2_cache/ .rts2_cache_cjs/ .rts2_cache_es/ .rts2_cache_umd/ # Optional REPL history .node_repl_history # Output of 'npm pack' *.tgz # Yarn Integrity file .yarn-integrity # dotenv environment variables file .env .env.test # parcel-bundler cache (https://parceljs.org/) .cache # Next.js build output .next # Nuxt.js build / generate output .nuxt dist # Gatsby files .cache/ # Comment in the public line in if your project uses Gatsby and *not* Next.js # https://nextjs.org/blog/next-9-1#public-directory-support # public # vuepress build output .vuepress/dist # Serverless directories .serverless/ # FuseBox cache .fusebox/ # DynamoDB Local files .dynamodb/ # TernJS port file .tern-port # Only apps should have lockfiles npm-shrinkwrap.json package-lock.json yarn.lock es-shim-unscopables-1.0.0/.npmignore000066400000000000000000000032601422510645100173710ustar00rootroot00000000000000# Logs logs *.log npm-debug.log* yarn-debug.log* yarn-error.log* lerna-debug.log* # Diagnostic reports (https://nodejs.org/api/report.html) report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json # Runtime data pids *.pid *.seed *.pid.lock # Directory for instrumented libs generated by jscoverage/JSCover lib-cov # Coverage directory used by tools like istanbul coverage *.lcov # nyc test coverage .nyc_output # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) .grunt # Bower dependency directory (https://bower.io/) bower_components # node-waf configuration .lock-wscript # Compiled binary addons (https://nodejs.org/api/addons.html) build/Release # Dependency directories node_modules/ jspm_packages/ # TypeScript v1 declaration files typings/ # TypeScript cache *.tsbuildinfo # Optional npm cache directory .npm # Optional eslint cache .eslintcache # Microbundle cache .rpt2_cache/ .rts2_cache_cjs/ .rts2_cache_es/ .rts2_cache_umd/ # Optional REPL history .node_repl_history # Output of 'npm pack' *.tgz # Yarn Integrity file .yarn-integrity # dotenv environment variables file .env .env.test # parcel-bundler cache (https://parceljs.org/) .cache # Next.js build output .next # Nuxt.js build / generate output .nuxt dist # Gatsby files .cache/ # Comment in the public line in if your project uses Gatsby and *not* Next.js # https://nextjs.org/blog/next-9-1#public-directory-support # public # vuepress build output .vuepress/dist # Serverless directories .serverless/ # FuseBox cache .fusebox/ # DynamoDB Local files .dynamodb/ # TernJS port file .tern-port # Only apps should have lockfiles npm-shrinkwrap.json package-lock.json yarn.lock .github/workflows es-shim-unscopables-1.0.0/.npmrc000066400000000000000000000000671422510645100165140ustar00rootroot00000000000000package-lock=false allow-same-version=true message=v%s es-shim-unscopables-1.0.0/.nycrc000066400000000000000000000002131422510645100165040ustar00rootroot00000000000000{ "all": true, "check-coverage": false, "reporter": ["text-summary", "text", "html", "json"], "exclude": [ "coverage", "test" ] } es-shim-unscopables-1.0.0/CHANGELOG.md000066400000000000000000000011661422510645100172060ustar00rootroot00000000000000### Changelog All notable changes to this project will be documented in this file. Dates are displayed in UTC. Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). #### v1.0.0 > 11 April 2022 - Initial implementation, tests [`0313267`](https://github.com/ljharb/es-shim-unscopables/commit/03132672560a06df8a36685c1688793d445ea034) - Initial commit [`5a68e27`](https://github.com/ljharb/es-shim-unscopables/commit/5a68e27e8f11d8b453c00e9239b35ec8795c850e) - [meta] do not publish workflow files [`4e29785`](https://github.com/ljharb/es-shim-unscopables/commit/4e2978541c25ce590589d5f23f311af6ca3618a7) es-shim-unscopables-1.0.0/LICENSE000066400000000000000000000020571422510645100164020ustar00rootroot00000000000000MIT License Copyright (c) 2022 Jordan Harband Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. es-shim-unscopables-1.0.0/README.md000066400000000000000000000043121422510645100166500ustar00rootroot00000000000000# es-shim-unscopables [![Version Badge][npm-version-svg]][package-url] [![github actions][actions-image]][actions-url] [![coverage][codecov-image]][codecov-url] [![dependency status][deps-svg]][deps-url] [![dev dependency status][dev-deps-svg]][dev-deps-url] [![License][license-image]][license-url] [![Downloads][downloads-image]][downloads-url] [![npm badge][npm-badge-png]][package-url] Helper package to shim a method into `Array.prototype[Symbol.unscopables]` ## Example ```js const assert = require('assert'); const shimUnscopables = require('es-shim-unscopables'); let copyWithin; let concat; with ([]) { assert.equal(concat, Array.prototype.concat); assert.notEqual(copyWithin, Array.prototype.copyWithin); } shimUnscopables('concat'); with ([]) { assert.notEqual(concat, Array.prototype.concat); assert.notEqual(copyWithin, Array.prototype.copyWithin); } ``` ## Tests Simply clone the repo, `npm install`, and run `npm test` ## Security Please email [@ljharb](https://github.com/ljharb) or see https://tidelift.com/security if you have a potential security vulnerability to report. [package-url]: https://npmjs.org/package/es-shim-unscopables [npm-version-svg]: https://versionbadg.es/ljharb/es-shim-unscopables.svg [deps-svg]: https://david-dm.org/ljharb/es-shim-unscopables.svg [deps-url]: https://david-dm.org/ljharb/es-shim-unscopables [dev-deps-svg]: https://david-dm.org/ljharb/es-shim-unscopables/dev-status.svg [dev-deps-url]: https://david-dm.org/ljharb/es-shim-unscopables#info=devDependencies [npm-badge-png]: https://nodei.co/npm/es-shim-unscopables.png?downloads=true&stars=true [license-image]: https://img.shields.io/npm/l/es-shim-unscopables.svg [license-url]: LICENSE [downloads-image]: https://img.shields.io/npm/dm/es-shim-unscopables.svg [downloads-url]: https://npm-stat.com/charts.html?package=es-shim-unscopables [codecov-image]: https://codecov.io/gh/ljharb/es-shim-unscopables/branch/main/graphs/badge.svg [codecov-url]: https://app.codecov.io/gh/ljharb/es-shim-unscopables/ [actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/ljharb/es-shim-unscopables [actions-url]: https://github.com/ljharb/es-shim-unscopables/actions es-shim-unscopables-1.0.0/index.js000066400000000000000000000010421422510645100170330ustar00rootroot00000000000000'use strict'; var has = require('has'); var hasUnscopables = typeof Symbol === 'function' && typeof Symbol.unscopables === 'symbol'; var map = hasUnscopables && Array.prototype[Symbol.unscopables]; var $TypeError = TypeError; module.exports = function shimUnscopables(method) { if (typeof method !== 'string' || !method) { throw new $TypeError('method must be a non-empty string'); } if (!has(Array.prototype, method)) { throw new $TypeError('method must be on Array.prototype'); } if (hasUnscopables) { map[method] = true; } }; es-shim-unscopables-1.0.0/package.json000066400000000000000000000027541422510645100176670ustar00rootroot00000000000000{ "name": "es-shim-unscopables", "version": "1.0.0", "description": "Helper package to shim a method into `Array.prototype[Symbol.unscopables]`", "main": "index.js", "exports": { ".": "./index.js", "./package.json": "./package.json" }, "scripts": { "prepublish": "not-in-publish || npm run prepublishOnly", "prepublishOnly": "safe-publish-latest", "prelint-disabled": "evalmd README.md", "lint": "eslint --ext=.js,.mjs .", "pretest": "npm run lint", "tests-only": "nyc tape 'test/**/*.js'", "test": "npm run tests-only", "posttest": "aud --production", "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)\")\"" }, "repository": { "type": "git", "url": "git+https://github.com/ljharb/es-shim-unscopables.git" }, "author": "Jordan Harband ", "license": "MIT", "bugs": { "url": "https://github.com/ljharb/es-shim-unscopables/issues" }, "homepage": "https://github.com/ljharb/es-shim-unscopables#readme", "devDependencies": { "@ljharb/eslint-config": "^21.0.0", "aud": "^2.0.0", "auto-changelog": "^2.4.0", "es-value-fixtures": "^1.2.1", "eslint": "=8.8.0", "evalmd": "^0.0.19", "for-each": "^0.3.3", "in-publish": "^2.0.1", "nyc": "^10.3.2", "object-inspect": "^1.12.0", "safe-publish-latest": "^2.0.0", "tape": "^5.5.3" }, "dependencies": { "has": "^1.0.3" } } es-shim-unscopables-1.0.0/test/000077500000000000000000000000001422510645100163505ustar00rootroot00000000000000es-shim-unscopables-1.0.0/test/index.js000066400000000000000000000035011422510645100200140ustar00rootroot00000000000000'use strict'; var test = require('tape'); var inspect = require('object-inspect'); var v = require('es-value-fixtures'); var forEach = require('for-each'); var has = require('has'); var shimUnscopables = require('../'); var sortSymbols = function (a, b) { return inspect(a).localeCompare(inspect(b)); }; test('shimUnscopables', function (t) { t.equal(typeof shimUnscopables, 'function', 'is a function'); forEach(v.nonStrings, function (notNonEmptyString) { t['throws']( function () { shimUnscopables(notNonEmptyString); }, TypeError, inspect(notNonEmptyString) + ' is not a non-empty String' ); }); t['throws']( function () { shimUnscopables('x'); }, TypeError, inspect('x') + ' is not on Array.prototype' ); t.test('no symbols', { skip: typeof Symbol === 'function' }, function (st) { st.doesNotThrow(function () { shimUnscopables('forEach'); }); st.end(); }); t.test('symbols, no unscopables', { skip: typeof Symbol !== 'function' || Symbol.unscopables }, function (st) { st.deepEqual(Object.getOwnPropertySymbols(Array.prototype), [Symbol.iterator]); shimUnscopables('forEach'); st.deepEqual(Object.getOwnPropertySymbols(Array.prototype), [Symbol.iterator]); st.end(); }); t.test('Symbol.unscopables', { skip: typeof Symbol !== 'function' || !Symbol.unscopables }, function (st) { st.deepEqual( Object.getOwnPropertySymbols(Array.prototype).sort(sortSymbols), [Symbol.iterator, Symbol.unscopables] ); st.notOk(has(Array.prototype[Symbol.unscopables], 'forEach'), 'unscopables map lacks forEach'); shimUnscopables('forEach'); st.deepEqual( Object.getOwnPropertySymbols(Array.prototype).sort(sortSymbols), [Symbol.iterator, Symbol.unscopables] ); st.equal(Array.prototype[Symbol.unscopables].forEach, true, 'unscopables map has forEach'); st.end(); }); t.end(); }); es-shim-unscopables-1.0.0/test/with.js000066400000000000000000000015071422510645100176640ustar00rootroot00000000000000/* eslint no-restricted-syntax: 0, no-with: 0, strict: 0 */ var test = require('tape'); var shimUnscopables = require('../'); test('`with` statement', { skip: typeof Symbol !== 'function' || !Symbol.unscopables }, function (t) { var entries; var concat; with ([]) { t.equal(concat, Array.prototype.concat, 'concat is dynamically bound'); t.notEqual(entries, Array.prototype.entries, 'entries is not dynamically bound'); } var obj = { foo: 1, bar: 2 }; var foo; var bar; obj[Symbol.unscopables] = { foo: true }; with (obj) { t.equal(foo, undefined); t.equal(bar, obj.bar); } shimUnscopables('concat'); with ([]) { t.notEqual(concat, Array.prototype.concat, 'concat is no longer dynamically bound'); t.notEqual(entries, Array.prototype.entries, 'entries is still not dynamically bound'); } t.end(); });