pax_global_header 0000666 0000000 0000000 00000000064 14225106451 0014512 g ustar 00root root 0000000 0000000 52 comment=4927833211c6ca86d5a892b979b6804f1edc4c71
es-shim-unscopables-1.0.0/ 0000775 0000000 0000000 00000000000 14225106451 0015371 5 ustar 00root root 0000000 0000000 es-shim-unscopables-1.0.0/.eslintrc 0000664 0000000 0000000 00000001111 14225106451 0017207 0 ustar 00root root 0000000 0000000 {
"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/ 0000775 0000000 0000000 00000000000 14225106451 0016731 5 ustar 00root root 0000000 0000000 es-shim-unscopables-1.0.0/.github/FUNDING.yml 0000664 0000000 0000000 00000001116 14225106451 0020545 0 ustar 00root root 0000000 0000000 # 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/ 0000775 0000000 0000000 00000000000 14225106451 0020766 5 ustar 00root root 0000000 0000000 es-shim-unscopables-1.0.0/.github/workflows/node-aught.yml 0000664 0000000 0000000 00000000516 14225106451 0023546 0 ustar 00root root 0000000 0000000 name: '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.yml 0000664 0000000 0000000 00000000206 14225106451 0024120 0 ustar 00root root 0000000 0000000 name: '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.yml 0000664 0000000 0000000 00000000521 14225106451 0023403 0 ustar 00root root 0000000 0000000 name: '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.yml 0000664 0000000 0000000 00000000411 14225106451 0022746 0 ustar 00root root 0000000 0000000 name: 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.yml 0000664 0000000 0000000 00000000303 14225106451 0025403 0 ustar 00root root 0000000 0000000 name: 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/.gitignore 0000664 0000000 0000000 00000003235 14225106451 0017364 0 ustar 00root root 0000000 0000000 # 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/.npmignore 0000664 0000000 0000000 00000003260 14225106451 0017371 0 ustar 00root root 0000000 0000000 # 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/.npmrc 0000664 0000000 0000000 00000000067 14225106451 0016514 0 ustar 00root root 0000000 0000000 package-lock=false
allow-same-version=true
message=v%s
es-shim-unscopables-1.0.0/.nycrc 0000664 0000000 0000000 00000000213 14225106451 0016504 0 ustar 00root root 0000000 0000000 {
"all": true,
"check-coverage": false,
"reporter": ["text-summary", "text", "html", "json"],
"exclude": [
"coverage",
"test"
]
}
es-shim-unscopables-1.0.0/CHANGELOG.md 0000664 0000000 0000000 00000001166 14225106451 0017206 0 ustar 00root root 0000000 0000000 ### 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/LICENSE 0000664 0000000 0000000 00000002057 14225106451 0016402 0 ustar 00root root 0000000 0000000 MIT 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.md 0000664 0000000 0000000 00000004312 14225106451 0016650 0 ustar 00root root 0000000 0000000 # 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.js 0000664 0000000 0000000 00000001042 14225106451 0017033 0 ustar 00root root 0000000 0000000 '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.json 0000664 0000000 0000000 00000002754 14225106451 0017667 0 ustar 00root root 0000000 0000000 {
"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/ 0000775 0000000 0000000 00000000000 14225106451 0016350 5 ustar 00root root 0000000 0000000 es-shim-unscopables-1.0.0/test/index.js 0000664 0000000 0000000 00000003501 14225106451 0020014 0 ustar 00root root 0000000 0000000 '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.js 0000664 0000000 0000000 00000001507 14225106451 0017664 0 ustar 00root root 0000000 0000000 /* 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();
});