pax_global_header00006660000000000000000000000064143774644110014525gustar00rootroot0000000000000052 comment=0a880c014f5c635059dc93beae99016e3f9319ce array-buffer-byte-length-1.0.0/000077500000000000000000000000001437746441100163305ustar00rootroot00000000000000array-buffer-byte-length-1.0.0/.eslintrc000066400000000000000000000000531437746441100201520ustar00rootroot00000000000000{ "root": true, "extends": "@ljharb", } array-buffer-byte-length-1.0.0/.github/000077500000000000000000000000001437746441100176705ustar00rootroot00000000000000array-buffer-byte-length-1.0.0/.github/FUNDING.yml000066400000000000000000000011231437746441100215020ustar00rootroot00000000000000# 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/array-buffer-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 up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] array-buffer-byte-length-1.0.0/.github/workflows/000077500000000000000000000000001437746441100217255ustar00rootroot00000000000000array-buffer-byte-length-1.0.0/.github/workflows/node-aught.yml000066400000000000000000000005161437746441100245050ustar00rootroot00000000000000name: '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' array-buffer-byte-length-1.0.0/.github/workflows/node-pretest.yml000066400000000000000000000002061437746441100250570ustar00rootroot00000000000000name: 'Tests: pretest/posttest' on: [pull_request, push] jobs: tests: uses: ljharb/actions/.github/workflows/pretest.yml@main array-buffer-byte-length-1.0.0/.github/workflows/node-tens.yml000066400000000000000000000005211437746441100243420ustar00rootroot00000000000000name: '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' array-buffer-byte-length-1.0.0/.github/workflows/rebase.yml000066400000000000000000000002571437746441100237150ustar00rootroot00000000000000name: Automatic Rebase on: [pull_request_target] jobs: _: uses: ljharb/actions/.github/workflows/rebase.yml@main secrets: token: ${{ secrets.GITHUB_TOKEN }} array-buffer-byte-length-1.0.0/.github/workflows/require-allow-edits.yml000066400000000000000000000003031437746441100263420ustar00rootroot00000000000000name: Require “Allow Edits” on: [pull_request_target] jobs: _: name: "Require “Allow Edits”" runs-on: ubuntu-latest steps: - uses: ljharb/require-allow-edits@main array-buffer-byte-length-1.0.0/.gitignore000066400000000000000000000032501437746441100203200ustar00rootroot00000000000000# 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 .npmignorearray-buffer-byte-length-1.0.0/.npmrc000066400000000000000000000000671437746441100174530ustar00rootroot00000000000000package-lock=false allow-same-version=true message=v%s array-buffer-byte-length-1.0.0/.nycrc000066400000000000000000000003301437746441100174430ustar00rootroot00000000000000{ "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" ] } array-buffer-byte-length-1.0.0/CHANGELOG.md000066400000000000000000000015271437746441100201460ustar00rootroot00000000000000# 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.0 - 2023-02-28 ### Commits - Initial implementation, tests, readme [`2db6cad`](https://github.com/inspect-js/array-buffer-byte-length/commit/2db6cad79270ab1966f5ea80160abbcd4534c91d) - Initial commit [`b2a0c9c`](https://github.com/inspect-js/array-buffer-byte-length/commit/b2a0c9c2246514b7999d331aad868c4f32326db7) - npm init [`376acdb`](https://github.com/inspect-js/array-buffer-byte-length/commit/376acdbd4435cb1d4c31d107cacb3b86f2363aee) - Only apps should have lockfiles [`70cf325`](https://github.com/inspect-js/array-buffer-byte-length/commit/70cf32526fc727d0d16a12d85a4bddea70075e31) array-buffer-byte-length-1.0.0/LICENSE000066400000000000000000000020531437746441100173350ustar00rootroot00000000000000MIT License Copyright (c) 2023 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. array-buffer-byte-length-1.0.0/README.md000066400000000000000000000036711437746441100176160ustar00rootroot00000000000000# array-buffer-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 byte length of an ArrayBuffer, even in engines without a `.byteLength` method. ## Example ```js const assert = require('assert'); const byteLength = require('array-buffer-byte-length'); assert.equal(byteLength([]), NaN, 'an array is not an ArrayBuffer, yields NaN'); assert.equal(byteLength(new ArrayBuffer(0)), 0, 'ArrayBuffer of byteLength 0, yields 0'); ``` ## Tests Simply clone the repo, `npm install`, and run `npm test` [package-url]: https://npmjs.org/package/array-buffer-byte-length [npm-version-svg]: https://versionbadg.es/inspect-js/array-buffer-byte-length.svg [deps-svg]: https://david-dm.org/inspect-js/array-buffer-byte-length.svg [deps-url]: https://david-dm.org/inspect-js/array-buffer-byte-length [dev-deps-svg]: https://david-dm.org/inspect-js/array-buffer-byte-length/dev-status.svg [dev-deps-url]: https://david-dm.org/inspect-js/array-buffer-byte-length#info=devDependencies [npm-badge-png]: https://nodei.co/npm/array-buffer-byte-length.png?downloads=true&stars=true [license-image]: https://img.shields.io/npm/l/array-buffer-byte-length.svg [license-url]: LICENSE [downloads-image]: https://img.shields.io/npm/dm/array-buffer-byte-length.svg [downloads-url]: https://npm-stat.com/charts.html?package=array-buffer-byte-length [codecov-image]: https://codecov.io/gh/inspect-js/array-buffer-byte-length/branch/main/graphs/badge.svg [codecov-url]: https://app.codecov.io/gh/inspect-js/array-buffer-byte-length/ [actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/inspect-js/array-buffer-byte-length [actions-url]: https://github.com/inspect-js/array-buffer-byte-length/actions array-buffer-byte-length-1.0.0/index.js000066400000000000000000000006121437746441100177740ustar00rootroot00000000000000'use strict'; var callBound = require('call-bind/callBound'); var $byteLength = callBound('ArrayBuffer.prototype.byteLength', true); var isArrayBuffer = require('is-array-buffer'); module.exports = function byteLength(ab) { if (!isArrayBuffer(ab)) { return NaN; } return $byteLength ? $byteLength(ab) : ab.byteLength; }; // in node < 0.11, byteLength is an own nonconfigurable property array-buffer-byte-length-1.0.0/package.json000066400000000000000000000041531437746441100206210ustar00rootroot00000000000000{ "name": "array-buffer-byte-length", "version": "1.0.0", "description": "Get the byte length of an ArrayBuffer, even in engines without a `.byteLength` method.", "main": "index.js", "exports": { ".": "./index.js", "./package.json": "./package.json" }, "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 .", "tests-only": "nyc tape 'test/**/*.js'", "test": "npm run tests-only", "posttest": "aud --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)\")\"" }, "keywords": [ "shim", "polyfill", "ArrayBuffer", "byteLength", "byte", "length", "es-shim API", "es-shims" ], "author": "Jordan Harband ", "funding": { "url": "https://github.com/sponsors/ljharb" }, "license": "MIT", "repository": { "type": "git", "url": "git+https://github.com/inspect-js/array-buffer-byte-length.git" }, "bugs": { "url": "https://github.com/inspect-js/array-buffer-byte-length/issues" }, "homepage": "https://github.com/inspect-js/array-buffer-byte-length#readme", "dependencies": { "call-bind": "^1.0.2", "is-array-buffer": "^3.0.1" }, "devDependencies": { "@ljharb/eslint-config": "^21.0.1", "aud": "^2.0.2", "auto-changelog": "^2.4.0", "es-value-fixtures": "^1.4.2", "eslint": "=8.8.0", "evalmd": "^0.0.19", "for-each": "^0.3.3", "in-publish": "^2.0.1", "npmignore": "^0.3.0", "nyc": "^10.3.2", "object-inspect": "^1.12.3", "safe-publish-latest": "^2.0.0", "tape": "^5.6.3" }, "auto-changelog": { "output": "CHANGELOG.md", "template": "keepachangelog", "unreleased": false, "commitLimit": false, "backfillLimit": false, "hideCredit": true }, "testling": { "files": "test/index.js" }, "publishConfig": { "ignore": [ ".github/workflows" ] } } array-buffer-byte-length-1.0.0/test/000077500000000000000000000000001437746441100173075ustar00rootroot00000000000000array-buffer-byte-length-1.0.0/test/index.js000066400000000000000000000013571437746441100207620ustar00rootroot00000000000000'use strict'; var test = require('tape'); var forEach = require('for-each'); var v = require('es-value-fixtures'); var inspect = require('object-inspect'); var byteLength = require('../'); test('byteLength', function (t) { forEach(v.objects.concat(v.primitives), function (nonAB) { t.equal(byteLength(nonAB), NaN, inspect(nonAB) + ' is not an ArrayBuffer, and yields NaN'); }); t.test('ArrayBuffers', { skip: typeof ArrayBuffer !== 'function' }, function (st) { var ab32 = new ArrayBuffer(32); st.equal(byteLength(ab32), 32, 'works on an ArrayBuffer of length 32: ' + inspect(ab32)); var ab0 = new ArrayBuffer(0); st.equal(byteLength(ab0), 0, 'works on an ArrayBuffer of length 0: ' + inspect(ab0)); st.end(); }); t.end(); });