pax_global_header 0000666 0000000 0000000 00000000064 14730733060 0014515 g ustar 00root root 0000000 0000000 52 comment=0160d9a9091666653b12dda2459c2ca0814a9af4
inspect-js-data-view-byte-offset-a7ce9d9/ 0000775 0000000 0000000 00000000000 14730733060 0020407 5 ustar 00root root 0000000 0000000 inspect-js-data-view-byte-offset-a7ce9d9/.eslintrc 0000664 0000000 0000000 00000000270 14730733060 0022232 0 ustar 00root root 0000000 0000000 {
"root": true,
"extends": "@ljharb",
"globals": {
"DataView": false,
},
"rules": {
"new-cap": ["error", {
"capIsNewExceptions": [
"GetIntrinsic",
],
}],
},
}
inspect-js-data-view-byte-offset-a7ce9d9/.github/ 0000775 0000000 0000000 00000000000 14730733060 0021747 5 ustar 00root root 0000000 0000000 inspect-js-data-view-byte-offset-a7ce9d9/.github/FUNDING.yml 0000664 0000000 0000000 00000001067 14730733060 0023570 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-offset
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-offset-a7ce9d9/.github/workflows/ 0000775 0000000 0000000 00000000000 14730733060 0024004 5 ustar 00root root 0000000 0000000 inspect-js-data-view-byte-offset-a7ce9d9/.github/workflows/node-aught.yml 0000664 0000000 0000000 00000000476 14730733060 0026571 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
inspect-js-data-view-byte-offset-a7ce9d9/.github/workflows/node-pretest.yml 0000664 0000000 0000000 00000000245 14730733060 0027141 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-offset-a7ce9d9/.github/workflows/node-tens.yml 0000664 0000000 0000000 00000000372 14730733060 0026425 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
inspect-js-data-view-byte-offset-a7ce9d9/.github/workflows/node-twenties.yml 0000664 0000000 0000000 00000000363 14730733060 0027316 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
inspect-js-data-view-byte-offset-a7ce9d9/.github/workflows/rebase.yml 0000664 0000000 0000000 00000000257 14730733060 0025774 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-offset-a7ce9d9/.github/workflows/require-allow-edits.yml 0000664 0000000 0000000 00000000515 14730733060 0030426 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-offset-a7ce9d9/.gitignore 0000664 0000000 0000000 00000004136 14730733060 0022403 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-offset-a7ce9d9/.npmrc 0000664 0000000 0000000 00000000067 14730733060 0021532 0 ustar 00root root 0000000 0000000 package-lock=false
allow-same-version=true
message=v%s
inspect-js-data-view-byte-offset-a7ce9d9/.nycrc 0000664 0000000 0000000 00000000330 14730733060 0021522 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-offset-a7ce9d9/CHANGELOG.md 0000664 0000000 0000000 00000005310 14730733060 0022217 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.1](https://github.com/inspect-js/data-view-byte-offset/compare/v1.0.0...v1.0.1) - 2024-12-18
### Commits
- [types] use shared tsconfig [`d5ce484`](https://github.com/inspect-js/data-view-byte-offset/commit/d5ce484f91818961c0521d98510131f6e2bb8d84)
- [readme] update URLs [`f297dd2`](https://github.com/inspect-js/data-view-byte-offset/commit/f297dd25fe9e018c6dc4fa181f723af4153e53e0)
- [Dev Deps] update `@arethetypeswrong/cli`, `@ljharb/eslint-config`, `@ljharb/tsconfig`, `@types/object-inspect`, `@types/tape`, `auto-changelog`, `es-value-fixtures`, `object-inspect`, `tape` [`f89d994`](https://github.com/inspect-js/data-view-byte-offset/commit/f89d994b4f94fca0f75a5afe4e07963a379ff36e)
- [actions] split out node 10-20, and 20+ [`e648e1d`](https://github.com/inspect-js/data-view-byte-offset/commit/e648e1da732dad4702184ffb2d2aaa63e5b75ec5)
- [Refactor] use `call-bound` directly [`56d996e`](https://github.com/inspect-js/data-view-byte-offset/commit/56d996ee5ce6a896215c4d9ffadbeda2605a8988)
- [Dev Deps] update `@arethetypeswrong/cli`, `tape` [`63abffa`](https://github.com/inspect-js/data-view-byte-offset/commit/63abffac147beb7917c538122f05dd007f34b41e)
- [Tests] replace `aud` with `npm audit` [`a7c11a5`](https://github.com/inspect-js/data-view-byte-offset/commit/a7c11a54fdfb219b938a04770a8f9c3db36b848f)
- [Deps] update `call-bind` [`b86a774`](https://github.com/inspect-js/data-view-byte-offset/commit/b86a7743d663ee70c4049c134625913e723e570e)
- [Dev Deps] update `@ljharb/tsconfig` [`058bb63`](https://github.com/inspect-js/data-view-byte-offset/commit/058bb6320cc183f48c096f7e8b7d3e13db420805)
- [Deps] update `call-bind` [`6593944`](https://github.com/inspect-js/data-view-byte-offset/commit/6593944952f2064ce3a6c48237da1610fdd169f5)
- [Dev Deps] add missing peer dep [`402219e`](https://github.com/inspect-js/data-view-byte-offset/commit/402219ed9c86ec5046892bc1248423cb34672c20)
## v1.0.0 - 2024-03-04
### Commits
- Initial implementation, tests, readme, types [`8b94518`](https://github.com/inspect-js/data-view-byte-offset/commit/8b94518cd2a87df3084cdf60b52f70d9f65b94b6)
- Initial commit [`aee2acc`](https://github.com/inspect-js/data-view-byte-offset/commit/aee2accbbefcd5645693f4587ce2eabde166b1a0)
- npm init [`10a21a4`](https://github.com/inspect-js/data-view-byte-offset/commit/10a21a4189c51a3add252e3f76fe31a0b5bdcfc1)
- Only apps should have lockfiles [`f6cfa3e`](https://github.com/inspect-js/data-view-byte-offset/commit/f6cfa3e917d58c2e130f9383f5e04f5d5069d0e6)
inspect-js-data-view-byte-offset-a7ce9d9/LICENSE 0000664 0000000 0000000 00000002057 14730733060 0021420 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-offset-a7ce9d9/README.md 0000664 0000000 0000000 00000004032 14730733060 0021665 0 ustar 00root root 0000000 0000000 # data-view-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]
Get the `byteOffset` 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.byteOffset` has been deleted after this module has loaded.
## Example
```js
const dataViewByteOffset = require('data-view-byte-offset');
const assert = require('assert');
const ab = new ArrayBuffer(42);
const dv = new DataView(ab, 2);
assert.equal(dataViewByteOffset(dv), 2);
```
## Tests
Simply clone the repo, `npm install`, and run `npm test`
[package-url]: https://npmjs.org/package/data-view-byte-offset
[npm-version-svg]: https://versionbadg.es/inspect-js/data-view-byte-offset.svg
[deps-svg]: https://david-dm.org/inspect-js/data-view-byte-offset.svg
[deps-url]: https://david-dm.org/inspect-js/data-view-byte-offset
[dev-deps-svg]: https://david-dm.org/inspect-js/data-view-byte-offset/dev-status.svg
[dev-deps-url]: https://david-dm.org/inspect-js/data-view-byte-offset#info=devDependencies
[npm-badge-png]: https://nodei.co/npm/data-view-byte-offset.png?downloads=true&stars=true
[license-image]: https://img.shields.io/npm/l/data-view-byte-offset.svg
[license-url]: LICENSE
[downloads-image]: https://img.shields.io/npm/dm/data-view-byte-offset.svg
[downloads-url]: https://npm-stat.com/charts.html?package=data-view-byte-offset
[codecov-image]: https://codecov.io/gh/inspect-js/data-view-byte-offset/branch/main/graphs/badge.svg
[codecov-url]: https://app.codecov.io/gh/inspect-js/data-view-byte-offset/
[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/inspect-js/data-view-byte-offset
[actions-url]: https://github.com/inspect-js/data-view-byte-offset/actions
inspect-js-data-view-byte-offset-a7ce9d9/index.d.ts 0000664 0000000 0000000 00000000227 14730733060 0022311 0 ustar 00root root 0000000 0000000 declare function dataViewByteOffset(value: DataView): number;
declare function dataViewByteOffset(value: unknown): never;
export = dataViewByteOffset; inspect-js-data-view-byte-offset-a7ce9d9/index.js 0000664 0000000 0000000 00000000761 14730733060 0022060 0 ustar 00root root 0000000 0000000 'use strict';
var $TypeError = require('es-errors/type');
var callBound = require('call-bound');
var $dataViewByteOffset = callBound('DataView.prototype.byteOffset', 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 = $dataViewByteOffset || function byteOffset(x) {
if (!isDataView(x)) {
throw new $TypeError('not a DataView');
}
return x.byteOffset;
};
inspect-js-data-view-byte-offset-a7ce9d9/package.json 0000664 0000000 0000000 00000004702 14730733060 0022700 0 ustar 00root root 0000000 0000000 {
"name": "data-view-byte-offset",
"version": "1.0.1",
"description": "Get the byteOffset 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/ljharb"
},
"repository": {
"type": "git",
"url": "git+https://github.com/inspect-js/data-view-byte-offset.git"
},
"keywords": [
"javascript",
"ecmascript",
"dataView",
"data",
"view",
"byte",
"offset",
"byteOffset",
"robust"
],
"author": "Jordan Harband ",
"license": "MIT",
"bugs": {
"url": "https://github.com/inspect-js/data-view-byte-offset/issues"
},
"homepage": "https://github.com/inspect-js/data-view-byte-offset#readme",
"dependencies": {
"call-bound": "^1.0.2",
"es-errors": "^1.3.0",
"is-data-view": "^1.0.1"
},
"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-value-fixtures": "^1.4.4",
"@types/for-each": "^0.3.3",
"@types/object-inspect": "^1.13.0",
"@types/tape": "^5.6.5",
"auto-changelog": "^2.5.0",
"encoding": "^0.1.13",
"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-offset-a7ce9d9/test/ 0000775 0000000 0000000 00000000000 14730733060 0021366 5 ustar 00root root 0000000 0000000 inspect-js-data-view-byte-offset-a7ce9d9/test/index.js 0000664 0000000 0000000 00000001744 14730733060 0023041 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 dataViewByteOffset = require('../');
test('dataViewByteOffset', 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 () { dataViewByteOffset(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, 2);
st.equal(dataViewByteOffset(dv), 2, inspect(dv) + ' has the same byteOffset originally passed to the DataView');
st.equal(dataViewByteOffset(dv), dv.byteOffset, inspect(dv) + ' has the same byteOffset as the buffer’s byteOffset');
st.end();
});
t.end();
});
inspect-js-data-view-byte-offset-a7ce9d9/tsconfig.json 0000664 0000000 0000000 00000000164 14730733060 0023117 0 ustar 00root root 0000000 0000000 {
"extends": "@ljharb/tsconfig",
"compilerOptions": {
"target": "es2021",
},
"exclude": [
"coverage",
],
}