pax_global_header00006660000000000000000000000064147307330010014510gustar00rootroot0000000000000052 comment=6ec90e8b52ad0ad68644663fe6970928044feb7d inspect-js-typed-array-byte-offset-392d04c/000077500000000000000000000000001473073300100206055ustar00rootroot00000000000000inspect-js-typed-array-byte-offset-392d04c/.eslintrc000066400000000000000000000000741473073300100224320ustar00rootroot00000000000000{ "root": true, "extends": "@ljharb", "rules": { }, } inspect-js-typed-array-byte-offset-392d04c/.github/000077500000000000000000000000001473073300100221455ustar00rootroot00000000000000inspect-js-typed-array-byte-offset-392d04c/.github/FUNDING.yml000066400000000000000000000011151473073300100237600ustar00rootroot00000000000000# 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/typed-array-length 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'] inspect-js-typed-array-byte-offset-392d04c/.github/workflows/000077500000000000000000000000001473073300100242025ustar00rootroot00000000000000inspect-js-typed-array-byte-offset-392d04c/.github/workflows/node-aught.yml000066400000000000000000000005651473073300100267660ustar00rootroot00000000000000name: 'Tests: node.js < 10' on: [pull_request, push] permissions: contents: read jobs: tests: uses: ljharb/actions/.github/workflows/node.yml@main with: range: '< 10' type: minors command: npm run tests-only skip-ls-check: true node: name: 'node < 10' needs: [tests] runs-on: ubuntu-latest steps: - run: true inspect-js-typed-array-byte-offset-392d04c/.github/workflows/node-noproto.yml000066400000000000000000000013751473073300100273560ustar00rootroot00000000000000name: 'Tests: node --disable-proto=throw' on: [pull_request, push] jobs: throw: uses: ljharb/actions/.github/workflows/node.yml@main with: range: '>= 12.17' type: minors skip-ls-check: true after_install: "npm link && npm link dunder-proto" command: "NODE_OPTIONS='--disable-proto=throw' npx tape 'tests/**/*.js'" delete: uses: ljharb/actions/.github/workflows/node.yml@main with: range: '>= 12.17' type: minors skip-ls-check: true after_install: "npm link && npm link dunder-proto" command: "NODE_OPTIONS='--disable-proto=delete' npx tape 'tests/**/*.js'" node: name: 'node --disable-proto' needs: [throw, delete] runs-on: ubuntu-latest steps: - run: true inspect-js-typed-array-byte-offset-392d04c/.github/workflows/node-pretest.yml000066400000000000000000000002451473073300100273370ustar00rootroot00000000000000name: 'Tests: pretest/posttest' on: [pull_request, push] permissions: contents: read jobs: tests: uses: ljharb/actions/.github/workflows/pretest.yml@main inspect-js-typed-array-byte-offset-392d04c/.github/workflows/node-tens.yml000066400000000000000000000005471473073300100266270ustar00rootroot00000000000000name: '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 inspect-js-typed-array-byte-offset-392d04c/.github/workflows/node-twenties.yml000066400000000000000000000005421473073300100275130ustar00rootroot00000000000000name: '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 finisher: name: 'node >= 20' needs: [tests] runs-on: ubuntu-latest steps: - run: true inspect-js-typed-array-byte-offset-392d04c/.github/workflows/rebase.yml000066400000000000000000000002571473073300100261720ustar00rootroot00000000000000name: Automatic Rebase on: [pull_request_target] jobs: _: uses: ljharb/actions/.github/workflows/rebase.yml@main secrets: token: ${{ secrets.GITHUB_TOKEN }} inspect-js-typed-array-byte-offset-392d04c/.github/workflows/require-allow-edits.yml000066400000000000000000000005151473073300100306240ustar00rootroot00000000000000name: Require “Allow Edits” on: [pull_request_target] permissions: contents: read jobs: _: permissions: pull-requests: read # for ljharb/require-allow-edits to check 'allow edits' on PR name: "Require “Allow Edits”" runs-on: ubuntu-latest steps: - uses: ljharb/require-allow-edits@main inspect-js-typed-array-byte-offset-392d04c/.gitignore000066400000000000000000000032511473073300100225760ustar00rootroot00000000000000# 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 .npmignore inspect-js-typed-array-byte-offset-392d04c/.npmrc000066400000000000000000000000671473073300100217300ustar00rootroot00000000000000package-lock=false allow-same-version=true message=v%s inspect-js-typed-array-byte-offset-392d04c/.nycrc000066400000000000000000000003301473073300100217200ustar00rootroot00000000000000{ "all": true, "check-coverage": false, "reporter": ["text-summary", "text", "html", "json"], "lines": 86, "statements": 85.93, "functions": 82.43, "branches": 76.06, "exclude": [ "coverage", "test" ] } inspect-js-typed-array-byte-offset-392d04c/CHANGELOG.md000066400000000000000000000117311473073300100224210ustar00rootroot00000000000000# 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/inspect-js/typed-array-byte-offset/compare/v1.0.3...v1.0.4) - 2024-12-18 ### Commits - [Tests] split out and enhance "no-proto" tests [`64d1a73`](https://github.com/inspect-js/typed-array-byte-offset/commit/64d1a73a0a7f20484ee817c4a6758121887e30d3) - [types] improve types [`21f484f`](https://github.com/inspect-js/typed-array-byte-offset/commit/21f484f55f9c6e3406b5eacbc937aa2e195da731) - [Tests] add `--disable-proto=delete` tests [`8f77f2a`](https://github.com/inspect-js/typed-array-byte-offset/commit/8f77f2af48e1522aae10e0429810907df9f9f6fc) - [actions] re-add a finisher; add perms [`59c1b7b`](https://github.com/inspect-js/typed-array-byte-offset/commit/59c1b7bfab826bceb43441c60affb1c1ad4e6cc7) - [Deps] update `call-bind`, `gopd`, `has-proto`, `reflect.getprototypeof` [`c0c30d5`](https://github.com/inspect-js/typed-array-byte-offset/commit/c0c30d57642858c8327b3d90b6104ccbb459d71a) - [Dev Deps] update `@arethetypeswrong/cli`, `@ljharb/tsconfig`, `@types/tape` [`2638bd5`](https://github.com/inspect-js/typed-array-byte-offset/commit/2638bd5d7000e6d902414aeac88c00a148f5b152) - [Deps] update `is-typed-array`, `reflect.getprototypeof` [`11540a5`](https://github.com/inspect-js/typed-array-byte-offset/commit/11540a577044442ce42d684d00d4686d7613bed4) - [Deps] update `is-typed-array` [`ad9cb70`](https://github.com/inspect-js/typed-array-byte-offset/commit/ad9cb70bcc09eaf535c24ce24a00716058833d64) - [Dev Deps] update `@types/tape` [`2838854`](https://github.com/inspect-js/typed-array-byte-offset/commit/2838854db6053003b0818a337f1e2f95ab383bce) ## [v1.0.3](https://github.com/inspect-js/typed-array-byte-offset/compare/v1.0.2...v1.0.3) - 2024-11-21 ### Fixed - [Fix] avoid relying on `__proto__` accessor [`#4`](https://github.com/inspect-js/typed-array-byte-offset/issues/4) ### Commits - [types] use shared config [`10b0823`](https://github.com/inspect-js/typed-array-byte-offset/commit/10b0823ecc13b95920cfa8f27fe61af5678fb67b) - [actions] split out node 10-20, and 20+ [`11554a9`](https://github.com/inspect-js/typed-array-byte-offset/commit/11554a96ca11b85c7ad87118e1d811bfde2b9f32) - [Dev Deps] update `@arethetypeswrong/cli`, `@ljharb/eslint-config`, `@types/object-inspect`, `auto-changelog`, `object-inspect`, `tape` [`c39dd06`](https://github.com/inspect-js/typed-array-byte-offset/commit/c39dd06d2868a724463722ff2f416b5c41171140) - [Tests] run tsc and `@arethetypeswrong/cli` in CI [`0b984aa`](https://github.com/inspect-js/typed-array-byte-offset/commit/0b984aa64c86f4bcb476b716cdd16d67c39b68ca) - [Tests] replace `aud` with `npm audit` [`512b59d`](https://github.com/inspect-js/typed-array-byte-offset/commit/512b59df0e567592282795bfec331193d828f2fc) ## [v1.0.2](https://github.com/inspect-js/typed-array-byte-offset/compare/v1.0.1...v1.0.2) - 2024-02-20 ### Commits - add types [`9eecdd2`](https://github.com/inspect-js/typed-array-byte-offset/commit/9eecdd245b089610d6ad49ef63c9df2b58c3e8a6) - [actions] skip ls check on node < 10; remove redundant finisher [`4fb4c91`](https://github.com/inspect-js/typed-array-byte-offset/commit/4fb4c912f5eb8034f4e3705b30f3f7dcc7080039) - [Deps] update `available-typed-arrays`, `has-proto` [`805cee2`](https://github.com/inspect-js/typed-array-byte-offset/commit/805cee207d73e12d526ff23d2c161f38283a1ed9) ## [v1.0.1](https://github.com/inspect-js/typed-array-byte-offset/compare/v1.0.0...v1.0.1) - 2024-02-17 ### Commits - [Dev Deps] update `aud`, `npmignore`, `object-inspect`, `tape` [`ffe7494`](https://github.com/inspect-js/typed-array-byte-offset/commit/ffe7494826fbb6d6bd11c40e03619b12a4ec2266) - [Deps] update `available-typed-arrays`, `call-bind`, `is-typed-array` [`3006bd7`](https://github.com/inspect-js/typed-array-byte-offset/commit/3006bd7e343d191093802473277801d12bfdc7b2) - [Refactor] use `gopd` [`45827ea`](https://github.com/inspect-js/typed-array-byte-offset/commit/45827ea7d9709cb1b3a9f2313eed76b71052b9c5) - [Dev Deps] update `tape` [`e33d080`](https://github.com/inspect-js/typed-array-byte-offset/commit/e33d080ef6488b5f15afe1078a9e5711d9656538) - [meta] add `sideEffects` flag [`f1dc0db`](https://github.com/inspect-js/typed-array-byte-offset/commit/f1dc0db73c1c4b93c15076602a3e30353878312c) ## v1.0.0 - 2023-06-06 ### Commits - Initial implementation, tests, readme [`f227633`](https://github.com/inspect-js/typed-array-byte-offset/commit/f2276337a907bdfe9725af1b36c3109e76f2430d) - Initial commit [`806bbaf`](https://github.com/inspect-js/typed-array-byte-offset/commit/806bbaf81e0267aebce5ae68cbf138718513642a) - npm init [`1151981`](https://github.com/inspect-js/typed-array-byte-offset/commit/1151981427eb1fddab8599d36e6afea50a78293f) - Only apps should have lockfiles [`5fa9933`](https://github.com/inspect-js/typed-array-byte-offset/commit/5fa9933275f10bdb9e8a175cc70a8228d4811642) inspect-js-typed-array-byte-offset-392d04c/LICENSE000066400000000000000000000020531473073300100216120ustar00rootroot00000000000000MIT License Copyright (c) 2020 Inspect JS 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. inspect-js-typed-array-byte-offset-392d04c/README.md000066400000000000000000000071271473073300100220730ustar00rootroot00000000000000# typed-array-byte-offset [![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] Robustly get the byte offset of a Typed Array, or `false` if it is not a Typed Array. Works cross-realm, in every engine, even if the `byteOffset` property is overridden. ## Example ```js var typedArrayByteOffset = require('typed-array-byte-offset'); var assert = require('assert'); assert.equal(false, typedArrayByteOffset(undefined)); assert.equal(false, typedArrayByteOffset(null)); assert.equal(false, typedArrayByteOffset(false)); assert.equal(false, typedArrayByteOffset(true)); assert.equal(false, typedArrayByteOffset([])); assert.equal(false, typedArrayByteOffset({})); assert.equal(false, typedArrayByteOffset(/a/g)); assert.equal(false, typedArrayByteOffset(new RegExp('a', 'g'))); assert.equal(false, typedArrayByteOffset(new Date())); assert.equal(false, typedArrayByteOffset(42)); assert.equal(false, typedArrayByteOffset(NaN)); assert.equal(false, typedArrayByteOffset(Infinity)); assert.equal(false, typedArrayByteOffset(new Number(42))); assert.equal(false, typedArrayByteOffset('foo')); assert.equal(false, typedArrayByteOffset(Object('foo'))); assert.equal(false, typedArrayByteOffset(function () {})); assert.equal(false, typedArrayByteOffset(function* () {})); assert.equal(false, typedArrayByteOffset(x => x * x)); assert.equal(false, typedArrayByteOffset([])); const buffer = new ArrayBuffer(32); assert.equal(8, typedArrayByteOffset(new Int8Array(buffer, 8))); assert.equal(8, typedArrayByteOffset(new Uint8Array(buffer, 8))); assert.equal(8, typedArrayByteOffset(new Uint8ClampedArray(buffer, 8))); assert.equal(4, typedArrayByteOffset(new Int16Array(buffer, 4))); assert.equal(4, typedArrayByteOffset(new Uint16Array(buffer, 4))); assert.equal(8, typedArrayByteOffset(new Int32Array(buffer, 8))); assert.equal(8, typedArrayByteOffset(new Uint32Array(buffer, 8))); assert.equal(16, typedArrayByteOffset(new Float32Array(buffer, 16))); assert.equal(16, typedArrayByteOffset(new Float64Array(buffer, 16))); assert.equal(16, typedArrayByteOffset(new BigInt64Array(buffer, 16))); assert.equal(16, typedArrayByteOffset(new BigUint64Array(buffer, 16))); ``` ## Tests Simply clone the repo, `npm install`, and run `npm test` [package-url]: https://npmjs.org/package/typed-array-byte-offset [npm-version-svg]: https://versionbadg.es/inspect-js/typed-array-byte-offset.svg [deps-svg]: https://david-dm.org/inspect-js/typed-array-byte-offset.svg [deps-url]: https://david-dm.org/inspect-js/typed-array-byte-offset [dev-deps-svg]: https://david-dm.org/inspect-js/typed-array-byte-offset/dev-status.svg [dev-deps-url]: https://david-dm.org/inspect-js/typed-array-byte-offset#info=devDependencies [npm-badge-png]: https://nodei.co/npm/typed-array-byte-offset.png?downloads=true&stars=true [license-image]: https://img.shields.io/npm/l/typed-array-byte-offset.svg [license-url]: LICENSE [downloads-image]: https://img.shields.io/npm/dm/typed-array-byte-offset.svg [downloads-url]: https://npm-stat.com/charts.html?package=typed-array-byte-offset [codecov-image]: https://codecov.io/gh/inspect-js/typed-array-byte-offset/branch/main/graphs/badge.svg [codecov-url]: https://app.codecov.io/gh/inspect-js/typed-array-byte-offset/ [actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/inspect-js/typed-array-byte-offset [actions-url]: https://github.com/inspect-js/typed-array-byte-offset/actions inspect-js-typed-array-byte-offset-392d04c/index.d.ts000066400000000000000000000007451473073300100225140ustar00rootroot00000000000000import TypedArrayNames from 'possible-typed-array-names'; declare namespace typedArrayByteOffset { export type TypedArrayName = typeof TypedArrayNames[number]; export type TypedArrayConstructor = typeof globalThis[TypedArrayName]; export type TypedArray = TypedArrayConstructor['prototype']; } declare function typedArrayByteOffset(value: typedArrayByteOffset.TypedArray): number; declare function typedArrayByteOffset(value: unknown): false; export = typedArrayByteOffset; inspect-js-typed-array-byte-offset-392d04c/index.js000066400000000000000000000046661473073300100222660ustar00rootroot00000000000000'use strict'; var forEach = require('for-each'); var callBind = require('call-bind'); var gPO = require('reflect.getprototypeof/polyfill')(); var typedArrays = require('available-typed-arrays')(); /** @typedef {(x: import('.').TypedArray) => number} ByteOffsetGetter */ /** @type {Record} */ var getters = { // @ts-expect-error TS can't handle __proto__ or `satisfies` in jsdoc __proto__: null }; var gOPD = require('gopd'); var oDP = Object.defineProperty; if (gOPD) { /** @type {ByteOffsetGetter} */ var getByteOffset = function (x) { return x.byteOffset; }; forEach(typedArrays, function (typedArray) { // In Safari 7, Typed Array constructors are typeof object if (typeof global[typedArray] === 'function' || typeof global[typedArray] === 'object') { var Proto = global[typedArray].prototype; // @ts-expect-error TS can't guarantee the callback is invoked sync var descriptor = gOPD(Proto, 'byteOffset'); if (!descriptor) { var superProto = gPO(Proto); // @ts-expect-error TS can't guarantee the callback is invoked sync descriptor = gOPD(superProto, 'byteOffset'); } // Opera 12.16 has a magic byteOffset data property on instances AND on Proto if (descriptor && descriptor.get) { getters[typedArray] = callBind(descriptor.get); } else if (oDP) { // this is likely an engine where instances have a magic byteOffset data property var arr = new global[typedArray](2); // @ts-expect-error TS can't guarantee the callback is invoked sync descriptor = gOPD(arr, 'byteOffset'); if (descriptor && descriptor.configurable) { oDP(arr, 'length', { value: 3 }); } if (arr.length === 2) { getters[typedArray] = getByteOffset; } } } }); } /** @type {ByteOffsetGetter} */ var tryTypedArrays = function tryAllTypedArrays(value) { /** @type {number} */ var foundOffset; forEach(getters, /** @type {(getter: ByteOffsetGetter) => void} */ function (getter) { if (typeof foundOffset !== 'number') { try { var offset = getter(value); if (typeof offset === 'number') { foundOffset = offset; } } catch (e) {} } }); // @ts-expect-error TS can't guarantee the callback is invoked sync return foundOffset; }; var isTypedArray = require('is-typed-array'); /** @type {import('.')} */ module.exports = function typedArrayByteOffset(value) { if (!isTypedArray(value)) { return false; } return tryTypedArrays(value); }; inspect-js-typed-array-byte-offset-392d04c/package.json000066400000000000000000000057471473073300100231100ustar00rootroot00000000000000{ "name": "typed-array-byte-offset", "version": "1.0.4", "description": "Robustly get the byte offset of a Typed Array", "main": "index.js", "exports": { ".": "./index.js", "./package.json": "./package.json" }, "types": "./index.d.ts", "sideEffects": false, "scripts": { "prepack": "npmignore --auto --commentLines=autogenerated", "prepublishOnly": "safe-publish-latest", "prepublish": "not-in-publish || npm run prepublishOnly", "pretest": "npm run lint", "prelint": "evalmd README.md", "lint": "eslint --ext=js,mjs .", "postlint": "tsc -p . && attw -P", "tests-only": "nyc tape 'test/**/*.js'", "test": "npm run tests-only", "posttest": "npx npm@'>=10.2' audit --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/inspect-js/typed-array-byte-offset.git" }, "keywords": [ "typed", "array", "byteOffset", "byte", "offset", "robust", "es", "Int8Array", "Uint8Array", "Uint8ClampedArray", "Int16Array", "Uint16Array", "Int32Array", "Uint32Array", "Float32Array", "Float64Array", "BigInt64Array", "BigUint64Array" ], "author": "Jordan Harband ", "funding": { "url": "https://github.com/sponsors/ljharb" }, "license": "MIT", "bugs": { "url": "https://github.com/inspect-js/typed-array-byte-offset/issues" }, "homepage": "https://github.com/inspect-js/typed-array-byte-offset#readme", "dependencies": { "available-typed-arrays": "^1.0.7", "call-bind": "^1.0.8", "for-each": "^0.3.3", "gopd": "^1.2.0", "has-proto": "^1.2.0", "is-typed-array": "^1.1.15", "reflect.getprototypeof": "^1.0.9" }, "devDependencies": { "@arethetypeswrong/cli": "^0.17.1", "@ljharb/eslint-config": "^21.1.1", "@ljharb/tsconfig": "^0.2.2", "@types/call-bind": "^1.0.5", "@types/es-abstract": "^1.17.9", "@types/for-each": "^0.3.3", "@types/gopd": "^1.0.3", "@types/is-callable": "^1.1.2", "@types/make-arrow-function": "^1.2.2", "@types/make-generator-function": "^2.0.3", "@types/object-inspect": "^1.13.0", "@types/tape": "^5.8.0", "auto-changelog": "^2.5.0", "eslint": "=8.8.0", "evalmd": "^0.0.19", "in-publish": "^2.0.1", "is-callable": "^1.2.7", "make-arrow-function": "^1.2.0", "make-generator-function": "^2.0.0", "npmignore": "^0.3.1", "nyc": "^10.3.2", "object-inspect": "^1.13.3", "possible-typed-array-names": "^1.0.0", "safe-publish-latest": "^2.0.0", "tape": "^5.9.0", "typescript": "next" }, "engines": { "node": ">= 0.4" }, "auto-changelog": { "output": "CHANGELOG.md", "template": "keepachangelog", "unreleased": false, "commitLimit": false, "backfillLimit": false, "hideCredit": true }, "testling": { "files": "test/index.js" }, "publishConfig": { "ignore": [ ".github/workflows", "types" ] } } inspect-js-typed-array-byte-offset-392d04c/test/000077500000000000000000000000001473073300100215645ustar00rootroot00000000000000inspect-js-typed-array-byte-offset-392d04c/test/index.js000066400000000000000000000055371473073300100232430ustar00rootroot00000000000000'use strict'; var test = require('tape'); var typedArrayByteOffset = require('../'); var isCallable = require('is-callable'); var generators = require('make-generator-function')(); var arrowFn = require('make-arrow-function')(); var forEach = require('for-each'); var inspect = require('object-inspect'); var typedArrayNames = require('possible-typed-array-names'); test('not arrays', function (t) { t.test('non-number/string primitives', function (st) { // @ts-expect-error st.equal(false, typedArrayByteOffset(), 'undefined is not typed array'); st.equal(false, typedArrayByteOffset(null), 'null is not typed array'); st.equal(false, typedArrayByteOffset(false), 'false is not typed array'); st.equal(false, typedArrayByteOffset(true), 'true is not typed array'); st.end(); }); t.equal(false, typedArrayByteOffset({}), 'object is not typed array'); t.equal(false, typedArrayByteOffset(/a/g), 'regex literal is not typed array'); t.equal(false, typedArrayByteOffset(new RegExp('a', 'g')), 'regex object is not typed array'); t.equal(false, typedArrayByteOffset(new Date()), 'new Date() is not typed array'); t.test('numbers', function (st) { st.equal(false, typedArrayByteOffset(42), 'number is not typed array'); st.equal(false, typedArrayByteOffset(Object(42)), 'number object is not typed array'); st.equal(false, typedArrayByteOffset(NaN), 'NaN is not typed array'); st.equal(false, typedArrayByteOffset(Infinity), 'Infinity is not typed array'); st.end(); }); t.test('strings', function (st) { st.equal(false, typedArrayByteOffset('foo'), 'string primitive is not typed array'); st.equal(false, typedArrayByteOffset(Object('foo')), 'string object is not typed array'); st.end(); }); t.end(); }); test('Functions', function (t) { t.equal(false, typedArrayByteOffset(function () {}), 'function is not typed array'); t.end(); }); test('Generators', { skip: generators.length === 0 }, function (t) { forEach(generators, function (genFn) { t.equal(false, typedArrayByteOffset(genFn), 'generator function ' + inspect(genFn) + ' is not typed array'); }); t.end(); }); test('Arrow functions', { skip: !arrowFn }, function (t) { t.equal(false, typedArrayByteOffset(arrowFn), 'arrow function is not typed array'); t.end(); }); test('Typed Arrays', function (t) { var length = 32; var byteOffset = 16; forEach(typedArrayNames, function (typedArray) { var buffer = new ArrayBuffer(length); var TypedArray = global[typedArray]; if (isCallable(TypedArray)) { // @ts-expect-error hush, TS, TAs can take an optional byte offset arg var arr = new TypedArray(buffer, byteOffset); t.equal(typedArrayByteOffset(arr), byteOffset, 'new ' + typedArray + '(new ArrayBuffer(' + length + '), ' + byteOffset + ') is typed array of byte offset ' + byteOffset); } else { t.comment('# SKIP ' + typedArray + ' is not supported'); } }); t.end(); }); inspect-js-typed-array-byte-offset-392d04c/tsconfig.json000066400000000000000000000002211473073300100233070ustar00rootroot00000000000000{ "extends": "@ljharb/tsconfig", "compilerOptions": { "target": "ES2021", "maxNodeModuleJsDepth": 0, }, "exclude": [ "coverage", ], } inspect-js-typed-array-byte-offset-392d04c/types/000077500000000000000000000000001473073300100217515ustar00rootroot00000000000000inspect-js-typed-array-byte-offset-392d04c/types/reflect.getprototypeof/000077500000000000000000000000001473073300100264665ustar00rootroot00000000000000inspect-js-typed-array-byte-offset-392d04c/types/reflect.getprototypeof/polyfill.d.ts000066400000000000000000000002131473073300100311060ustar00rootroot00000000000000declare module 'reflect.getprototypeof/polyfill' { function getPolyfill(): typeof Reflect.getPrototypeOf; export = getPolyfill; }