diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index bc228f8..0000000 --- a/.editorconfig +++ /dev/null @@ -1,20 +0,0 @@ -root = true - -[*] -indent_style = tab -indent_size = 4 -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true -max_line_length = 150 - -[CHANGELOG.md] -indent_style = space -indent_size = 2 - -[*.json] -max_line_length = off - -[Makefile] -max_line_length = off diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index 34a6262..0000000 --- a/.eslintrc +++ /dev/null @@ -1,13 +0,0 @@ -{ - "root": true, - - "extends": "@ljharb", - - "globals": { - "globalThis": false - }, - - "rules": { - "max-statements-per-line": [2, { "max": 2 }] - }, -} diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml deleted file mode 100644 index 7dd24b9..0000000 --- a/.github/FUNDING.yml +++ /dev/null @@ -1,12 +0,0 @@ -# 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-typed-array -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'] diff --git a/.github/workflows/node-aught.yml b/.github/workflows/node-aught.yml deleted file mode 100644 index d6fed62..0000000 --- a/.github/workflows/node-aught.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: '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 - skip-ls-check: true - - node: - name: 'node < 10' - needs: [tests] - runs-on: ubuntu-latest - steps: - - run: true diff --git a/.github/workflows/node-harmony.yml b/.github/workflows/node-harmony.yml deleted file mode 100644 index 2825e83..0000000 --- a/.github/workflows/node-harmony.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: 'Tests: node.js (harmony)' - -on: [pull_request, push] - -jobs: - tests: - uses: ljharb/actions/.github/workflows/node.yml@main - with: - range: '>=0.4 <16' - type: minors - command: npm run test:harmony - skip-ls-check: true - - node: - name: 'node: harmony' - needs: [tests] - runs-on: ubuntu-latest - steps: - - run: true diff --git a/.github/workflows/node-pretest.yml b/.github/workflows/node-pretest.yml deleted file mode 100644 index 765edf7..0000000 --- a/.github/workflows/node-pretest.yml +++ /dev/null @@ -1,7 +0,0 @@ -name: 'Tests: pretest/posttest' - -on: [pull_request, push] - -jobs: - tests: - uses: ljharb/actions/.github/workflows/pretest.yml@main diff --git a/.github/workflows/node-tens.yml b/.github/workflows/node-tens.yml deleted file mode 100644 index 6b71d59..0000000 --- a/.github/workflows/node-tens.yml +++ /dev/null @@ -1,21 +0,0 @@ -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 diff --git a/.github/workflows/node-twenties.yml b/.github/workflows/node-twenties.yml deleted file mode 100644 index 66c9382..0000000 --- a/.github/workflows/node-twenties.yml +++ /dev/null @@ -1,21 +0,0 @@ -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 diff --git a/.github/workflows/rebase.yml b/.github/workflows/rebase.yml deleted file mode 100644 index b9e1712..0000000 --- a/.github/workflows/rebase.yml +++ /dev/null @@ -1,9 +0,0 @@ -name: Automatic Rebase - -on: [pull_request_target] - -jobs: - _: - uses: ljharb/actions/.github/workflows/rebase.yml@main - secrets: - token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/require-allow-edits.yml b/.github/workflows/require-allow-edits.yml deleted file mode 100644 index 7b842f8..0000000 --- a/.github/workflows/require-allow-edits.yml +++ /dev/null @@ -1,12 +0,0 @@ -name: Require “Allow Edits” - -on: [pull_request_target] - -jobs: - _: - name: "Require “Allow Edits”" - - runs-on: ubuntu-latest - - steps: - - uses: ljharb/require-allow-edits@main diff --git a/.gitignore b/.gitignore index 7fbca22..3c3629e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,35 +1 @@ -# Logs -logs -*.log - -# Runtime data -pids -*.pid -*.seed - -# Directory for instrumented libs generated by jscoverage/JSCover -lib-cov - -# Coverage directory used by tools like istanbul -coverage -.nyc_output/ - -# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) -.grunt - -# node-waf configuration -.lock-wscript - -# Compiled binary addons (http://nodejs.org/api/addons.html) -build/Release - -# Dependency directory -# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git node_modules - -# Only apps should have lockfiles -npm-shrinkwrap.json -package-lock.json -yarn.lock - -.npmignore diff --git a/.npmrc b/.npmrc deleted file mode 100644 index eacea13..0000000 --- a/.npmrc +++ /dev/null @@ -1,3 +0,0 @@ -package-lock=false -allow-same-version=true -message=v%s diff --git a/.nycrc b/.nycrc deleted file mode 100644 index bdd626c..0000000 --- a/.nycrc +++ /dev/null @@ -1,9 +0,0 @@ -{ - "all": true, - "check-coverage": false, - "reporter": ["text-summary", "text", "html", "json"], - "exclude": [ - "coverage", - "test" - ] -} diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index a2f6fb3..0000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,166 +0,0 @@ -# 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.1.15](https://github.com/inspect-js/is-typed-array/compare/v1.1.14...v1.1.15) - 2024-12-18 - -### Commits - -- [types] improve types [`d934b49`](https://github.com/inspect-js/is-typed-array/commit/d934b49f7a16d5e20ba437a795b887f1f71ef240) -- [Dev Deps] update `@types/tape` [`da26511`](https://github.com/inspect-js/is-typed-array/commit/da26511ad7515c50fdc720701d5735b0d8a40800) - -## [v1.1.14](https://github.com/inspect-js/is-typed-array/compare/v1.1.13...v1.1.14) - 2024-12-17 - -### Commits - -- [types] use shared config [`eafa7fa`](https://github.com/inspect-js/is-typed-array/commit/eafa7fad2fc8d464a68e218d39a7eab782d9ce76) -- [actions] split out node 10-20, and 20+ [`cd6d5a3`](https://github.com/inspect-js/is-typed-array/commit/cd6d5a3283a1e65cf5885e57daede65a5176fd91) -- [types] use `which-typed-array`’s `TypedArray` type; re-export it [`d7d9fcd`](https://github.com/inspect-js/is-typed-array/commit/d7d9fcd75d538b7f8146dcd9faca5142534a3d45) -- [Dev Deps] update `@arethetypeswrong/cli`, `@ljharb/eslint-config`, `@ljharb/tsconfig`, `@types/node`, `@types/object-inspect`, `@types/tape`, `auto-changelog`, `object-inspect`, `tape` [`65afb42`](https://github.com/inspect-js/is-typed-array/commit/65afb4263ff4f4ee4ee51b284dc7519ce969a666) -- [Dev Deps] update `@types/node`, `has-tostringtag`, `tape` [`9e27ddd`](https://github.com/inspect-js/is-typed-array/commit/9e27ddd62a51ebae46781de0adbd8871341c633c) -- [Tests] replace `aud` with `npm audit` [`ad4defe`](https://github.com/inspect-js/is-typed-array/commit/ad4defe211c77d42b880d13faf7737b8f1adaf13) -- [Tests] use `@arethetypeswrong/cli` [`ac4bcca`](https://github.com/inspect-js/is-typed-array/commit/ac4bcca4ee2215662e79aa21681756984bb0b6d1) -- [Deps] update `which-typed-array` [`c298129`](https://github.com/inspect-js/is-typed-array/commit/c2981299c09cd64d89bf1e496447c0379b45d03a) -- [Deps] update `which-typed-array` [`744c29a`](https://github.com/inspect-js/is-typed-array/commit/744c29aa8d4f9df360082074f7b4f2f0d42d76e5) -- [Dev Deps] add missing peer dep [`94d2f5a`](https://github.com/inspect-js/is-typed-array/commit/94d2f5a11016516823e8d943e0bfc7b29dcb146d) - -## [v1.1.13](https://github.com/inspect-js/is-typed-array/compare/v1.1.12...v1.1.13) - 2024-02-01 - -### Commits - -- [patch] add types [`8a8a679`](https://github.com/inspect-js/is-typed-array/commit/8a8a679937d1c4b970c98556460cef2b7fa0bffb) -- [Dev Deps] update `aud`, `has-tostringtag`, `npmignore`, `object-inspect`, `tape` [`8146b60`](https://github.com/inspect-js/is-typed-array/commit/8146b6019a24f502e66e2c224ce5bea8df9f39bc) -- [actions] optimize finishers [`34f875a`](https://github.com/inspect-js/is-typed-array/commit/34f875ace16c4900d6b0ef4688e9e3eb7d502715) -- [Deps] update `which-typed-array` [`19c974f`](https://github.com/inspect-js/is-typed-array/commit/19c974f4bbd93ffc45cb8638b86688bc00f1420b) -- [meta] add `sideEffects` flag [`0b68e5e`](https://github.com/inspect-js/is-typed-array/commit/0b68e5e58684b79110a82a0a51df8beb7574d6a2) - -## [v1.1.12](https://github.com/inspect-js/is-typed-array/compare/v1.1.11...v1.1.12) - 2023-07-17 - -### Commits - -- [Refactor] use `which-typed-array` for all internals [`7619405`](https://github.com/inspect-js/is-typed-array/commit/761940532de595f6721fed101b02814dcfa7fe4e) - -## [v1.1.11](https://github.com/inspect-js/is-typed-array/compare/v1.1.10...v1.1.11) - 2023-07-17 - -### Commits - -- [Fix] `node < v0.6` lacks proper Object toString behavior [`c94b90d`](https://github.com/inspect-js/is-typed-array/commit/c94b90dc6bc457783d6f8cc208415a49da0933b7) -- [Robustness] use `call-bind` [`573b00b`](https://github.com/inspect-js/is-typed-array/commit/573b00b8deec42ac1ac262415e442ea0b7e1c96b) -- [Dev Deps] update `@ljharb/eslint-config`, `aud`, `object-inspect`, `tape` [`c88c2d4`](https://github.com/inspect-js/is-typed-array/commit/c88c2d479976110478fa4038fe8921251c06a163) - -## [v1.1.10](https://github.com/inspect-js/is-typed-array/compare/v1.1.9...v1.1.10) - 2022-11-02 - -### Commits - -- [meta] add `auto-changelog` [`cf6d86b`](https://github.com/inspect-js/is-typed-array/commit/cf6d86bf2f693eca357439d4d12e76d641f91f92) -- [actions] update rebase action to use reusable workflow [`8da51a5`](https://github.com/inspect-js/is-typed-array/commit/8da51a5dce6d2442ae31ccbc2be136f2e04d6bef) -- [Dev Deps] update `aud`, `is-callable`, `object-inspect`, `tape` [`554e3de`](https://github.com/inspect-js/is-typed-array/commit/554e3deec59dec926d0badc628e589ab363e465b) -- [Refactor] use `gopd` instead of an `es-abstract` helper` [`cdaa465`](https://github.com/inspect-js/is-typed-array/commit/cdaa465d5f94bfc9e32475e31209e1c2458a9603) -- [Deps] update `es-abstract` [`677ae4b`](https://github.com/inspect-js/is-typed-array/commit/677ae4b3c8323b59d6650a9254ab945045c33f79) - - - -1.1.9 / 2022-05-13 -================= - * [Refactor] use `foreach` instead of `for-each` - * [readme] markdown URL cleanup - * [Deps] update `es-abstract` - * [meta] use `npmignore` to autogenerate an npmignore file - * [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `object-inspect`, `safe-publish-latest`, `tape` - * [actions] reuse common workflows - * [actions] update codecov uploader - -1.1.8 / 2021-08-30 -================= - * [Refactor] use `globalThis` if available (#53) - * [Deps] update `available-typed-arrays` - * [Dev Deps] update `@ljharb/eslint-config` - -1.1.7 / 2021-08-07 -================= - * [Fix] if Symbol.toStringTag exists but is not present, use Object.prototype.toString - * [Dev Deps] update `is-callable`, `tape` - -1.1.6 / 2021-08-05 -================= - * [Fix] use `has-tostringtag` to behave correctly in the presence of symbol shams - * [readme] add actions and codecov badges - * [meta] use `prepublishOnly` script for npm 7+ - * [Deps] update `available-typed-arrays`, `es-abstract` - * [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `object-inspect`, `tape` - * [actions] use `node/install` instead of `node/run`; use `codecov` action - -1.1.5 / 2021-02-14 -================= - * [meta] do not publish github action workflow files or nyc output - * [Deps] update `call-bind`, `es-abstract` - * [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `is-callable`, `tape` - -1.1.4 / 2020-12-05 -================= - * [readme] fix repo URLs, remove defunct badges - * [Deps] update `available-typed-arrays`, `es-abstract`; use `call-bind` where applicable - * [meta] gitignore nyc output - * [meta] only audit prod deps - * [actions] add "Allow Edits" workflow - * [actions] switch Automatic Rebase workflow to `pull_request_target` event - * [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `is-callable`, `make-arrow-function`, `make-generator-function`, `object-inspect`, `tape`; add `aud` - * [Tests] migrate tests to Github Actions - * [Tests] run `nyc` on all tests - -1.1.3 / 2020-01-24 -================= - * [Refactor] use `es-abstract`’s `callBound`, `available-typed-arrays`, `has-symbols` - -1.1.2 / 2020-01-20 -================= - * [Fix] in envs without Symbol.toStringTag, dc8a8cc made arrays return `true` - * [Tests] add `evalmd` to `prelint` - -1.1.1 / 2020-01-18 -================= - * [Robustness] don’t rely on Array.prototype.indexOf existing - * [meta] remove unused Makefile and associated utilities - * [meta] add `funding` field; create FUNDING.yml - * [actions] add automatic rebasing / merge commit blocking - * [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `is-callable`, `replace`, `semver`, `tape`; add `safe-publish-latest` - * [Tests] use shared travis-ci configs - * [Tests] use `npx aud` instead of `nsp` or `npm audit` with hoops - -1.1.0 / 2019-02-16 -================= - * [New] add `BigInt64Array` and `BigUint64Array` - * [Refactor] use an array instead of an object for storing Typed Array names - * [meta] ignore `test.html` - * [Tests] up to `node` `v11.10`, `v10.15`, `v8.15`, `v7.10`, `v6.16`, `v5.10`, `v4.9` - * [Tests] remove `jscs` - * [Tests] use `npm audit` instead of `nsp` - * [Dev Deps] update `eslint`,` @ljharb/eslint-config`, `is-callable`, `tape`, `replace`, `semver` - * [Dev Deps] remove unused eccheck script + dep - -1.0.4 / 2016-03-19 -================= - * [Fix] `Symbol.toStringTag` is on the super-`[[Prototype]]` of Float32Array, not the `[[Prototype]]` (#3) - * [Tests] up to `node` `v5.9`, `v4.4` - * [Tests] use pretest/posttest for linting/security - * [Dev Deps] update `tape`, `jscs`, `nsp`, `eslint`, `@ljharb/eslint-config`, `semver`, `is-callable` - -1.0.3 / 2015-10-13 -================= - * [Deps] Add missing `foreach` dependency (#1) - -1.0.2 / 2015-10-05 -================= - * [Deps] Remove unneeded "isarray" dependency - * [Dev Deps] update `eslint`, `@ljharb/eslint-config` - -1.0.1 / 2015-10-02 -================= - * Rerelease: avoid instanceof and the constructor property; work cross-realm; work with Symbol.toStringTag. - -1.0.0 / 2015-05-06 -================= - * Initial release. diff --git a/LICENSE b/LICENSE deleted file mode 100644 index b43df44..0000000 --- a/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2015 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. - diff --git a/README.md b/README.md index 5075257..836623e 100644 --- a/README.md +++ b/README.md @@ -1,70 +1,7 @@ -# is-typed-array [![Version Badge][npm-version-svg]][package-url] +# is-typed-array -[![github actions][actions-image]][actions-url] -[![coverage][codecov-image]][codecov-url] -[![dependency status][5]][6] -[![dev dependency status][7]][8] -[![License][license-image]][license-url] -[![Downloads][downloads-image]][downloads-url] +Check if the passed in object is a TypedArray (e.g. Float32Array). -[![npm badge][npm-badge-png]][package-url] +## install -Is this value a JS Typed Array? This module works cross-realm/iframe, does not depend on `instanceof` or mutable properties, and despite ES6 Symbol.toStringTag. - -## Example - -```js -var isTypedArray = require('is-typed-array'); -var assert = require('assert'); - -assert.equal(false, isTypedArray(undefined)); -assert.equal(false, isTypedArray(null)); -assert.equal(false, isTypedArray(false)); -assert.equal(false, isTypedArray(true)); -assert.equal(false, isTypedArray([])); -assert.equal(false, isTypedArray({})); -assert.equal(false, isTypedArray(/a/g)); -assert.equal(false, isTypedArray(new RegExp('a', 'g'))); -assert.equal(false, isTypedArray(new Date())); -assert.equal(false, isTypedArray(42)); -assert.equal(false, isTypedArray(NaN)); -assert.equal(false, isTypedArray(Infinity)); -assert.equal(false, isTypedArray(new Number(42))); -assert.equal(false, isTypedArray('foo')); -assert.equal(false, isTypedArray(Object('foo'))); -assert.equal(false, isTypedArray(function () {})); -assert.equal(false, isTypedArray(function* () {})); -assert.equal(false, isTypedArray(x => x * x)); -assert.equal(false, isTypedArray([])); - -assert.ok(isTypedArray(new Int8Array())); -assert.ok(isTypedArray(new Uint8Array())); -assert.ok(isTypedArray(new Uint8ClampedArray())); -assert.ok(isTypedArray(new Int16Array())); -assert.ok(isTypedArray(new Uint16Array())); -assert.ok(isTypedArray(new Int32Array())); -assert.ok(isTypedArray(new Uint32Array())); -assert.ok(isTypedArray(new Float32Array())); -assert.ok(isTypedArray(new Float64Array())); -assert.ok(isTypedArray(new BigInt64Array())); -assert.ok(isTypedArray(new BigUint64Array())); -``` - -## Tests -Simply clone the repo, `npm install`, and run `npm test` - -[package-url]: https://npmjs.org/package/is-typed-array -[npm-version-svg]: https://versionbadg.es/inspect-js/is-typed-array.svg -[deps-svg]: https://david-dm.org/inspect-js/is-typed-array.svg -[deps-url]: https://david-dm.org/inspect-js/is-typed-array -[dev-deps-svg]: https://david-dm.org/inspect-js/is-typed-array/dev-status.svg -[dev-deps-url]: https://david-dm.org/inspect-js/is-typed-array#info=devDependencies -[npm-badge-png]: https://nodei.co/npm/is-typed-array.png?downloads=true&stars=true -[license-image]: https://img.shields.io/npm/l/is-typed-array.svg -[license-url]: LICENSE -[downloads-image]: https://img.shields.io/npm/dm/is-typed-array.svg -[downloads-url]: https://npm-stat.com/charts.html?package=is-typed-array -[codecov-image]: https://codecov.io/gh/inspect-js/is-typed-array/branch/main/graphs/badge.svg -[codecov-url]: https://app.codecov.io/gh/inspect-js/is-typed-array/ -[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/inspect-js/is-typed-array -[actions-url]: https://github.com/inspect-js/is-typed-array/actions +Do `npm i is-typed-array`. diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 73bcf35..0000000 --- a/index.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -import type { TypedArray } from 'which-typed-array'; - -declare namespace isTypedArray { - export { TypedArray }; -} - -declare function isTypedArray(value: unknown): value is isTypedArray.TypedArray; - -export = isTypedArray; diff --git a/index.js b/index.js index 6e38c53..4a85d97 100644 --- a/index.js +++ b/index.js @@ -1,8 +1,7 @@ 'use strict'; -var whichTypedArray = require('which-typed-array'); - -/** @type {import('.')} */ -module.exports = function isTypedArray(value) { - return !!whichTypedArray(value); +var isTypedArray = function (obj) { + return obj && obj.buffer && obj.buffer.constructor === ArrayBuffer; }; + +module.exports = isTypedArray; diff --git a/package.json b/package.json index a8b1e77..0213bb5 100644 --- a/package.json +++ b/package.json @@ -1,129 +1,26 @@ { - "name": "is-typed-array", - "version": "1.1.15", - "author": { - "name": "Jordan Harband", - "email": "ljharb@gmail.com", - "url": "http://ljharb.codes" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - }, - "contributors": [ - { - "name": "Jordan Harband", - "email": "ljharb@gmail.com", - "url": "http://ljharb.codes" - } - ], - "description": "Is this value a JS Typed Array? This module works cross-realm/iframe, does not depend on `instanceof` or mutable properties, and despite ES6 Symbol.toStringTag.", - "license": "MIT", - "main": "index.js", - "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 --silent lint", - "test": "npm run tests-only && npm run test:harmony", - "tests-only": "nyc tape test", - "test:harmony": "nyc node --harmony --es-staging test", - "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)\")\"" - }, - "repository": { - "type": "git", - "url": "git://github.com/inspect-js/is-typed-array.git" - }, - "keywords": [ - "array", - "TypedArray", - "typed array", - "is", - "typed", - "Int8Array", - "Uint8Array", - "Uint8ClampedArray", - "Int16Array", - "Uint16Array", - "Int32Array", - "Uint32Array", - "Float32Array", - "Float64Array", - "ES6", - "toStringTag", - "Symbol.toStringTag", - "@@toStringTag" - ], - "dependencies": { - "which-typed-array": "^1.1.16" - }, - "devDependencies": { - "@arethetypeswrong/cli": "^0.17.1", - "@ljharb/eslint-config": "^21.1.1", - "@ljharb/tsconfig": "^0.2.2", - "@types/for-each": "^0.3.3", - "@types/is-callable": "^1.1.2", - "@types/make-arrow-function": "^1.2.2", - "@types/make-generator-function": "^2.0.3", - "@types/node": "^20.17.10", - "@types/object-inspect": "^1.13.0", - "@types/tape": "^5.8.0", - "auto-changelog": "^2.5.0", - "encoding": "^0.1.13", - "eslint": "=8.8.0", - "evalmd": "^0.0.19", - "for-each": "^0.3.3", - "has-tostringtag": "^1.0.2", - "in-publish": "^2.0.1", - "is-callable": "^1.2.7", - "make-arrow-function": "^1.2.0", - "make-generator-function": "^2.0.0", - "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" - }, - "testling": { - "files": "test/index.js", - "browsers": [ - "iexplore/6.0..latest", - "firefox/3.0..6.0", - "firefox/15.0..latest", - "firefox/nightly", - "chrome/4.0..10.0", - "chrome/20.0..latest", - "chrome/canary", - "opera/10.0..latest", - "opera/next", - "safari/4.0..latest", - "ipad/6.0..latest", - "iphone/6.0..latest", - "android-browser/4.2" - ] - }, - "engines": { - "node": ">= 0.4" - }, - "auto-changelog": { - "output": "CHANGELOG.md", - "template": "keepachangelog", - "unreleased": false, - "commitLimit": false, - "backfillLimit": false, - "hideCredit": true, - "startingVersion": "1.1.10" - }, - "publishConfig": { - "ignore": [ - ".github/workflows" - ] - } + "name": "is-typed-array", + "version": "1.0.0", + "description": "Check if the passed in object is a TypedArray (e.g. Float32Array).", + "main": "index.js", + "scripts": { + "test": "browserify test.js | tap-closer | smokestack | tap-spec" + }, + "author": "", + "license": "ISC", + "devDependencies": { + "browserify": "^10.1.1", + "smokestack": "^3.2.2", + "tap-closer": "^1.0.0", + "tap-spec": "^3.0.0", + "tape": "^4.0.0" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/alexanderGugel/is-typed-array.git" + }, + "bugs": { + "url": "https://github.com/alexanderGugel/is-typed-array/issues" + }, + "homepage": "https://github.com/alexanderGugel/is-typed-array#readme" } diff --git a/test.js b/test.js new file mode 100644 index 0000000..00db895 --- /dev/null +++ b/test.js @@ -0,0 +1,11 @@ +'use strict'; + +var test = require('tape'); +var isTypedArray = require('./'); + +test('isTypedArray', function(t) { + t.ok(isTypedArray(new Float32Array)); + t.notOk(isTypedArray([])); + t.end(); +}); + diff --git a/test/index.js b/test/index.js deleted file mode 100644 index c96e397..0000000 --- a/test/index.js +++ /dev/null @@ -1,111 +0,0 @@ -'use strict'; - -var test = require('tape'); -var isTypedArray = require('../'); -var isCallable = require('is-callable'); -var hasToStringTag = require('has-tostringtag/shams')(); -var generators = require('make-generator-function')(); -var arrowFn = require('make-arrow-function')(); -var forEach = require('for-each'); -var inspect = require('object-inspect'); - -var typedArrayNames = [ - 'Int8Array', - 'Uint8Array', - 'Uint8ClampedArray', - 'Int16Array', - 'Uint16Array', - 'Int32Array', - 'Uint32Array', - 'Float32Array', - 'Float64Array', - 'BigInt64Array', - 'BigUint64Array' -]; - -test('not arrays', function (t) { - t.test('non-number/string primitives', function (st) { - // @ts-expect-error Expected 1 arguments, but got 0.ts(2554) - st.notOk(isTypedArray(), 'undefined is not typed array'); - st.notOk(isTypedArray(null), 'null is not typed array'); - st.notOk(isTypedArray(false), 'false is not typed array'); - st.notOk(isTypedArray(true), 'true is not typed array'); - st.end(); - }); - - t.notOk(isTypedArray({}), 'object is not typed array'); - t.notOk(isTypedArray(/a/g), 'regex literal is not typed array'); - t.notOk(isTypedArray(new RegExp('a', 'g')), 'regex object is not typed array'); - t.notOk(isTypedArray(new Date()), 'new Date() is not typed array'); - - t.test('numbers', function (st) { - st.notOk(isTypedArray(42), 'number is not typed array'); - st.notOk(isTypedArray(Object(42)), 'number object is not typed array'); - st.notOk(isTypedArray(NaN), 'NaN is not typed array'); - st.notOk(isTypedArray(Infinity), 'Infinity is not typed array'); - st.end(); - }); - - t.test('strings', function (st) { - st.notOk(isTypedArray('foo'), 'string primitive is not typed array'); - st.notOk(isTypedArray(Object('foo')), 'string object is not typed array'); - st.end(); - }); - - t.end(); -}); - -test('Functions', function (t) { - t.notOk(isTypedArray(function () {}), 'function is not typed array'); - t.end(); -}); - -test('Generators', { skip: generators.length === 0 }, function (t) { - forEach(generators, function (genFn) { - t.notOk(isTypedArray(genFn), 'generator function ' + inspect(genFn) + ' is not typed array'); - }); - t.end(); -}); - -test('Arrow functions', { skip: !arrowFn }, function (t) { - t.notOk(isTypedArray(arrowFn), 'arrow function is not typed array'); - t.end(); -}); - -test('@@toStringTag', { skip: !hasToStringTag }, function (t) { - forEach(typedArrayNames, function (typedArray) { - // @ts-expect-error - if (typeof global[typedArray] === 'function') { - // @ts-expect-error - var fakeTypedArray = []; - // @ts-expect-error - fakeTypedArray[Symbol.toStringTag] = typedArray; - // @ts-expect-error - t.notOk(isTypedArray(fakeTypedArray), 'faked ' + typedArray + ' is not typed array'); - } else { - t.comment('# SKIP ' + typedArray + ' is not supported'); - } - }); - t.end(); -}); - -test('non-Typed Arrays', function (t) { - t.notOk(isTypedArray([]), '[] is not typed array'); - t.end(); -}); - -/** @typedef {Int8ArrayConstructor | Uint8ArrayConstructor | Uint8ClampedArrayConstructor | Int16ArrayConstructor | Uint16ArrayConstructor | Int32ArrayConstructor | Uint32ArrayConstructor | Float32ArrayConstructor | Float64ArrayConstructor | BigInt64ArrayConstructor | BigUint64ArrayConstructor} TypedArrayConstructor */ - -test('Typed Arrays', function (t) { - forEach(typedArrayNames, function (typedArray) { - // @ts-expect-error - /** @type {TypedArrayConstructor} */ var TypedArray = global[typedArray]; - if (isCallable(TypedArray)) { - var arr = new TypedArray(10); - t.ok(isTypedArray(arr), 'new ' + typedArray + '(10) is typed array'); - } else { - t.comment('# SKIP ' + typedArray + ' is not supported'); - } - }); - t.end(); -}); diff --git a/tsconfig.json b/tsconfig.json deleted file mode 100644 index ac228e2..0000000 --- a/tsconfig.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "@ljharb/tsconfig", - "exclude": [ - "coverage", - ], -}