Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

array-util

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

array-util - npm Package Compare versions

Comparing version 0.1.1 to 0.1.3

3

lib/util.js

@@ -37,4 +37,5 @@ Array.prototype.equals = Array.prototype.compare = function equals(array) {

for (var j = i + 1; j < a.length; ++j) {
if (a[i] === a[j])
if (JSON.stringify(a[i]) === JSON.stringify(a[j])) {
a.splice(j--, 1);
}
}

@@ -41,0 +42,0 @@ }

{
"name": "array-util",
"version": "0.1.1",
"version": "0.1.3",
"description": "Array utils for misc. but useful things, so far just compares arrays",

@@ -5,0 +5,0 @@ "main": "./lib/util",

@@ -6,3 +6,3 @@ ArrayUtil

###Array.prototype.merge
>Uniquely merge two arrays. This only works with elements that are primitives
>Uniquely merge two arrays (even with object elements).

@@ -9,0 +9,0 @@ ###Array.prototype.equals

require('../lib/util.js');
var assert = require('chai').assert;
describe('Array',function(){
describe('#merge',function(){
it('Should contain values of both arrays after calling merge',function(){
var array = [1,2,3];
var array_2 = [3,4,5,6];
assert(array.merge(array_2).equals([1, 2, 3, 4, 5, 6]));
});
});
describe('Array', function() {
describe('#merge', function() {
it('Should contain values of both arrays after calling merge', function() {
var array = [1, 2, 3];
var array_2 = [3, 4, 5, 6];
assert(array.merge(array_2).equals([1, 2, 3, 4, 5, 6]));
});
it('Should properly and uniquely merge intersecting arrays with objects', function() {
var array = [{
name: 'John'
}, {
name: 'Jane'
}],
array2 = [{
name: 'John'
}, {
name: 'Fred'
}],
expected = [{
name: 'John'
}, {
name: 'Jane'
}, {
name: 'Fred'
}];
assert(array.merge(array2).equals(expected));
});
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc