├── .gitignore ├── .github ├── FUNDING.yml └── workflows │ ├── node-pretest.yml │ ├── require-allow-edits.yml │ ├── node-tens.yml │ ├── node-aught.yml │ └── rebase.yml ├── Makefile ├── CONTRIBUTING.md ├── .eslintrc ├── index.js ├── renovate.json ├── SECURITY.md ├── .travis.yml ├── component.json ├── tea.yaml ├── LICENSE ├── test.js ├── package.json └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | tidelift: "npm/isarray" 2 | patreon: juliangruber 3 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | 2 | test: 3 | @node_modules/.bin/tape test.js 4 | 5 | .PHONY: test 6 | 7 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | We don't expect to accept any contributions, because this project is considered done and serves legacy purposes only 2 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | 4 | "extends": "@ljharb", 5 | 6 | "rules": { 7 | "indent": ["error", 2], 8 | }, 9 | } 10 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var toString = {}.toString; 4 | 5 | module.exports = Array.isArray || function (arr) { 6 | return toString.call(arr) === '[object Array]'; 7 | }; 8 | -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json", 3 | "extends": [ 4 | "config:base", 5 | ":preserveSemverRanges" 6 | ], 7 | "ignoreDeps": ["eslint"] 8 | } 9 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | ## Security contact information 2 | 3 | To report a security vulnerability, please use the 4 | [Tidelift security contact](https://tidelift.com/security). 5 | Tidelift will coordinate the fix and disclosure. -------------------------------------------------------------------------------- /.github/workflows/node-pretest.yml: -------------------------------------------------------------------------------- 1 | name: 'Tests: pretest/posttest' 2 | 3 | on: [pull_request, push] 4 | 5 | permissions: 6 | contents: read 7 | 8 | jobs: 9 | tests: 10 | uses: ljharb/actions/.github/workflows/pretest.yml@main 11 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | arch: 3 | - amd64 4 | - ppc64le 5 | sudo: false 6 | node_js: 7 | - "node" 8 | - "10" 9 | - "8" 10 | - "6" 11 | cache: npm 12 | os: 13 | - osx 14 | - precise 15 | - xenial 16 | - windows 17 | script: 18 | - npm test 19 | notifications: 20 | email: 21 | on_success: never 22 | on_failure: never 23 | 24 | -------------------------------------------------------------------------------- /.github/workflows/require-allow-edits.yml: -------------------------------------------------------------------------------- 1 | name: Require “Allow Edits” 2 | 3 | on: [pull_request_target] 4 | 5 | permissions: 6 | contents: read 7 | 8 | jobs: 9 | _: 10 | permissions: 11 | pull-requests: read # for ljharb/require-allow-edits to check 'allow edits' on PR 12 | 13 | name: "Require “Allow Edits”" 14 | 15 | runs-on: ubuntu-latest 16 | 17 | steps: 18 | - uses: ljharb/require-allow-edits@13f90bc8cc5de000f2b44a0e2c3a11d108e8cd9f # @main 19 | -------------------------------------------------------------------------------- /.github/workflows/node-tens.yml: -------------------------------------------------------------------------------- 1 | name: 'Tests: node.js >= 10' 2 | 3 | on: [pull_request, push] 4 | 5 | permissions: 6 | contents: read 7 | 8 | jobs: 9 | tests: 10 | uses: ljharb/actions/.github/workflows/node.yml@main 11 | with: 12 | range: '>= 10' 13 | type: majors 14 | command: npm run tests-only 15 | 16 | node: 17 | name: 'node >= 10' 18 | needs: [tests] 19 | runs-on: ubuntu-latest 20 | steps: 21 | - run: 'echo tests completed' 22 | -------------------------------------------------------------------------------- /.github/workflows/node-aught.yml: -------------------------------------------------------------------------------- 1 | name: 'Tests: node.js < 10' 2 | 3 | on: [pull_request, push] 4 | 5 | permissions: 6 | contents: read 7 | 8 | jobs: 9 | tests: 10 | uses: ljharb/actions/.github/workflows/node.yml@main 11 | with: 12 | range: '> 0.6 < 10' 13 | type: minors 14 | command: npm run tests-only 15 | 16 | node: 17 | name: 'node < 10' 18 | needs: [tests] 19 | runs-on: ubuntu-latest 20 | steps: 21 | - run: 'echo tests completed' 22 | -------------------------------------------------------------------------------- /component.json: -------------------------------------------------------------------------------- 1 | { 2 | "name" : "isarray", 3 | "description" : "Array#isArray for older browsers", 4 | "version" : "0.0.1", 5 | "repository" : "juliangruber/isarray", 6 | "homepage": "https://github.com/juliangruber/isarray", 7 | "main" : "index.js", 8 | "scripts" : [ 9 | "index.js" 10 | ], 11 | "dependencies" : {}, 12 | "keywords": ["browser","isarray","array"], 13 | "author": { 14 | "name": "Julian Gruber", 15 | "email": "mail@juliangruber.com", 16 | "url": "http://juliangruber.com" 17 | }, 18 | "license": "MIT" 19 | } 20 | -------------------------------------------------------------------------------- /.github/workflows/rebase.yml: -------------------------------------------------------------------------------- 1 | name: Automatic Rebase 2 | 3 | on: [pull_request_target] 4 | 5 | permissions: 6 | contents: read 7 | 8 | jobs: 9 | _: 10 | permissions: 11 | contents: write # for ljharb/rebase to push code to rebase 12 | pull-requests: read # for ljharb/rebase to get info about PR 13 | 14 | name: "Automatic Rebase" 15 | 16 | runs-on: ubuntu-latest 17 | 18 | steps: 19 | - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6 20 | - uses: ljharb/rebase@3f30d8c115145dcc562f01582f59fbeefe77c707 # @master 21 | env: 22 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 23 | -------------------------------------------------------------------------------- /tea.yaml: -------------------------------------------------------------------------------- 1 | # https://tea.xyz/what-is-this-file 2 | # 3 | # DO NOT REMOVE OR EDIT THIS WARNING: 4 | # 5 | # This file is auto-generated by the TEA app. It is intended to validate ownership of your repository. 6 | # DO NOT commit this file or accept any PR if you don't know what this is. 7 | # We are aware that spammers will try to use this file to try to profit off others' work. 8 | # We take this very seriously and will take action against any malicious actors. 9 | # 10 | # If you are not the owner of this repository, and someone maliciously opens a commit with this file 11 | # please report it to us at support@tea.xyz. 12 | # 13 | # A constitution without this header is invalid. 14 | --- 15 | version: 2.0.0 16 | codeOwners: 17 | - '0x50b4EC9Ec70BA2Ea1b95eC9EB0C64b46f13595f7' 18 | - '0x8D279ED5772D655aF6568373575124a6eFe40A30' 19 | quorum: 1 20 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2013 Julian Gruber 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var isArray = require('./'); 4 | var test = require('tape'); 5 | 6 | var nativeIsArray = Array.isArray; 7 | 8 | test('is array (only polyfill)', function (t) { 9 | delete Array.isArray; 10 | t.ok(isArray([])); 11 | t.notOk(isArray({})); 12 | t.notOk(isArray(null)); 13 | t.notOk(isArray(false)); 14 | t.notOk(isArray('')); 15 | t.notOk(isArray('42')); 16 | t.notOk(isArray(42)); 17 | t.notOk(isArray(34.00)); 18 | t.notOk(isArray(123e-5)); 19 | t.notOk(isArray('[]')); 20 | t.notOk(isArray(undefined)); 21 | t.notOk(isArray(function () {})); 22 | 23 | var obj = {}; 24 | obj[0] = true; 25 | t.notOk(isArray(obj)); 26 | 27 | var arr = []; 28 | arr.foo = 'bar'; 29 | t.ok(isArray(arr)); 30 | 31 | t.end(); 32 | }); 33 | 34 | test('is array (native)', function (t) { 35 | Array.isArray = nativeIsArray; 36 | t.ok(isArray([])); 37 | t.notOk(isArray({})); 38 | t.notOk(isArray(null)); 39 | t.notOk(isArray(false)); 40 | t.notOk(isArray('')); 41 | t.notOk(isArray('42')); 42 | t.notOk(isArray(42)); 43 | t.notOk(isArray(34.00)); 44 | t.notOk(isArray(123e-5)); 45 | t.notOk(isArray('[]')); 46 | t.notOk(isArray(undefined)); 47 | t.notOk(isArray(function () {})); 48 | 49 | var obj = {}; 50 | obj[0] = true; 51 | t.notOk(isArray(obj)); 52 | 53 | var arr = []; 54 | arr.foo = 'bar'; 55 | t.ok(isArray(arr)); 56 | 57 | t.end(); 58 | }); 59 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "isarray", 3 | "description": "Array#isArray for older browsers", 4 | "version": "2.0.5", 5 | "repository": { 6 | "type": "git", 7 | "url": "ssh://github.com/juliangruber/isarray.git" 8 | }, 9 | "homepage": "https://github.com/juliangruber/isarray", 10 | "main": "index.js", 11 | "files": [ 12 | "index.js" 13 | ], 14 | "devDependencies": { 15 | "@ljharb/eslint-config": "^22.0.0", 16 | "eslint": "=8.8.0", 17 | "tape": "^5.6.0" 18 | }, 19 | "keywords": [ 20 | "browser", 21 | "isarray", 22 | "array" 23 | ], 24 | "author": { 25 | "name": "Julian Gruber", 26 | "email": "mail@juliangruber.com", 27 | "url": "http://juliangruber.com" 28 | }, 29 | "license": "MIT", 30 | "testling": { 31 | "files": "test.js", 32 | "browsers": [ 33 | "ie/8..latest", 34 | "firefox/17..latest", 35 | "firefox/nightly", 36 | "chrome/22..latest", 37 | "chrome/canary", 38 | "opera/12..latest", 39 | "opera/next", 40 | "safari/5.1..latest", 41 | "ipad/6.0..latest", 42 | "iphone/6.0..latest", 43 | "android-browser/4.2..latest" 44 | ] 45 | }, 46 | "scripts": { 47 | "pretest": "npm run lint", 48 | "lint": "eslint --ext=mjs,js .", 49 | "tests-only": "tape test.js", 50 | "test": "npm run tests-only", 51 | "posttest": "npx npm@'>=10.2' audit --production" 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # isarray 3 | 4 | `Array#isArray` for older browsers and deprecated Node.js versions. 5 | 6 | [![github actions][actions-image]][actions-url] 7 | [![downloads](https://img.shields.io/npm/dm/isarray.svg)](https://www.npmjs.org/package/isarray) 8 | [![openssf](https://api.securityscorecards.dev/projects/github.com/juliangruber/isarray/badge)](https://deps.dev/npm/isarray) 9 | [![OpenSSF Best Practices](https://www.bestpractices.dev/projects/6288/badge)](https://www.bestpractices.dev/projects/6288) 10 | 11 | __Just use Array.isArray directly__, unless you need to support those older versions. 12 | 13 | ## Usage 14 | 15 | ```js 16 | var isArray = require('isarray'); 17 | 18 | console.log(isArray([])); // => true 19 | console.log(isArray({})); // => false 20 | ``` 21 | 22 | ## API 23 | 24 | [Array#isArray](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray) 25 | 26 | ## Installation 27 | 28 | With [npm](https://npmjs.org) do 29 | 30 | ```bash 31 | $ npm install isarray 32 | ``` 33 | 34 | Then bundle for the browser with 35 | [browserify](https://github.com/substack/node-browserify). 36 | 37 | ## Sponsors 38 | 39 | This module is proudly supported by my [Sponsors](https://github.com/juliangruber/sponsors)! 40 | 41 | Do you want to support modules like this to improve their quality, stability and weigh in on new features? Then please consider donating to my [Patreon](https://www.patreon.com/juliangruber). Not sure how much of my modules you're using? Try [feross/thanks](https://github.com/feross/thanks)! 42 | 43 | ## Security contact information 44 | 45 | To report a security vulnerability, please use the 46 | [Tidelift security contact](https://tidelift.com/security). 47 | Tidelift will coordinate the fix and disclosure. 48 | 49 | [actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/juliangruber/isarray 50 | [actions-url]: https://github.com/juliangruber/isarray/actions 51 | --------------------------------------------------------------------------------