collect.js
Advanced tools
Comparing version 1.0.1 to 1.0.2
{ | ||
"name": "collect.js", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Convenient and dependency free wrapper for working with arrays and objects.", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -170,3 +170,3 @@ # <img src="https://raw.githubusercontent.com/ecrmnn/collect.js/master/collectjs.jpg" alt="collect.js"> | ||
#### ``diff()`` | ||
The diff method compares the collection against another collection or a plain PHP array based on its values. This method will return the values in the original collection that are not present in the given collection: | ||
The diff method compares the collection against another collection or a plain array based on its values. This method will return the values in the original collection that are not present in the given collection: | ||
```js | ||
@@ -183,3 +183,3 @@ const collection = collect([1, 2, 3, 4, 5]); | ||
#### ``diffKeys()`` | ||
The diffKeys method compares the collection against another collection or a plain PHP array based on its keys. This method will return the key / value pairs in the original collection that are not present in the given collection: | ||
The diffKeys method compares the collection against another collection or a plain object based on its keys. This method will return the key / value pairs in the original collection that are not present in the given collection: | ||
```js | ||
@@ -186,0 +186,0 @@ const collection = collect({ |
@@ -264,2 +264,6 @@ 'use strict'; | ||
Collection.prototype.diff = function (values) { | ||
if (values instanceof Collection) { | ||
values = values.all(); | ||
} | ||
const collection = this.items.filter(function (item) { | ||
@@ -266,0 +270,0 @@ return values.indexOf(item) === -1; |
@@ -505,2 +505,6 @@ 'use strict'; | ||
expect(collection.all()).to.eql([1, 2, 3, 4, 5]); | ||
const diffCollection = collect([1, 2, 3, 9]); | ||
const diff2 = collection.diff(diffCollection); | ||
expect(diff2.all()).to.eql([4, 5]); | ||
}); | ||
@@ -833,2 +837,6 @@ | ||
expect(collection.all()).to.eql(data); | ||
const diffCollection = collect(diff); | ||
const _diff2 = collection.diffKeys(diffCollection); | ||
expect(_diff2.all()).to.eql({a: 'a', c: 'c'}); | ||
}); | ||
@@ -835,0 +843,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
205566
1758