Skip to content

Commit

Permalink
Adds diffUsing method
Browse files Browse the repository at this point in the history
  • Loading branch information
ecrmnn committed Mar 29, 2023
1 parent 2b3dd64 commit 3667c8b
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 3 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,7 @@ diff.all();
// [{ name: 'Alice', age: 25 }]
```


#### `doesntContain()`

The `doesntContain` method determines whether the collection does not contain a given item. You may pass a closure to the `doesntContain` method to determine if an element does not exist in the collection matching a given truth test:
Expand Down Expand Up @@ -3355,4 +3356,4 @@ PRs are welcomed to this project, and help is needed in order to keep up with th

### License

MIT © [Daniel Eckermann](https://danieleckermann.com)
MIT © [Daniel Eckermann](https://danieleckermann.com)
14 changes: 13 additions & 1 deletion build/collect.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/collect.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Collection.prototype.dd = require('./methods/dd');
Collection.prototype.diff = require('./methods/diff');
Collection.prototype.diffAssoc = require('./methods/diffAssoc');
Collection.prototype.diffKeys = require('./methods/diffKeys');
Collection.prototype.diffUsing = require('./methods/diffUsing');
Collection.prototype.doesntContain = require('./methods/doesntContain');
Collection.prototype.dump = require('./methods/dump');
Collection.prototype.duplicates = require('./methods/duplicates');
Expand Down
8 changes: 8 additions & 0 deletions test/methods/diffUsing_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ module.exports = (it, expect, collect) => {
expect(collection.all()).to.eql(['fr', 'en_gb', 'hr']);
});

it('should compare with null', () => {
const collection = collect(['fr', 'en_gb', 'hr']);

const diff = collection.diffUsing(null, (a, b) => a.localeCompare(b));

expect(diff.all()).to.eql(collection.all());
});

it('should compare the collection against another collection using on a callback', () => {
const collection = collect([
{ name: 'Alice', age: 25 },
Expand Down

0 comments on commit 3667c8b

Please sign in to comment.