Registry / testing / x-is-array

x-is-array

JSON →
library0.1.0jsnpmunverified

x-is-array is a lightweight, single-purpose JavaScript utility designed solely to determine if a given value is an array. It is currently at version 0.1.0 and, given its stable and minimal functionality, does not follow a frequent release cadence, as its core logic is well-established and rarely requires updates. Its key differentiator is its explicit existence as a standalone npm package for environments where a dedicated import might be preferred over direct usage of the built-in `Array.isArray()`, though they achieve the same result. It's often used in older CommonJS environments or as a simple dependency in utility libraries. This package serves as a direct alternative to `Array.isArray()` for compatibility or stylistic reasons in specific project setups.

npm install x-is-array
INSTALL
IMPORT
SIG · X-IS-ARRAY
X
x-is-array
testingjavascriptv0.1.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

isArray
import isArray from 'x-is-array';
import { isArray } from 'x-is-array';
The package exports a single function as its default export, hence a default import is correct in ESM.
isArray
const isArray = require('x-is-array');
This is the primary and most common usage pattern for this package in CommonJS environments.
Type Checking
import isArray from 'x-is-array'; // In TypeScript, `isArray` will correctly narrow types if used as a type guard.
While primarily a runtime check, TypeScript users can leverage its type-guarding capabilities for conditional type narrowing.

Demonstrates how to import and use `x-is-array` to check various data types for array status, including type narrowing.

import isArray from 'x-is-array'; console.log('Testing various values with x-is-array:'); console.log('[] is array:', isArray([])); console.log('[1, 2, 3] is array:', isArray([1, 2, 3])); console.log('"hello" is array:', isArray("hello")); console.log('"" is array:', isArray("")); console.log('9 is array:', isArray(9)); console.log('true is array:', isArray(true)); console.log('false is array:', isArray(false)); console.log('new Date() is array:', isArray(new Date())); console.log('{} is array:', isArray({})); console.log('{ a: 1 } is array:', isArray({ a: 1 })); console.log('null is array:', isArray(null)); console.log('undefined is array:', isArray(undefined)); // Demonstrating type narrowing in TypeScript context function processValue(value: unknown) { if (isArray(value)) { console.log(`The value ${JSON.stringify(value)} is an array with length ${value.length}.`); // 'value' is now type 'any[]' or 'unknown[]' depending on TS config } else { console.log(`The value ${JSON.stringify(value)} is not an array.`); } } processValue([1, 2]); processValue('not an array');
Debug
Known issues
gotchaPrefer `Array.isArray()` over `x-is-array` for most modern environments. `Array.isArray()` is a native JavaScript method available since ES5, offering universal browser and Node.js support without introducing an external dependency.
fix
Replace `import isArray from 'x-is-array';` with direct usage of `Array.isArray()` or `const isArray = Array.isArray;` for consistency.
affects: >=0.1.0
gotchaWhile functionally identical to `Array.isArray()`, using `x-is-array` introduces a minor performance overhead due to module loading and an additional function call layer compared to the native implementation. This difference is usually negligible but can be a factor in extremely performance-sensitive code paths.
fix
For optimal performance in critical sections, use the native `Array.isArray()` method directly.
affects: >=0.1.0
gotchaThe package has been at version 0.1.0 since its inception. While stable, this indicates a lack of active development or updates, which might be a concern for projects requiring actively maintained dependencies or specific new features (though unlikely for a simple array check).
fix
Evaluate project needs; for a simple array check, the lack of updates is often not an issue, but consider alternatives if active maintenance is a strict requirement.
affects: >=0.1.0
Errors
Common errors & fixes
TypeError: isArray is not a function
Attempting to destructure `isArray` from `x-is-array` (e.g., `import { isArray } from 'x-is-array';`) instead of using a default import.
fix
Ensure `isArray` is imported as a default export: `import isArray from 'x-is-array';` in ESM or `const isArray = require('x-is-array');` in CommonJS.
ReferenceError: require is not defined
Attempting to use `require('x-is-array')` in an ES Module context without a compatible bundler or Node.js configuration for CommonJS interop.
fix
If in an ES Module file (`.mjs` or `type: "module"` in `package.json`), use `import isArray from 'x-is-array';`. If in a browser, ensure a bundler like Webpack or Rollup is configured to handle CommonJS modules.
Upgrade
Version history
0.1.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
14 hits · last 30 days
node
12
Resources
x-is-array — npm install x-is-array · libregistry