pax_global_header 0000666 0000000 0000000 00000000064 14731174470 0014522 g ustar 00root root 0000000 0000000 52 comment=76b05f64f4ecdca09df1a5f9f40501ca903f9bd8
inspect-js-data-view-byte-length-0315207/ 0000775 0000000 0000000 00000000000 14731174470 0020063 5 ustar 00root root 0000000 0000000 inspect-js-data-view-byte-length-0315207/.eslintrc 0000664 0000000 0000000 00000000270 14731174470 0021706 0 ustar 00root root 0000000 0000000 {
"root": true,
"extends": "@ljharb",
"globals": {
"DataView": false,
},
"rules": {
"new-cap": ["error", {
"capIsNewExceptions": [
"GetIntrinsic",
],
}],
},
}
inspect-js-data-view-byte-length-0315207/.github/ 0000775 0000000 0000000 00000000000 14731174470 0021423 5 ustar 00root root 0000000 0000000 inspect-js-data-view-byte-length-0315207/.github/FUNDING.yml 0000664 0000000 0000000 00000001067 14731174470 0023244 0 ustar 00root root 0000000 0000000 # 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/ 0000775 0000000 0000000 00000000000 14731174470 0023460 5 ustar 00root root 0000000 0000000 inspect-js-data-view-byte-length-0315207/.github/workflows/node-aught.yml 0000664 0000000 0000000 00000000650 14731174470 0026237 0 ustar 00root root 0000000 0000000 name: '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.yml 0000664 0000000 0000000 00000000245 14731174470 0026615 0 ustar 00root root 0000000 0000000 name: '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.yml 0000664 0000000 0000000 00000000547 14731174470 0026105 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
inspect-js-data-view-byte-length-0315207/.github/workflows/node-twenties.yml 0000664 0000000 0000000 00000000536 14731174470 0026774 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
inspect-js-data-view-byte-length-0315207/.github/workflows/rebase.yml 0000664 0000000 0000000 00000000257 14731174470 0025450 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 }}
inspect-js-data-view-byte-length-0315207/.github/workflows/require-allow-edits.yml 0000664 0000000 0000000 00000000515 14731174470 0030102 0 ustar 00root root 0000000 0000000 name: 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/.gitignore 0000664 0000000 0000000 00000004136 14731174470 0022057 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
.npmignore
inspect-js-data-view-byte-length-0315207/.npmrc 0000664 0000000 0000000 00000000067 14731174470 0021206 0 ustar 00root root 0000000 0000000 package-lock=false
allow-same-version=true
message=v%s
inspect-js-data-view-byte-length-0315207/.nycrc 0000664 0000000 0000000 00000000330 14731174470 0021176 0 ustar 00root root 0000000 0000000 {
"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.md 0000664 0000000 0000000 00000005507 14731174470 0021703 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.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/LICENSE 0000664 0000000 0000000 00000002057 14731174470 0021074 0 ustar 00root root 0000000 0000000 MIT 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.md 0000664 0000000 0000000 00000004030 14731174470 0021337 0 ustar 00root root 0000000 0000000 # 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.ts 0000664 0000000 0000000 00000000227 14731174470 0021765 0 ustar 00root root 0000000 0000000 declare function dataViewByteLength(value: DataView): number;
declare function dataViewByteLength(value: unknown): never;
export = dataViewByteLength; inspect-js-data-view-byte-length-0315207/index.js 0000664 0000000 0000000 00000000761 14731174470 0021534 0 ustar 00root root 0000000 0000000 '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.json 0000664 0000000 0000000 00000004615 14731174470 0022357 0 ustar 00root root 0000000 0000000 {
"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/ 0000775 0000000 0000000 00000000000 14731174470 0021042 5 ustar 00root root 0000000 0000000 inspect-js-data-view-byte-length-0315207/test/index.js 0000664 0000000 0000000 00000002022 14731174470 0022503 0 ustar 00root root 0000000 0000000 '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.json 0000664 0000000 0000000 00000000362 14731174470 0022573 0 ustar 00root root 0000000 0000000 {
"extends": "@ljharb/tsconfig",
"compilerOptions": {
"target": "es2021", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
},
"exclude": [
"coverage",
],
}