pax_global_header00006660000000000000000000000064144000341610014503gustar00rootroot0000000000000052 comment=87a13652c4361a9d1ae8cbcde27fc836e3de6d32 is-array-buffer-3.0.2/000077500000000000000000000000001440003416100145035ustar00rootroot00000000000000is-array-buffer-3.0.2/.eslintrc000066400000000000000000000002201440003416100163210ustar00rootroot00000000000000{ "root": true, "extends": "@ljharb", "rules": { "new-cap": ["error", { "capIsNewExceptions": [ "GetIntrinsic", ], }], }, } is-array-buffer-3.0.2/.github/000077500000000000000000000000001440003416100160435ustar00rootroot00000000000000is-array-buffer-3.0.2/.github/FUNDING.yml000066400000000000000000000011121440003416100176530ustar00rootroot00000000000000# 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/is-array-buffer 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'] is-array-buffer-3.0.2/.github/workflows/000077500000000000000000000000001440003416100201005ustar00rootroot00000000000000is-array-buffer-3.0.2/.github/workflows/node-aught.yml000066400000000000000000000005161440003416100226600ustar00rootroot00000000000000name: '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' is-array-buffer-3.0.2/.github/workflows/node-pretest.yml000066400000000000000000000002061440003416100232320ustar00rootroot00000000000000name: 'Tests: pretest/posttest' on: [pull_request, push] jobs: tests: uses: ljharb/actions/.github/workflows/pretest.yml@main is-array-buffer-3.0.2/.github/workflows/node-tens.yml000066400000000000000000000005211440003416100225150ustar00rootroot00000000000000name: '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' is-array-buffer-3.0.2/.github/workflows/rebase.yml000066400000000000000000000002571440003416100220700ustar00rootroot00000000000000name: Automatic Rebase on: [pull_request_target] jobs: _: uses: ljharb/actions/.github/workflows/rebase.yml@main secrets: token: ${{ secrets.GITHUB_TOKEN }} is-array-buffer-3.0.2/.github/workflows/require-allow-edits.yml000066400000000000000000000003031440003416100245150ustar00rootroot00000000000000name: Require “Allow Edits” on: [pull_request_target] jobs: _: name: "Require “Allow Edits”" runs-on: ubuntu-latest steps: - uses: ljharb/require-allow-edits@main is-array-buffer-3.0.2/.gitignore000066400000000000000000000032511440003416100164740ustar00rootroot00000000000000# 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 is-array-buffer-3.0.2/.npmrc000066400000000000000000000000671440003416100156260ustar00rootroot00000000000000package-lock=false allow-same-version=true message=v%s is-array-buffer-3.0.2/.nycrc000066400000000000000000000002131440003416100156160ustar00rootroot00000000000000{ "all": true, "check-coverage": false, "reporter": ["text-summary", "text", "html", "json"], "exclude": [ "coverage", "test" ] } is-array-buffer-3.0.2/CHANGELOG.md000066400000000000000000000054571440003416100163270ustar00rootroot00000000000000# 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). ## [v3.0.2](https://github.com/fengyuanchen/is-array-buffer/compare/v3.0.1...v3.0.2) - 2023-03-01 ### Commits - [Fix] `node` 0.8: an object arg to a TA only throws a RangeError when it is an ArrayBuffer of an incompatible byte length [`d5108f6`](https://github.com/fengyuanchen/is-array-buffer/commit/d5108f6d06245e616b6c563995f214a38732243c) - [Dev Deps] update `object-inspect`, `tape` [`400f456`](https://github.com/fengyuanchen/is-array-buffer/commit/400f4563ccbe27c7fbb485665352c76210bba9cb) - [Deps] update `get-intrinsic` [`133732e`](https://github.com/fengyuanchen/is-array-buffer/commit/133732ec88f8dded1c705b758badc2240077a6d8) ## [v3.0.1](https://github.com/fengyuanchen/is-array-buffer/compare/v3.0.0...v3.0.1) - 2023-01-05 ### Commits - [Fix] in node 0.8, TAs do not coerce Uint8Arrays to an ArrayBuffer properly [`e488763`](https://github.com/fengyuanchen/is-array-buffer/commit/e48876346f446825dad619e55dcc830ed93f2853) - [Dev Deps] update `@ljharb/eslint-config`, `aud` [`8eebfa2`](https://github.com/fengyuanchen/is-array-buffer/commit/8eebfa21881f3a9fa5094f8c486f00e496658ea9) ## [v3.0.0](https://github.com/fengyuanchen/is-array-buffer/compare/v2.0.0...v3.0.0) - 2023-01-04 ### Commits - [Breaking] replace package implementation [`b65f929`](https://github.com/fengyuanchen/is-array-buffer/commit/b65f929d856d2a42f043be0f5a0fc2e067370ed1) - Initial implementation, tests, readme [`06afa73`](https://github.com/fengyuanchen/is-array-buffer/commit/06afa73e775960802ea9257cc6b4cdf768c72d3f) - Initial commit [`051813f`](https://github.com/fengyuanchen/is-array-buffer/commit/051813f15e3cbf515e2447306761dd9c42819150) - npm init [`946d3de`](https://github.com/fengyuanchen/is-array-buffer/commit/946d3de82b15471fb2c00a4a2a5a52eb0515eb04) - [meta] use `npmignore` to autogenerate an npmignore file [`ca4c446`](https://github.com/fengyuanchen/is-array-buffer/commit/ca4c446f37daf5ab8cc590f2194574c2706561ed) - Only apps should have lockfiles [`be7d8eb`](https://github.com/fengyuanchen/is-array-buffer/commit/be7d8eb09dc5033c04df85d7ba9a8714f4e54357) - docs: fix badge link [`9ea7fb6`](https://github.com/fengyuanchen/is-array-buffer/commit/9ea7fb638e79f8938161b3b7370cb965d8e93a8b) ## 2.0.0 (Feb 12, 2021) - Refactor in TypeScript. - Drop the `dist` directory. - Drop the UMD bundled file. - Add a declaration file for TypeScript. ## 1.0.1 (Apr 1, 2018) - Improve code style. ## 1.0.0 (Jul 25, 2017) - Supports UMD, CommonJS and ES Module. ## 0.1.0 (Nov 28, 2015) - Check if ArrayBuffer is defined first. ## 0.0.1 (Nov 11, 2015) - Initial release. is-array-buffer-3.0.2/LICENSE000066400000000000000000000020721440003416100155110ustar00rootroot00000000000000MIT License Copyright (c) 2015 Chen Gengyuan, 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. is-array-buffer-3.0.2/README.md000066400000000000000000000045451440003416100157720ustar00rootroot00000000000000# is-array-buffer [![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] Is this value a JS ArrayBuffer? This module works cross-realm/iframe, does not depend on `instanceof` or mutable properties, and despite ES6 Symbol.toStringTag. ## Example ```js var assert = require('assert'); var isArrayBuffer = require('is-array-buffer'); assert(!isArrayBuffer(function () {})); assert(!isArrayBuffer(null)); assert(!isArrayBuffer(function* () { yield 42; return Infinity; }); assert(!isArrayBuffer(Symbol('foo'))); assert(!isArrayBuffer(1n)); assert(!isArrayBuffer(Object(1n))); assert(!isArrayBuffer(new Set())); assert(!isArrayBuffer(new WeakSet())); assert(!isArrayBuffer(new Map())); assert(!isArrayBuffer(new WeakMap())); assert(!isArrayBuffer(new WeakRef({}))); assert(!isArrayBuffer(new FinalizationRegistry(() => {}))); assert(!isArrayBuffer(new SharedArrayBuffer())); assert(isArrayBuffer(new ArrayBuffer())); class MyArrayBuffer extends ArrayBuffer {} assert(isArrayBuffer(new MyArrayBuffer())); ``` ## Tests Simply clone the repo, `npm install`, and run `npm test` [package-url]: https://npmjs.org/package/is-array-buffer [npm-version-svg]: https://versionbadg.es/inspect-js/is-array-buffer.svg [deps-svg]: https://david-dm.org/inspect-js/is-array-buffer.svg [deps-url]: https://david-dm.org/inspect-js/is-array-buffer [dev-deps-svg]: https://david-dm.org/inspect-js/is-array-buffer/dev-status.svg [dev-deps-url]: https://david-dm.org/inspect-js/is-array-buffer#info=devDependencies [npm-badge-png]: https://nodei.co/npm/is-array-buffer.png?downloads=true&stars=true [license-image]: https://img.shields.io/npm/l/is-array-buffer.svg [license-url]: LICENSE [downloads-image]: https://img.shields.io/npm/dm/is-array-buffer.svg [downloads-url]: https://npm-stat.com/charts.html?package=is-array-buffer [codecov-image]: https://codecov.io/gh/inspect-js/is-array-buffer/branch/main/graphs/badge.svg [codecov-url]: https://app.codecov.io/gh/inspect-js/is-array-buffer/ [actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/inspect-js/is-array-buffer [actions-url]: https://github.com/inspect-js/is-array-buffer/actions is-array-buffer-3.0.2/index.js000066400000000000000000000023521440003416100161520ustar00rootroot00000000000000'use strict'; var callBind = require('call-bind'); var callBound = require('call-bind/callBound'); var GetIntrinsic = require('get-intrinsic'); var isTypedArray = require('is-typed-array'); var $ArrayBuffer = GetIntrinsic('ArrayBuffer', true); var $Float32Array = GetIntrinsic('Float32Array', true); var $byteLength = callBound('ArrayBuffer.prototype.byteLength', true); // in node 0.10, ArrayBuffers have no prototype methods, but have an own slot-checking `slice` method var abSlice = $ArrayBuffer && !$byteLength && new $ArrayBuffer().slice; var $abSlice = abSlice && callBind(abSlice); module.exports = $byteLength || $abSlice ? function isArrayBuffer(obj) { if (!obj || typeof obj !== 'object') { return false; } try { if ($byteLength) { $byteLength(obj); } else { $abSlice(obj, 0); } return true; } catch (e) { return false; } } : $Float32Array // in node 0.8, ArrayBuffers have no prototype or own methods ? function IsArrayBuffer(obj) { try { return (new $Float32Array(obj)).buffer === obj && !isTypedArray(obj); } catch (e) { return typeof obj === 'object' && e.name === 'RangeError'; } } : function isArrayBuffer(obj) { // eslint-disable-line no-unused-vars return false; }; is-array-buffer-3.0.2/package.json000066400000000000000000000040111440003416100167650ustar00rootroot00000000000000{ "name": "is-array-buffer", "version": "3.0.2", "description": "Is this value a JS ArrayBuffer?", "main": "index.js", "exports": { ".": "./index.js", "./package.json": "./package.json" }, "sideEffects": false, "scripts": { "prepack": "npmignore --auto --commentLines=autogenerated", "prepublishOnly": "safe-publish-latest", "prepublish": "not-in-publish || npm run prepublishOnly", "lint": "eslint --ext=.js,.mjs .", "pretest": "npm run lint", "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)\")\"" }, "repository": { "type": "git", "url": "git+https://github.com/inspect-js/is-array-buffer.git" }, "keywords": [ "javascript", "ecmascript", "is", "arraybuffer", "array", "buffer" ], "author": "Jordan Harband ", "funding": { "url": "https://github.com/sponsors/ljharb" }, "license": "MIT", "bugs": { "url": "https://github.com/inspect-js/is-array-buffer/issues" }, "homepage": "https://github.com/inspect-js/is-array-buffer#readme", "devDependencies": { "@ljharb/eslint-config": "^21.0.1", "aud": "^2.0.2", "auto-changelog": "^2.4.0", "available-typed-arrays": "^1.0.5", "es-value-fixtures": "^1.4.2", "eslint": "=8.8.0", "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, "startingVersion": "2.0.1" }, "dependencies": { "call-bind": "^1.0.2", "get-intrinsic": "^1.2.0", "is-typed-array": "^1.1.10" }, "publishConfig": { "ignore": [ ".github/workflows" ] } } is-array-buffer-3.0.2/test/000077500000000000000000000000001440003416100154625ustar00rootroot00000000000000is-array-buffer-3.0.2/test/index.js000066400000000000000000000025041440003416100171300ustar00rootroot00000000000000'use strict'; var test = require('tape'); var inspect = require('object-inspect'); var forEach = require('for-each'); var v = require('es-value-fixtures'); var availableTypedArrays = require('available-typed-arrays')(); var isArrayBuffer = require('..'); test('isArrayBuffer', function (t) { t.equal(typeof isArrayBuffer, 'function', 'is a function'); var nonABs = v.primitives.concat( v.objects, typeof SharedArrayBuffer === 'function' ? new SharedArrayBuffer() : [] ); forEach(nonABs, function (nonAB) { t.equal(isArrayBuffer(nonAB), false, inspect(nonAB) + ' is not an ArrayBuffer'); }); t.test('actual ArrayBuffer instances', { skip: typeof ArrayBuffer === 'undefined' }, function (st) { var ab = new ArrayBuffer(); st.equal(isArrayBuffer(ab), true, inspect(ab) + ' is an ArrayBuffer'); var ab42 = new ArrayBuffer(42); st.equal(isArrayBuffer(ab42), true, inspect(ab42) + ' is an ArrayBuffer'); st.end(); }); t.test('Typed Arrays', { skip: availableTypedArrays.length === 0 }, function (st) { forEach(availableTypedArrays, function (TypedArray) { var ta = new global[TypedArray](0); st.equal(isArrayBuffer(ta.buffer), true, inspect(ta.buffer) + ', the TA\'s buffer, is an ArrayBuffer'); st.equal(isArrayBuffer(ta), false, inspect(ta) + ' is not an ArrayBuffer'); }); st.end(); }); t.end(); });