Skip to content

[Replacement]: is-arrayish #622

@dreyfus92

Description

@dreyfus92

Package to replace

is-arrayish

Suggested replacement(s)

Array.isArray() (native)

Manifest type

micro-utility (tiny utility replaceable with native code or removal)

Rationale

is-arrayish checks if an object can be used like an Array either a true array or an object with an Array prototype in its chain ({__proto__: []}). Both cases are fully covered by native JavaScript:

  • Array.isArray() handles direct arrays and cross-realm arrays (e.g. from vm contexts or iframes)
  • obj instanceof Array covers the prototype-chain case ({__proto__: []}) for same-realm objects

Availability

Built-in since ES5 / Node.js 0.1.101. No install required.

Code example (optional)

// Before
const isArrayish = require('is-arrayish')

isArrayish([])               // true
isArrayish({ __proto__: [] }) // true
isArrayish({})               // false

// After — sufficient for most cases
Array.isArray([])               // true
Array.isArray({ __proto__: [] }) // false — see note above
Array.isArray({})               // false

// After — exact drop-in replacement if prototype-chain behaviour is needed
function isArrayish(obj) {
  if (obj == null) return false
  return Array.isArray(obj) || obj instanceof Array
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    acceptedUsed to signal if a suggested replacement has been accepted.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions