-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b59e188
commit a2decb5
Showing
8 changed files
with
832 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,98 +1,100 @@ | ||
{ | ||
"name": "es-map", | ||
"version": "0.0.0", | ||
"description": "An ES-spec-compliant Map shim/polyfill/replacement that works as far down as ES3", | ||
"main": "index.js", | ||
"exports": { | ||
".": [ | ||
{ | ||
"import": "./index.mjs", | ||
"require": "./index.js", | ||
"default": "./index.js" | ||
}, | ||
"./index.js" | ||
], | ||
"./polyfill": [ | ||
{ | ||
"import": "./polyfill.mjs", | ||
"require": "./polyfill.js", | ||
"default": "./polyfill.js" | ||
}, | ||
"./polyfill.js" | ||
], | ||
"./implementation": [ | ||
{ | ||
"import": "./implementation.mjs", | ||
"require": "./implementation.js", | ||
"default": "./implementation.js" | ||
}, | ||
"./implementation.js" | ||
], | ||
"./shim": [ | ||
{ | ||
"import": "./shim.mjs", | ||
"require": "./shim.js", | ||
"default": "./shim.js" | ||
}, | ||
"./shim.js" | ||
], | ||
"./auto": "./auto.js", | ||
"./package.json": "./package.json" | ||
}, | ||
"scripts": { | ||
"prepublish": "safe-publish-latest", | ||
"pretest": "npm run lint", | ||
"lint": "eslint --ext=js,mjs .", | ||
"tests-only": "tape 'test/**/*.js'", | ||
"tests-esm": "node test/index.mjs", | ||
"test": "npm run tests-only && npm run tests-esm", | ||
"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/es-shims/es-map.git" | ||
}, | ||
"keywords": [ | ||
"Set", | ||
"Map", | ||
"collections", | ||
"shim", | ||
"polyfill", | ||
"es-shim", | ||
"API" | ||
], | ||
"author": "Nicolò Ribaudo <nicolo.ribaudo@gmail.com>", | ||
"funding": { | ||
"url": "https://github.com/es-shims/es-map?sponsor=1" | ||
}, | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/es-shims/es-map/issues" | ||
}, | ||
"homepage": "https://github.com/es-shims/es-map#readme", | ||
"devDependencies": { | ||
"@ljharb/eslint-config": "^17.2.0", | ||
"aud": "^1.1.2", | ||
"auto-changelog": "^2.2.1", | ||
"eslint": "^7.12.0", | ||
"functions-have-names": "^1.2.1", | ||
"has-strict-mode": "^1.0.0", | ||
"safe-publish-latest": "^1.1.4", | ||
"tape": "^5.0.1" | ||
}, | ||
"dependencies": { | ||
"define-properties": "^1.1.3", | ||
"es-abstract": "^1.18.0-next.1", | ||
"has-symbols": "^1.0.1" | ||
}, | ||
"auto-changelog": { | ||
"output": "CHANGELOG.md", | ||
"template": "keepachangelog", | ||
"unreleased": false, | ||
"commitLimit": false, | ||
"backfillLimit": false, | ||
"hideCredit": true | ||
} | ||
"name": "es-map", | ||
"version": "0.0.0", | ||
"description": "An ES-spec-compliant Map shim/polyfill/replacement that works as far down as ES3", | ||
"main": "index.js", | ||
"exports": { | ||
".": [ | ||
{ | ||
"import": "./index.mjs", | ||
"require": "./index.js", | ||
"default": "./index.js" | ||
}, | ||
"./index.js" | ||
], | ||
"./polyfill": [ | ||
{ | ||
"import": "./polyfill.mjs", | ||
"require": "./polyfill.js", | ||
"default": "./polyfill.js" | ||
}, | ||
"./polyfill.js" | ||
], | ||
"./implementation": [ | ||
{ | ||
"import": "./implementation.mjs", | ||
"require": "./implementation.js", | ||
"default": "./implementation.js" | ||
}, | ||
"./implementation.js" | ||
], | ||
"./shim": [ | ||
{ | ||
"import": "./shim.mjs", | ||
"require": "./shim.js", | ||
"default": "./shim.js" | ||
}, | ||
"./shim.js" | ||
], | ||
"./auto": "./auto.js", | ||
"./package.json": "./package.json" | ||
}, | ||
"scripts": { | ||
"prepublish": "safe-publish-latest", | ||
"pretest": "npm run lint", | ||
"lint": "eslint --ext=js,mjs .", | ||
"tests-only": "tape 'test/**/*.js'", | ||
"tests-esm": "node test/index.mjs", | ||
"test": "npm run tests-only && npm run tests-esm", | ||
"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/es-shims/es-map.git" | ||
}, | ||
"keywords": [ | ||
"Set", | ||
"Map", | ||
"collections", | ||
"shim", | ||
"polyfill", | ||
"es-shim", | ||
"API" | ||
], | ||
"author": "Nicolò Ribaudo <nicolo.ribaudo@gmail.com>", | ||
"funding": { | ||
"url": "https://github.com/es-shims/es-map?sponsor=1" | ||
}, | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/es-shims/es-map/issues" | ||
}, | ||
"homepage": "https://github.com/es-shims/es-map#readme", | ||
"devDependencies": { | ||
"@ljharb/eslint-config": "^17.2.0", | ||
"array.from": "^1.1.0", | ||
"aud": "^1.1.2", | ||
"auto-changelog": "^2.2.1", | ||
"eslint": "^7.12.0", | ||
"functions-have-names": "^1.2.1", | ||
"has-strict-mode": "^1.0.0", | ||
"safe-publish-latest": "^1.1.4", | ||
"tape": "^5.0.1" | ||
}, | ||
"dependencies": { | ||
"define-properties": "^1.1.3", | ||
"es-abstract": "^1.18.0-next.1", | ||
"globalthis": "^1.0.1", | ||
"has-symbols": "^1.0.1" | ||
}, | ||
"auto-changelog": { | ||
"output": "CHANGELOG.md", | ||
"template": "keepachangelog", | ||
"unreleased": false, | ||
"commitLimit": false, | ||
"backfillLimit": false, | ||
"hideCredit": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
'use strict'; | ||
|
||
var Map = require('../'); | ||
var test = require('tape'); | ||
var runTests = require('./tests'); | ||
|
||
test('as a function', function (t) { | ||
runTests(Map, t); | ||
|
||
t.end(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import Map, * as MapModule from 'es-map'; | ||
import test from 'tape'; | ||
import runTests from './tests.js'; | ||
|
||
test('as a function', (t) => { | ||
console.log(Map); | ||
|
||
runTests(Map, t); | ||
|
||
t.end(); | ||
}); | ||
|
||
test('named exports', async (t) => { | ||
t.deepEqual( | ||
Object.keys(MapModule).sort(), | ||
['default', 'shim', 'getPolyfill', 'implementation'].sort(), | ||
'has expected named exports' | ||
); | ||
|
||
const { shim, getPolyfill, implementation } = MapModule; | ||
t.equal(await import('es-map/shim'), shim, 'shim named export matches deep export'); | ||
t.equal(await import('es-map/implementation'), implementation, 'implementation named export matches deep export'); | ||
t.equal(await import('es-map/polyfill'), getPolyfill, 'getPolyfill named export matches deep export'); | ||
|
||
t.end(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
'use strict'; | ||
|
||
require('../shim')(); | ||
|
||
var test = require('tape'); | ||
|
||
/* | ||
* These delete are necessary because es-get-iterator (used by the array.from polyfill) | ||
* only works when it's required _after_ shimming the Map. | ||
*/ | ||
delete require.cache[process.cwd() + '/node_modules/is-map/index.js']; | ||
delete require.cache[process.cwd() + '/node_modules/es-get-iterator/node_modules/es-abstract/helpers/callBound.js']; | ||
delete require.cache[process.cwd() + '/node_modules/es-get-iterator/node_modules/es-abstract/GetIntrinsic.js']; | ||
delete require.cache[process.cwd() + '/node_modules/es-get-iterator/index.js']; | ||
delete require.cache[process.cwd() + '/node_modules/iterate-values/index.js']; | ||
delete require.cache[process.cwd() + '/node_modules/array.from/implementation.js']; | ||
delete require.cache[process.cwd() + '/node_modules/array.from/index.js']; | ||
var ArrayFrom = require('array.from'); | ||
|
||
var runTests = require('./tests'); | ||
|
||
test('shimmed', function (t) { | ||
runTests(Map, t); | ||
|
||
// This test only works when the polyfill is applied globally | ||
t.test('should have an iterator that works with polyfilled Array.from', { skip: true }, function (st) { | ||
var map = new Map(); | ||
|
||
st.equal(map.set('a', 1), map, 'add "a"->1 to map'); | ||
st.equal(map.set('b', NaN), map, 'add "b"->NaN to map'); | ||
st.equal(map.set('c', false), map, 'add "c"->false to map'); | ||
st.deepEqual(ArrayFrom(map), [['a', 1], ['b', NaN], ['c', false]], 'Array.from(map) returns the entries'); | ||
|
||
// These don't work with es-get-iterator | ||
st.deepEqual(ArrayFrom(map.keys()), ['a', 'b', 'c'], 'Array.from(map.keys()) returns the keys'); | ||
st.deepEqual(ArrayFrom(map.values()), [1, NaN, false], 'Array.from(map.values()) returns the values'); | ||
st.deepEqual(ArrayFrom(map.entries()), [['a', 1], ['b', NaN], ['c', false]], 'Array.from(map.entries()) returns the entries'); | ||
|
||
st.end(); | ||
}); | ||
|
||
t.end(); | ||
}); |
Oops, something went wrong.