Registry / data / array-difference

array-difference

JSON →
library0.0.2jsnpmunverified

The `array-difference` package, currently at version 0.0.2 and last published in 2020 (with a copyright date of 2013), provides a basic utility method for computing the symmetric difference between two arrays. It identifies elements present in one array but not the other. Originally designed to be compatible with AMD and CommonJS modules, it functions in both Node.js and browser environments of its era. This package is no longer actively maintained or developed. Modern JavaScript projects typically use native `Set` operations, `filter` with `includes`, or more feature-rich, actively maintained third-party libraries that offer advanced array comparison, custom comparison functions, and better performance for large datasets. Its key differentiator is its simplicity and small footprint, though this comes at the cost of modern features and ongoing support.

data
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.

This package is CommonJS-only and does not support ES Modules (`import`/`export`) due to its age and lack of maintenance. Attempting to use `import` will result in a `SyntaxError`.

const difference = require('array-difference');

Demonstrates how to import and use the `difference` function to find elements unique to two given arrays.

const difference = require('array-difference'); const array1 = [1, 2, 3, 'a', 'b']; const array2 = [2, 3, 4, 'b', 'c']; // Compute the symmetric difference: elements unique to array1 or array2 const diffResult = difference(array1, array2); console.log('Array 1:', array1); console.log('Array 2:', array2); console.log('Difference (elements unique to either array):', diffResult); // Expected output: [1, 4, 'a', 'c'] const array3 = [5, 6, 7]; const array4 = [6, 8]; console.log('Difference ([5, 6, 7], [6, 8]):', difference(array3, array4)); // Expected output: [5, 7, 8]
Debug
Known footguns
gotchaThe `array-difference` package is effectively abandoned. It has not been updated since 2020 and its core logic dates back to 2013. There will be no further bug fixes, performance improvements, or feature additions. Consider actively maintained alternatives or native JavaScript methods.
gotchaThis package is CommonJS-only. It does not support ES Modules (`import`/`export`) syntax, which is the standard for modern JavaScript development. Attempting to use `import` will lead to runtime errors in environments configured for ESM.
gotchaThe functionality provided by this package is limited to simple symmetric difference and can be replicated with native JavaScript array methods or `Set` objects, often with better performance and clearer intent. Its algorithm may not be optimized for very large arrays.
gotchaDue to its unmaintained status, there is no guarantee of compatibility with newer Node.js versions or browser environments, and it may contain unpatched vulnerabilities, although unlikely for such a simple utility.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
17 hits · last 30 days
bytedance
5
gptbot
4
ahrefsbot
4
script
1
Resources