pax_global_header00006660000000000000000000000064147311744700014522gustar00rootroot0000000000000052 comment=76b05f64f4ecdca09df1a5f9f40501ca903f9bd8 inspect-js-data-view-byte-length-0315207/000077500000000000000000000000001473117447000200635ustar00rootroot00000000000000inspect-js-data-view-byte-length-0315207/.eslintrc000066400000000000000000000002701473117447000217060ustar00rootroot00000000000000{ "root": true, "extends": "@ljharb", "globals": { "DataView": false, }, "rules": { "new-cap": ["error", { "capIsNewExceptions": [ "GetIntrinsic", ], }], }, } inspect-js-data-view-byte-length-0315207/.github/000077500000000000000000000000001473117447000214235ustar00rootroot00000000000000inspect-js-data-view-byte-length-0315207/.github/FUNDING.yml000066400000000000000000000010671473117447000232440ustar00rootroot00000000000000# 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/data-view-byte-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 a single custom sponsorship URL inspect-js-data-view-byte-length-0315207/.github/workflows/000077500000000000000000000000001473117447000234605ustar00rootroot00000000000000inspect-js-data-view-byte-length-0315207/.github/workflows/node-aught.yml000066400000000000000000000006501473117447000262370ustar00rootroot00000000000000name: 'Tests: node.js < 10' on: [pull_request, push] permissions: contents: read jobs: tests: uses: ljharb/actions/.github/workflows/node.yml@main with: range: '< 10' notable: '0.11.4 || 0.11.3 || 0.10.0 || 0.9' 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-data-view-byte-length-0315207/.github/workflows/node-pretest.yml000066400000000000000000000002451473117447000266150ustar00rootroot00000000000000name: 'Tests: pretest/posttest' on: [pull_request, push] permissions: contents: read jobs: tests: uses: ljharb/actions/.github/workflows/pretest.yml@main inspect-js-data-view-byte-length-0315207/.github/workflows/node-tens.yml000066400000000000000000000005471473117447000261050ustar00rootroot00000000000000name: '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-data-view-byte-length-0315207/.github/workflows/node-twenties.yml000066400000000000000000000005361473117447000267740ustar00rootroot00000000000000name: '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 inspect-js-data-view-byte-length-0315207/.github/workflows/rebase.yml000066400000000000000000000002571473117447000254500ustar00rootroot00000000000000name: Automatic Rebase on: [pull_request_target] jobs: _: uses: ljharb/actions/.github/workflows/rebase.yml@main secrets: token: ${{ secrets.GITHUB_TOKEN }} inspect-js-data-view-byte-length-0315207/.github/workflows/require-allow-edits.yml000066400000000000000000000005151473117447000301020ustar00rootroot00000000000000name: 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-data-view-byte-length-0315207/.gitignore000066400000000000000000000041361473117447000220570ustar00rootroot00000000000000# 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 .npmignore inspect-js-data-view-byte-length-0315207/.npmrc000066400000000000000000000000671473117447000212060ustar00rootroot00000000000000package-lock=false allow-same-version=true message=v%s inspect-js-data-view-byte-length-0315207/.nycrc000066400000000000000000000003301473117447000211760ustar00rootroot00000000000000{ "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-data-view-byte-length-0315207/CHANGELOG.md000066400000000000000000000055071473117447000217030ustar00rootroot00000000000000# 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.2](https://github.com/inspect-js/data-view-byte-length/compare/v1.0.1...v1.0.2) - 2024-12-19 ### Commits - [readme] update URLs [`79df46c`](https://github.com/inspect-js/data-view-byte-length/commit/79df46cdf4c551d83059335ace8b8550369710b0) - [actions] split out node 10-20, and 20+ [`2890929`](https://github.com/inspect-js/data-view-byte-length/commit/289092965343dfa6fcc931c32ecd1c1286f5f2dc) - [Dev Deps] update `@arethetypeswrong/cli`, `@ljharb/eslint-config`, `@ljharb/tsconfig`, `@types/object-inspect`, `@types/tape`, `auto-changelog`, `es-value-fixtures`, `object-inspect`, `tape` [`97fac7f`](https://github.com/inspect-js/data-view-byte-length/commit/97fac7fb6c2f3655c9755d9dcf3569cdf6899635) - [Refactor] use `call-bound` directly [`56f17fa`](https://github.com/inspect-js/data-view-byte-length/commit/56f17fa583a963c2a6d2da5f2db00f7725714533) - [Deps] update `call-bind`, `is-data-view` [`254a502`](https://github.com/inspect-js/data-view-byte-length/commit/254a5026c0201eb35d20722af2993e0412b2f2ea) - [Tests] replace `aud` with `npm audit` [`7158679`](https://github.com/inspect-js/data-view-byte-length/commit/7158679d1ef0e15ccf64b6d0169413ed8351f243) - [Dev Deps] update `@ljharb/tsconfig` [`ed63290`](https://github.com/inspect-js/data-view-byte-length/commit/ed63290bc162fe5a9086412fc6099dd49c70d474) ## [v1.0.1](https://github.com/inspect-js/data-view-byte-length/compare/v1.0.0...v1.0.1) - 2024-03-08 ### Commits - [types] use shared tsconfig [`0d5873c`](https://github.com/inspect-js/data-view-byte-length/commit/0d5873c9fddd413bacbb3a2c32e7e1a7f1f5bd2c) - [Dev Deps] update `@arethetypeswrong/cli`, `tape` [`13c1eaf`](https://github.com/inspect-js/data-view-byte-length/commit/13c1eafea562993c7d15a450e86d2ee7a1aa8299) - [patch] fix function name [`a061e7b`](https://github.com/inspect-js/data-view-byte-length/commit/a061e7b457f53bdc39716dacdddbe558ee790745) - [Deps] update `call-bind` [`6603851`](https://github.com/inspect-js/data-view-byte-length/commit/6603851eef423c5762841221f97abfdc905c8bde) ## v1.0.0 - 2024-03-04 ### Commits - Initial implementation, tests, readme, types [`79ad058`](https://github.com/inspect-js/data-view-byte-length/commit/79ad058a73a4f8425e8ad034211dfc39e643dc86) - Initial commit [`1a11313`](https://github.com/inspect-js/data-view-byte-length/commit/1a113138783a815f66fd000a9f9c89fdbe8c98fb) - npm init [`aac0108`](https://github.com/inspect-js/data-view-byte-length/commit/aac010820b20b8604d33e5a74b51591f19f553e2) - Only apps should have lockfiles [`cdf1a15`](https://github.com/inspect-js/data-view-byte-length/commit/cdf1a15d4c201137982e1e703d56a42582c6d246) inspect-js-data-view-byte-length-0315207/LICENSE000066400000000000000000000020571473117447000210740ustar00rootroot00000000000000MIT License Copyright (c) 2024 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. inspect-js-data-view-byte-length-0315207/README.md000066400000000000000000000040301473117447000213370ustar00rootroot00000000000000# data-view-byte-length [![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] Get the `byteLength` out of a DataView, robustly. This will work in node <= 0.10 and < 0.11.4, where there's no prototype accessor, only a nonconfigurable own property. It will also work in modern engines where `DataView.prototype.byteLength` has been deleted after this module has loaded. ## Example ```js const dataViewByteLength = require('data-view-byte-length'); const assert = require('assert'); const ab = new ArrayBuffer(42); const dv = new DataView(ab); assert.equal(dataViewByteLength(dv), 42); ``` ## Tests Simply clone the repo, `npm install`, and run `npm test` [package-url]: https://npmjs.org/package/data-view-byte-length [npm-version-svg]: https://versionbadg.es/inspect-js/data-view-byte-length.svg [deps-svg]: https://david-dm.org/inspect-js/data-view-byte-length.svg [deps-url]: https://david-dm.org/inspect-js/data-view-byte-length [dev-deps-svg]: https://david-dm.org/inspect-js/data-view-byte-length/dev-status.svg [dev-deps-url]: https://david-dm.org/inspect-js/data-view-byte-length#info=devDependencies [npm-badge-png]: https://nodei.co/npm/data-view-byte-length.png?downloads=true&stars=true [license-image]: https://img.shields.io/npm/l/data-view-byte-length.svg [license-url]: LICENSE [downloads-image]: https://img.shields.io/npm/dm/data-view-byte-length.svg [downloads-url]: https://npm-stat.com/charts.html?package=data-view-byte-length [codecov-image]: https://codecov.io/gh/inspect-js/data-view-byte-length/branch/main/graphs/badge.svg [codecov-url]: https://app.codecov.io/gh/inspect-js/data-view-byte-length/ [actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/inspect-js/data-view-byte-length [actions-url]: https://github.com/inspect-js/data-view-byte-length/actions inspect-js-data-view-byte-length-0315207/index.d.ts000066400000000000000000000002271473117447000217650ustar00rootroot00000000000000declare function dataViewByteLength(value: DataView): number; declare function dataViewByteLength(value: unknown): never; export = dataViewByteLength;inspect-js-data-view-byte-length-0315207/index.js000066400000000000000000000007611473117447000215340ustar00rootroot00000000000000'use strict'; var $TypeError = require('es-errors/type'); var callBound = require('call-bound'); var $dataViewByteLength = callBound('DataView.prototype.byteLength', true); var isDataView = require('is-data-view'); // node <= 0.10, < 0.11.4 has a nonconfigurable own property instead of a prototype getter /** @type {import('.')} */ module.exports = $dataViewByteLength || function byteLength(x) { if (!isDataView(x)) { throw new $TypeError('not a DataView'); } return x.byteLength; }; inspect-js-data-view-byte-length-0315207/package.json000066400000000000000000000046151473117447000223570ustar00rootroot00000000000000{ "name": "data-view-byte-length", "version": "1.0.2", "description": "Get the byteLength out of a DataView, robustly.", "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", "prelint": "evalmd README.md", "lint": "eslint --ext=js,mjs .", "postlint": "tsc -p . && attw -P", "pretest": "npm run lint", "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)\")\"" }, "funding": { "url": "https://github.com/sponsors/inspect-js" }, "repository": { "type": "git", "url": "git+https://github.com/inspect-js/data-view-byte-length.git" }, "keywords": [ "javascript", "ecmascript", "dataview", "data", "view", "byte", "length", "byteLength", "robust" ], "author": "Jordan Harband ", "license": "MIT", "bugs": { "url": "https://github.com/inspect-js/data-view-byte-length/issues" }, "homepage": "https://github.com/inspect-js/data-view-byte-length#readme", "dependencies": { "call-bound": "^1.0.3", "es-errors": "^1.3.0", "is-data-view": "^1.0.2" }, "devDependencies": { "@arethetypeswrong/cli": "^0.17.1", "@ljharb/eslint-config": "^21.1.1", "@ljharb/tsconfig": "^0.2.2", "@types/es-value-fixtures": "^1.4.4", "@types/for-each": "^0.3.3", "@types/object-inspect": "^1.13.0", "@types/tape": "^5.8.0", "auto-changelog": "^2.5.0", "es-value-fixtures": "^1.5.0", "eslint": "=8.8.0", "evalmd": "^0.0.19", "for-each": "^0.3.3", "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", "typescript": "next" }, "engines": { "node": ">= 0.4" }, "auto-changelog": { "output": "CHANGELOG.md", "template": "keepachangelog", "unreleased": false, "commitLimit": false, "backfillLimit": false, "hideCredit": true }, "publishConfig": { "ignore": [ ".github/workflows" ] } } inspect-js-data-view-byte-length-0315207/test/000077500000000000000000000000001473117447000210425ustar00rootroot00000000000000inspect-js-data-view-byte-length-0315207/test/index.js000066400000000000000000000020221473117447000225030ustar00rootroot00000000000000'use strict'; var test = require('tape'); var forEach = require('for-each'); var v = require('es-value-fixtures'); var inspect = require('object-inspect'); var dataViewByteLength = require('../'); test('dataViewByteLength', function (t) { forEach( // @ts-expect-error TS sucks at [].concat // eslint-disable-next-line no-extra-parens /** @type {[...typeof v.primitives, ...typeof v.objects]} */ ([].concat(v.primitives, v.objects)), function (nonDV) { t['throws'](function () { dataViewByteLength(nonDV); }, TypeError, inspect(nonDV) + ' is not a DataView'); } ); t.test('DataView', { skip: typeof DataView !== 'function' }, function (st) { var ab = new ArrayBuffer(42); var dv = new DataView(ab); st.equal(dataViewByteLength(dv), 42, inspect(dv) + ' has the same byteLength as the buffer originally passed to the DataView'); st.equal(dataViewByteLength(dv), dv.buffer.byteLength, inspect(dv) + ' has the same byteLength as the buffer’s byteLength of its own buffer property'); st.end(); }); t.end(); }); inspect-js-data-view-byte-length-0315207/tsconfig.json000066400000000000000000000003621473117447000225730ustar00rootroot00000000000000{ "extends": "@ljharb/tsconfig", "compilerOptions": { "target": "es2021", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ }, "exclude": [ "coverage", ], }