pax_global_header 0000666 0000000 0000000 00000000064 14727650177 0014532 g ustar 00root root 0000000 0000000 52 comment=b781900adb00d1fdf04b562c7ba0536b85dd0537
es-shims-ArrayBuffer.prototype.slice-d8ac721/ 0000775 0000000 0000000 00000000000 14727650177 0021245 5 ustar 00root root 0000000 0000000 es-shims-ArrayBuffer.prototype.slice-d8ac721/.editorconfig 0000664 0000000 0000000 00000000424 14727650177 0023722 0 ustar 00root root 0000000 0000000 root = true
[*]
indent_style = tab;
insert_final_newline = true;
quote_type = auto;
space_after_anonymous_functions = true;
space_after_control_statements = true;
spaces_around_operators = true;
trim_trailing_whitespace = true;
spaces_in_brackets = false;
end_of_line = lf;
es-shims-ArrayBuffer.prototype.slice-d8ac721/.eslintrc 0000664 0000000 0000000 00000001001 14727650177 0023061 0 ustar 00root root 0000000 0000000 {
"root": true,
"extends": "@ljharb",
"rules": {
"id-length": 0,
"max-params": 0,
"max-statements": 0,
"multiline-comment-style": 0,
"new-cap": [2, {
"capIsNewExceptions": [
"IsSharedArrayBuffer",
"ToIntegerOrInfinity",
"GetIntrinsic",
"IsDetachedBuffer",
"SpeciesConstructor",
],
}],
},
"overrides": [
{
"files": "test/**",
"globals": {
"ArrayBuffer": false,
"Uint8Array": false,
},
"rules": {
"max-lines-per-function": 0,
},
},
],
}
es-shims-ArrayBuffer.prototype.slice-d8ac721/.github/ 0000775 0000000 0000000 00000000000 14727650177 0022605 5 ustar 00root root 0000000 0000000 es-shims-ArrayBuffer.prototype.slice-d8ac721/.github/workflows/ 0000775 0000000 0000000 00000000000 14727650177 0024642 5 ustar 00root root 0000000 0000000 es-shims-ArrayBuffer.prototype.slice-d8ac721/.github/workflows/node-aught.yml 0000664 0000000 0000000 00000000516 14727650177 0027422 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-shims-ArrayBuffer.prototype.slice-d8ac721/.github/workflows/node-pretest.yml 0000664 0000000 0000000 00000000206 14727650177 0027774 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-shims-ArrayBuffer.prototype.slice-d8ac721/.github/workflows/node-tens.yml 0000664 0000000 0000000 00000000547 14727650177 0027267 0 ustar 00root root 0000000 0000000 name: 'Tests: node.js 10 - 20'
on: [pull_request, push]
permissions:
contents: read
jobs:
tests:
uses: ljharb/actions/.github/workflows/node.yml@main
with:
range: '>= 10 < 20'
type: minors
command: npm run tests-only
node:
name: 'node 10 - 20'
needs: [tests]
runs-on: ubuntu-latest
steps:
- run: true
es-shims-ArrayBuffer.prototype.slice-d8ac721/.github/workflows/node-twenties.yml 0000664 0000000 0000000 00000000536 14727650177 0030156 0 ustar 00root root 0000000 0000000 name: 'Tests: node.js >= 20'
on: [pull_request, push]
permissions:
contents: read
jobs:
tests:
uses: ljharb/actions/.github/workflows/node.yml@main
with:
range: '>= 20'
type: minors
command: npm run tests-only
node:
name: 'node >= 20'
needs: [tests]
runs-on: ubuntu-latest
steps:
- run: true
es-shims-ArrayBuffer.prototype.slice-d8ac721/.github/workflows/rebase.yml 0000664 0000000 0000000 00000000257 14727650177 0026632 0 ustar 00root root 0000000 0000000 name: Automatic Rebase
on: [pull_request_target]
jobs:
_:
uses: ljharb/actions/.github/workflows/rebase.yml@main
secrets:
token: ${{ secrets.GITHUB_TOKEN }}
es-shims-ArrayBuffer.prototype.slice-d8ac721/.github/workflows/require-allow-edits.yml 0000664 0000000 0000000 00000000303 14727650177 0031257 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-shims-ArrayBuffer.prototype.slice-d8ac721/.gitignore 0000664 0000000 0000000 00000004202 14727650177 0023233 0 ustar 00root root 0000000 0000000 # Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-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/
# Snowpack dependency directory (https://snowpack.dev/)
web_modules/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional stylelint cache
.stylelintcache
# 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 variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local
# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache
# Next.js build output
.next
out
# 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
# vuepress v2.x temp and cache directory
.temp
.cache
# Docusaurus cache and generated files
.docusaurus
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# TernJS port file
.tern-port
# Stores VSCode versions used for testing VSCode extensions
.vscode-test
# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
# Only apps should have lockfiles.
npm-shrinkwrap.json
package-lock.json
yarn.lock
# coverage
coverage/
.nyc_output/
.npmignore
es-shims-ArrayBuffer.prototype.slice-d8ac721/.npmrc 0000664 0000000 0000000 00000000067 14727650177 0022370 0 ustar 00root root 0000000 0000000 package-lock=false
allow-same-version=true
message=v%s
es-shims-ArrayBuffer.prototype.slice-d8ac721/.nycrc 0000664 0000000 0000000 00000000213 14727650177 0022360 0 ustar 00root root 0000000 0000000 {
"all": true,
"check-coverage": false,
"reporter": ["text-summary", "text", "html", "json"],
"exclude": [
"coverage",
"test"
]
}
es-shims-ArrayBuffer.prototype.slice-d8ac721/CHANGELOG.md 0000664 0000000 0000000 00000010504 14727650177 0023056 0 ustar 00root root 0000000 0000000 # Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [v1.0.4](https://github.com/es-shims/ArrayBuffer.prototype.slice/compare/v1.0.3...v1.0.4) - 2024-12-15
### Commits
- [actions] split out node 10-20, and 20+ [`5e59635`](https://github.com/es-shims/ArrayBuffer.prototype.slice/commit/5e59635c948994b613c544b4e94fe93536d6b213)
- [Deps] update `call-bind`, `es-abstract`, `get-intrinsic` [`0afbb59`](https://github.com/es-shims/ArrayBuffer.prototype.slice/commit/0afbb5942574055a8a3afdf0f69f60313e3f1af2)
- [Dev Deps] update `@es-shims/api`, `auto-changelog`, `es-value-fixtures`, `object-inspect`, `tape` [`d76caf4`](https://github.com/es-shims/ArrayBuffer.prototype.slice/commit/d76caf4880ef358cf5384a6eb29d0f2f67e4d3a8)
- [Deps] update `call-bind`, `es-abstract`, `es-errors`, `get-intrinsic` [`2b374a2`](https://github.com/es-shims/ArrayBuffer.prototype.slice/commit/2b374a2d4078d9122ac30bdecd8a8fae740aa74c)
- [Dev Deps] update `@es-shims/api`, `@ljharb/eslint-config`, `object-inspect`, `tape` [`a24fd39`](https://github.com/es-shims/ArrayBuffer.prototype.slice/commit/a24fd39370d891ea3439f9d7a1c42183c0aa1bf7)
- [Tests] replace `aud` with `npm audit` [`c704fb0`](https://github.com/es-shims/ArrayBuffer.prototype.slice/commit/c704fb0b1651ceb56b609a5b4646a993fc868219)
- [Deps] remove unused dependency [`0274b32`](https://github.com/es-shims/ArrayBuffer.prototype.slice/commit/0274b32ab1d345fbf70745a79dd7a44f844179bb)
- [Dev Deps] add missing peer dep [`673f754`](https://github.com/es-shims/ArrayBuffer.prototype.slice/commit/673f754797dd0c40801cca2f32ff08b372448c6b)
## [v1.0.3](https://github.com/es-shims/ArrayBuffer.prototype.slice/compare/v1.0.2...v1.0.3) - 2024-02-04
### Commits
- [Deps] update `array-buffer-byte-length`, `call-bind`, `define-properties`, `es-abstract`, `get-intrinsic`, `is-array-buffer` [`d9b6859`](https://github.com/es-shims/ArrayBuffer.prototype.slice/commit/d9b68591ff509613d0dfc4036539ba4e0dc34931)
- [Dev Deps] update `aud`, `npmignore`, `object-inspect`, `tape` [`38cb58d`](https://github.com/es-shims/ArrayBuffer.prototype.slice/commit/38cb58dfa3f3c8b11bfb2144f8e7cc74dd461f5e)
- [Refactor] use `es-errors` where possible, so things that only need those do not need `get-intrinsic` [`5c07bef`](https://github.com/es-shims/ArrayBuffer.prototype.slice/commit/5c07befd134cae93ad5f9ab307ff67691ff5155b)
## [v1.0.2](https://github.com/es-shims/ArrayBuffer.prototype.slice/compare/v1.0.1...v1.0.2) - 2023-09-05
### Commits
- [Deps] update `es-abstract` [`a9ab0d2`](https://github.com/es-shims/ArrayBuffer.prototype.slice/commit/a9ab0d2551bb301b740e333ea3795fad23fcbe40)
- [Dev Deps] update `tape` [`6b24af5`](https://github.com/es-shims/ArrayBuffer.prototype.slice/commit/6b24af585dc9176c8ac3fd482cb1d5257e550a09)
- [Fix] move `es-abstract` to runtime deps [`63a8397`](https://github.com/es-shims/ArrayBuffer.prototype.slice/commit/63a8397623d7749856f6392ae93bf87152c3916c)
## [v1.0.1](https://github.com/es-shims/ArrayBuffer.prototype.slice/compare/v1.0.0...v1.0.1) - 2023-07-11
### Commits
- [Fix] node < 0.11 has an own nonconfigurable `slice` property; use it [`554823c`](https://github.com/es-shims/ArrayBuffer.prototype.slice/commit/554823c92ce16d6b7184a7d0ccfe315b663584d7)
- [Dev Deps] update `@es-shims/api`, `@ljharb/eslint-config`, `aud`, `es-abstract`, `tape` [`53b0421`](https://github.com/es-shims/ArrayBuffer.prototype.slice/commit/53b04217048c645306597e2cfc55adb69c384146)
- [Deps] update `define-properties`, `get-intrinsic` [`4966b02`](https://github.com/es-shims/ArrayBuffer.prototype.slice/commit/4966b02bc25ac006709b29ca370b9f6e159f723a)
## v1.0.0 - 2023-07-09
### Commits
- Initial implementation, tests, readme [`36b4b5e`](https://github.com/es-shims/ArrayBuffer.prototype.slice/commit/36b4b5eedfa225c3086e9453b9db0088c299640a)
- Initial commit [`51499df`](https://github.com/es-shims/ArrayBuffer.prototype.slice/commit/51499dfac7d8c67c2928cb47363a4de7ff17904a)
- npm init [`8ec604e`](https://github.com/es-shims/ArrayBuffer.prototype.slice/commit/8ec604e7d3ef8d4c27376b09645f779c2244b08f)
- Only apps should have lockfiles [`ac54435`](https://github.com/es-shims/ArrayBuffer.prototype.slice/commit/ac54435161d4415e2122e3a682499f3a6df2f6de)
es-shims-ArrayBuffer.prototype.slice-d8ac721/LICENSE 0000664 0000000 0000000 00000002061 14727650177 0022251 0 ustar 00root root 0000000 0000000 MIT License
Copyright (c) 2023 ECMAScript Shims
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-shims-ArrayBuffer.prototype.slice-d8ac721/README.md 0000664 0000000 0000000 00000005001 14727650177 0022520 0 ustar 00root root 0000000 0000000 # ArrayBuffer.prototype.slice [![Version Badge][npm-version-svg]][package-url]
[![github actions][actions-image]][actions-url]
[![coverage][codecov-image]][codecov-url]
[![License][license-image]][license-url]
[![Downloads][downloads-image]][downloads-url]
[![npm badge][npm-badge-png]][package-url]
An ES spec-compliant `ArrayBuffer.prototype.slice` shim. Invoke its "shim" method to shim ArrayBuffer.prototype.slice if it is unavailable.
This package implements the [es-shim API](https://github.com/es-shims/api) interface. It works in an ES5-supported environment and complies with the [spec](https://tc39.es/ecma262/#sec-arraybuffer.prototype.slice).
Most common usage:
```js
var assert = require('assert');
var slice = require('arraybuffer.prototype.slice');
var ab = new ArrayBuffer(1);
var arr = new Uint8Array(ab);
arr[0] = 123;
var ab2 = slice(ab);
var arr2 = new Uint8Array(ab2);
arr2[0] = 234;
assert.deepEqual(arr, new Uint8Array([123]));
assert.deepEqual(arr2, new Uint8Array([234]));
if (!ArrayBuffer.prototype.transfer) {
slice.shim();
}
var ab2 = ab.slice();
var arr2 = new Uint8Array(ab2);
arr2[0] = 234;
assert.deepEqual(arr, new Uint8Array([123]));
assert.deepEqual(arr2, new Uint8Array([234]));
```
## Tests
Simply clone the repo, `npm install`, and run `npm test`
[package-url]: https://npmjs.org/package/arraybuffer.prototype.slice
[npm-version-svg]: https://versionbadg.es/es-shims/ArrayBuffer.prototype.slice.svg
[deps-svg]: https://david-dm.org/es-shims/ArrayBuffer.prototype.slice.svg
[deps-url]: https://david-dm.org/es-shims/ArrayBuffer.prototype.slice
[dev-deps-svg]: https://david-dm.org/es-shims/ArrayBuffer.prototype.slice/dev-status.svg
[dev-deps-url]: https://david-dm.org/es-shims/ArrayBuffer.prototype.slice#info=devDependencies
[npm-badge-png]: https://nodei.co/npm/arraybuffer.prototype.slice.png?downloads=true&stars=true
[license-image]: https://img.shields.io/npm/l/arraybuffer.prototype.slice.svg
[license-url]: LICENSE
[downloads-image]: https://img.shields.io/npm/dm/arraybuffer.prototype.slice.svg
[downloads-url]: https://npm-stat.com/charts.html?package=arraybuffer.prototype.slice
[codecov-image]: https://codecov.io/gh/es-shims/ArrayBuffer.prototype.slice/branch/main/graphs/badge.svg
[codecov-url]: https://app.codecov.io/gh/es-shims/ArrayBuffer.prototype.slice/
[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/es-shims/ArrayBuffer.prototype.slice
[actions-url]: https://github.com/es-shims/ArrayBuffer.prototype.slice/actions
es-shims-ArrayBuffer.prototype.slice-d8ac721/auto.js 0000664 0000000 0000000 00000000044 14727650177 0022551 0 ustar 00root root 0000000 0000000 'use strict';
require('./shim')();
es-shims-ArrayBuffer.prototype.slice-d8ac721/implementation.js 0000664 0000000 0000000 00000005153 14727650177 0024634 0 ustar 00root root 0000000 0000000 'use strict';
var GetIntrinsic = require('get-intrinsic');
var $ArrayBuffer = GetIntrinsic('%ArrayBuffer%', true);
var $Uint8Array = GetIntrinsic('%Uint8Array%', true);
var IsDetachedBuffer = require('es-abstract/2024/IsDetachedBuffer');
var IsSharedArrayBuffer = require('es-abstract/2024/IsSharedArrayBuffer');
var max = require('es-abstract/2024/max');
var min = require('es-abstract/2024/min');
var SpeciesConstructor = require('es-abstract/2024/SpeciesConstructor');
var ToIntegerOrInfinity = require('es-abstract/2024/ToIntegerOrInfinity');
var arrayBufferByteLength = require('array-buffer-byte-length');
var isArrayBuffer = require('is-array-buffer');
var $TypeError = require('es-errors/type');
module.exports = function slice(start, end) {
var O = this; // step 1
if (!isArrayBuffer(O) || IsSharedArrayBuffer(O) || IsDetachedBuffer(O)) {
throw new $TypeError('receiver must be a non-detached, non-shared ArrayBuffer'); // steps 2-4
}
var len = arrayBufferByteLength(O); // step 5
var relativeStart = ToIntegerOrInfinity(start); // step 6
var first;
if (relativeStart === -Infinity) {
first = 0; // step 7
} else if (relativeStart < 0) {
first = max(len + relativeStart, 0); // step 8
} else {
first = min(relativeStart, len); // step 9
}
var relativeEnd = typeof end === 'undefined' ? len : ToIntegerOrInfinity(end); // step 10
var final;
if (relativeEnd === -Infinity) {
final = 0; // step 11
} else if (relativeEnd < 0) {
final = max(len + relativeEnd, 0); // step 12
} else {
final = min(relativeEnd, len); // step 13
}
var newLen = max(final - first, 0); // step 14
var Ctor = SpeciesConstructor(O, $ArrayBuffer); // step 15
var new$ = new Ctor(newLen); // step 16
if (!isArrayBuffer(new$) || IsSharedArrayBuffer(new$) || IsDetachedBuffer(new$)) {
throw new $TypeError('Species constructor must produce a non-detached, non-shared Array Buffer'); // steps 17-19
}
if (new$ === O) {
throw new $TypeError('new ArrayBuffer should not have been the same as the receiver'); // step 20
}
if (arrayBufferByteLength(new$) < newLen) {
throw new $TypeError('new ArrayBuffer\'s byteLength must be at least the requested length'); // step 21
}
if (IsDetachedBuffer(O)) {
throw new $TypeError('receiver became an detached ArrayBuffer'); // step 23
}
/*
24. Let fromBuf be O.[[ArrayBufferData]].
25. Let toBuf be new.[[ArrayBufferData]].
26. Perform CopyDataBlockBytes(toBuf, 0, fromBuf, first, newLen).
*/
var sourceArr = new $Uint8Array(O);
var destArr = new $Uint8Array(new$);
for (var i = start, ii = 0; i < end; i++, ii++) {
destArr[ii] = sourceArr[i];
}
return new$; // step 27
};
es-shims-ArrayBuffer.prototype.slice-d8ac721/index.js 0000664 0000000 0000000 00000000565 14727650177 0022720 0 ustar 00root root 0000000 0000000 'use strict';
var define = require('define-properties');
var callBind = require('call-bind');
var implementation = require('./implementation');
var getPolyfill = require('./polyfill');
var shim = require('./shim');
var bound = callBind(getPolyfill());
define(bound, {
getPolyfill: getPolyfill,
implementation: implementation,
shim: shim
});
module.exports = bound;
es-shims-ArrayBuffer.prototype.slice-d8ac721/package.json 0000664 0000000 0000000 00000005367 14727650177 0023546 0 ustar 00root root 0000000 0000000 {
"name": "arraybuffer.prototype.slice",
"version": "1.0.4",
"description": "ES spec-compliant shim for ArrayBuffer.prototype.slice",
"author": "Jordan Harband ",
"funding": {
"url": "https://github.com/sponsors/ljharb"
},
"license": "MIT",
"main": "index.js",
"exports": {
".": "./index.js",
"./auto": "./auto.js",
"./polyfill": "./polyfill.js",
"./implementation": "./implementation.js",
"./shim": "./shim.js",
"./package.json": "./package.json"
},
"scripts": {
"prepack": "npmignore --auto --commentLines=autogenerated",
"prepublish": "not-in-publish || npm run prepublishOnly",
"prepublishOnly": "safe-publish-latest",
"pretest": "npm run lint",
"test": "npm run tests-only",
"posttest": "npx npm@'>=10.2' audit --production",
"tests-only": "nyc tape 'test/**/*.js'",
"prelint": "eclint check $(git ls-files | xargs find 2> /dev/null | grep -vE 'node_modules|\\.git')",
"lint": "eslint --ext=js,mjs .",
"postlint": "evalmd README.md && es-shim-api --bound",
"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/ArrayBuffer.prototype.slice.git"
},
"homepage": "https://github.com/es-shims/ArrayBuffer.prototype.slice#readme",
"bugs": {
"url": "https://github.com/es-shims/ArrayBuffer.prototype.slice/issues"
},
"keywords": [
"javascript",
"ecmascript",
"ArrayBuffer.prototype.slice",
"polyfill",
"shim",
"ArrayBuffer",
"array",
"buffer",
"ArrayBuffer#slice",
"slice",
"typed array",
"es-shim API"
],
"dependencies": {
"array-buffer-byte-length": "^1.0.1",
"call-bind": "^1.0.8",
"define-properties": "^1.2.1",
"es-abstract": "^1.23.5",
"es-errors": "^1.3.0",
"get-intrinsic": "^1.2.6",
"is-array-buffer": "^3.0.4"
},
"devDependencies": {
"@es-shims/api": "^2.5.1",
"@ljharb/eslint-config": "^21.1.1",
"auto-changelog": "^2.5.0",
"eclint": "^2.8.1",
"encoding": "^0.1.13",
"es-value-fixtures": "^1.5.0",
"eslint": "=8.8.0",
"evalmd": "^0.0.19",
"for-each": "^0.3.3",
"functions-have-names": "^1.2.3",
"has-strict-mode": "^1.0.1",
"in-publish": "^2.0.1",
"npmignore": "^0.3.1",
"nyc": "^10.3.2",
"object-inspect": "^1.13.3",
"safe-publish-latest": "^2.0.0",
"tape": "^5.9.0"
},
"testling": {
"files": "test/index.js"
},
"engines": {
"node": ">= 0.4"
},
"auto-changelog": {
"output": "CHANGELOG.md",
"template": "keepachangelog",
"unreleased": false,
"commitLimit": false,
"backfillLimit": false,
"hideCredit": true
},
"publishConfig": {
"ignore": [
".github/workflows"
]
}
}
es-shims-ArrayBuffer.prototype.slice-d8ac721/polyfill.js 0000664 0000000 0000000 00000001176 14727650177 0023442 0 ustar 00root root 0000000 0000000 'use strict';
var callBind = require('call-bind');
var implementation = require('./implementation');
var ownSlice = typeof ArrayBuffer === 'function' && new ArrayBuffer(0).slice;
var ownSliceBound = ownSlice && callBind(ownSlice);
var ownSliceWrapper = ownSliceBound && function slice(start, end) {
/* eslint no-invalid-this: 0 */
if (arguments.length < 2) {
return ownSliceBound(this, arguments.length > 0 ? start : 0);
}
return ownSliceBound(this, start, end);
};
module.exports = function getPolyfill() {
return (typeof ArrayBuffer === 'function' && ArrayBuffer.prototype.slice)
|| ownSliceWrapper
|| implementation;
};
es-shims-ArrayBuffer.prototype.slice-d8ac721/shim.js 0000664 0000000 0000000 00000000613 14727650177 0022543 0 ustar 00root root 0000000 0000000 'use strict';
var define = require('define-properties');
var getPolyfill = require('./polyfill');
module.exports = function shimArrayBufferSlice() {
if (typeof ArrayBuffer === 'function') {
var polyfill = getPolyfill();
define(
ArrayBuffer.prototype,
{ slice: polyfill },
{ slice: function () { return ArrayBuffer.prototype.slice !== polyfill; } }
);
}
return polyfill;
};
es-shims-ArrayBuffer.prototype.slice-d8ac721/test/ 0000775 0000000 0000000 00000000000 14727650177 0022224 5 ustar 00root root 0000000 0000000 es-shims-ArrayBuffer.prototype.slice-d8ac721/test/implementation.js 0000664 0000000 0000000 00000001722 14727650177 0025611 0 ustar 00root root 0000000 0000000 'use strict';
var implementation = require('../implementation');
var callBind = require('call-bind');
var test = require('tape');
var hasStrictMode = require('has-strict-mode')();
var runTests = require('./tests');
test('as a function', function (t) {
t.test('ArrayBuffer support', { skip: typeof ArrayBuffer === 'undefined' }, function (st) {
st.test('bad array/this value', { skip: !hasStrictMode }, function (s2t) {
/* eslint no-useless-call: 0 */
s2t['throws'](function () { implementation.call(undefined); }, TypeError, 'undefined is not an object');
s2t['throws'](function () { implementation.call(null); }, TypeError, 'null is not an object');
s2t.end();
});
runTests(callBind(implementation), st);
st.end();
});
t.test('no ArrayBuffer support', { skip: typeof ArrayBuffer !== 'undefined' }, function (st) {
st['throws'](
function () { implementation.call({}); },
SyntaxError,
'ArrayBuffer is not supported'
);
});
t.end();
});
es-shims-ArrayBuffer.prototype.slice-d8ac721/test/index.js 0000664 0000000 0000000 00000001353 14727650177 0023673 0 ustar 00root root 0000000 0000000 'use strict';
var index = require('../');
var test = require('tape');
var runTests = require('./tests');
test('as a function', function (t) {
t.test('ArrayBuffer support', { skip: typeof ArrayBuffer === 'undefined' }, function (st) {
st.test('bad array/this value', function (s2t) {
s2t['throws'](function () { index(undefined); }, TypeError, 'undefined is not an object');
s2t['throws'](function () { index(null); }, TypeError, 'null is not an object');
s2t.end();
});
runTests(index, st);
st.end();
});
t.test('no ArrayBuffer support', { skip: typeof ArrayBuffer !== 'undefined' }, function (st) {
st['throws'](
function () { index({}); },
SyntaxError,
'ArrayBuffer is not supported'
);
});
t.end();
});
es-shims-ArrayBuffer.prototype.slice-d8ac721/test/shimmed.js 0000664 0000000 0000000 00000003363 14727650177 0024215 0 ustar 00root root 0000000 0000000 'use strict';
require('../auto');
var test = require('tape');
var defineProperties = require('define-properties');
var callBind = require('call-bind');
var isEnumerable = Object.prototype.propertyIsEnumerable;
var functionsHaveNames = require('functions-have-names')();
var hasStrictMode = require('has-strict-mode')();
var runTests = require('./tests');
test('shimmed', function (t) {
t.test('ArrayBuffer support', { skip: typeof ArrayBuffer === 'undefined' }, function (st) {
var method = ArrayBuffer.prototype.slice;
st.equal(method.length, 2, 'ArrayBuffer#slice has a length of 2');
st.test('Function name', { skip: !functionsHaveNames }, function (s2t) {
s2t.equal(method.name, 'slice', 'ArrayBuffer#slice name "slice"');
s2t.end();
});
st.test('enumerability', { skip: !defineProperties.supportsDescriptors }, function (et) {
et.equal(false, isEnumerable.call(ArrayBuffer.prototype, 'slice'), 'ArrayBuffer#slice is not enumerable');
et.end();
});
st.test('bad array/this value', { skip: !hasStrictMode }, function (s2t) {
/* eslint no-useless-call: 0 */
s2t['throws'](function () { return method.call(undefined); }, TypeError, 'undefined is not an object');
s2t['throws'](function () { return method.call(null); }, TypeError, 'null is not an object');
s2t.end();
});
t.test('has the correct descriptor', { skip: !Object.getOwnPropertyDescriptor }, function (s2t) {
var descriptor = Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, 'slice');
s2t.equal(descriptor.configurable, true);
s2t.equal(descriptor.enumerable, false);
s2t.equal(typeof descriptor.value, 'function');
s2t.equal(descriptor.writable, true);
s2t.end();
});
runTests(callBind(method), st);
st.end();
});
t.end();
});
es-shims-ArrayBuffer.prototype.slice-d8ac721/test/tests.js 0000664 0000000 0000000 00000004337 14727650177 0023733 0 ustar 00root root 0000000 0000000 'use strict';
var inspect = require('object-inspect');
var IsDetachedBuffer = require('es-abstract/2024/IsDetachedBuffer');
var forEach = require('for-each');
var v = require('es-value-fixtures');
var byteLength = require('array-buffer-byte-length');
module.exports = function runTests(slice, t) {
forEach(v.primitives.concat(v.objects), function (nonAB) {
t['throws'](
function () { slice(nonAB); },
TypeError,
inspect(nonAB) + ' is not an ArrayBuffer'
);
});
t.test('ArrayBuffers', { skip: typeof ArrayBuffer === 'undefined' }, function (st) {
var ab = new ArrayBuffer(0);
st.equal(IsDetachedBuffer(ab), false, 'ArrayBuffer is not detached');
try {
var nb = slice(ab);
} catch (e) {
if (e instanceof SyntaxError) {
st.skip('Detaching ArrayBuffer is not supported');
return st.end();
}
console.log(e.stack);
}
st.notEqual(nb, ab, 'new ArrayBuffer is not the same as the original');
st.equal(IsDetachedBuffer(ab), false, 'old ArrayBuffer is not detached');
st.equal(IsDetachedBuffer(nb), false, 'new ArrayBuffer is not detached');
var ab2 = new ArrayBuffer(8);
st.equal(byteLength(ab2), 8, 'original ArrayBuffer has length 8');
try {
var nbLen = slice(ab2, 4);
} catch (e) {
if (e instanceof SyntaxError) {
st.skip('Detaching ArrayBuffer is not supported');
return st.end();
}
}
st.equal(IsDetachedBuffer(ab2), false, 'old ArrayBuffer is not detached');
st.equal(IsDetachedBuffer(nbLen), false, 'new ArrayBuffer is not detached');
st.equal(byteLength(ab2), 8, 'original ArrayBuffer has length 8');
st.equal(byteLength(nbLen), 4, 'newly sliced ArrayBuffer has length 4');
var one = new ArrayBuffer(1);
var arr = new Uint8Array(one);
arr[0] = 123;
var two = slice(one);
var arr2 = new Uint8Array(two);
arr2[0] = 234;
st.deepEqual(arr, new Uint8Array([123]), 'original buffer is unchanged');
st.deepEqual(arr2, new Uint8Array([234]), 'sliced buffer is changed');
return st.end();
});
t.test('SharedArrayBuffers', { skip: typeof SharedArrayBuffer === 'undefined' }, function (st) {
var sab = new SharedArrayBuffer(0);
st['throws'](
function () { slice(sab); },
TypeError,
inspect(sab) + ' is not an ArrayBuffer'
);
st.end();
});
};