-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Breaking] rename package to
at
from item
Per 2020.11.17 TC39
- Loading branch information
Showing
11 changed files
with
87 additions
and
84 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,15 +1,15 @@ | ||
import callBind from 'call-bind'; | ||
import RequireObjectCoercible from 'es-abstract/2020/RequireObjectCoercible.js'; | ||
|
||
import getPolyfill from 'array.prototype.item/polyfill'; | ||
import getPolyfill from 'array.prototype.at/polyfill'; | ||
|
||
const bound = callBind(getPolyfill()); | ||
|
||
export default function item(array, index) { | ||
export default function at(array, index) { | ||
RequireObjectCoercible(array); | ||
return bound(array, index); | ||
} | ||
|
||
export { default as getPolyfill } from 'array.prototype.item/polyfill'; | ||
export { default as implementation } from 'array.prototype.item/implementation'; | ||
export { default as shim } from 'array.prototype.item/shim'; | ||
export { default as getPolyfill } from 'array.prototype.at/polyfill'; | ||
export { default as implementation } from 'array.prototype.at/implementation'; | ||
export { default as shim } from 'array.prototype.at/shim'; |
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,17 +1,17 @@ | ||
'use strict'; | ||
|
||
var item = require('..'); | ||
var at = require('..'); | ||
var test = require('tape'); | ||
var runTests = require('./tests'); | ||
|
||
test('as a function', function (t) { | ||
t.test('bad array/this value', function (st) { | ||
st['throws'](item.bind(null, undefined, function () {}), TypeError, 'undefined is not an object'); | ||
st['throws'](item.bind(null, null, function () {}), TypeError, 'null is not an object'); | ||
st['throws'](at.bind(null, undefined, function () {}), TypeError, 'undefined is not an object'); | ||
st['throws'](at.bind(null, null, function () {}), TypeError, 'null is not an object'); | ||
st.end(); | ||
}); | ||
|
||
runTests(item, t); | ||
runTests(at, 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 |
---|---|---|
@@ -1,31 +1,31 @@ | ||
import item from 'array.prototype.item'; | ||
import * as itemModule from 'array.prototype.item'; | ||
import at from 'array.prototype.at'; | ||
import * as atModule from 'array.prototype.at'; | ||
import test from 'tape'; | ||
import runTests from './tests.js'; | ||
|
||
test('as a function', (t) => { | ||
t.test('bad array/this value', (st) => { | ||
st.throws(() => item(undefined), TypeError, 'undefined is not an object'); | ||
st.throws(() => item(null), TypeError, 'null is not an object'); | ||
st.throws(() => at(undefined), TypeError, 'undefined is not an object'); | ||
st.throws(() => at(null), TypeError, 'null is not an object'); | ||
st.end(); | ||
}); | ||
|
||
runTests(item, t); | ||
runTests(at, t); | ||
|
||
t.end(); | ||
}); | ||
|
||
test('named exports', async (t) => { | ||
t.deepEqual( | ||
Object.keys(itemModule).sort(), | ||
Object.keys(atModule).sort(), | ||
['default', 'shim', 'getPolyfill', 'implementation'].sort(), | ||
'has expected named exports' | ||
); | ||
|
||
const { shim, getPolyfill, implementation } = itemModule; | ||
t.equal(await import('array.prototype.item/shim'), shim, 'shim named export matches deep export'); | ||
t.equal(await import('array.prototype.item/implementation'), implementation, 'implementation named export matches deep export'); | ||
t.equal(await import('array.prototype.item/polyfill'), getPolyfill, 'getPolyfill named export matches deep export'); | ||
const { shim, getPolyfill, implementation } = atModule; | ||
t.equal(await import('array.prototype.at/shim'), shim, 'shim named export matches deep export'); | ||
t.equal(await import('array.prototype.at/implementation'), implementation, 'implementation named export matches deep export'); | ||
t.equal(await import('array.prototype.at/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
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