-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from hckrnews/feature/array-with-object-diff
Feature/array with object diff
- Loading branch information
Showing
10 changed files
with
3,379 additions
and
5,075 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
16.14.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,6 @@ dist: trusty | |
addons: | ||
language: node_js | ||
node_js: | ||
- "10" | ||
- "12" | ||
- "14" | ||
- "16" | ||
- "18" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,21 @@ | ||
import toJson from './toJson.js'; | ||
|
||
export default function intersect(original, array, multi) { | ||
return original.filter((value) => { | ||
const jsonValue = toJson(array); | ||
|
||
if (multi) { | ||
const found = array | ||
.map((item) => JSON.stringify(item)) | ||
.reduce((accumulator, currentValue) => { | ||
if (currentValue.indexOf(JSON.stringify(value)) >= 0) { | ||
return accumulator + 1; | ||
} | ||
const found = jsonValue.reduce((accumulator, currentValue) => { | ||
if (currentValue.indexOf(JSON.stringify(value)) >= 0) { | ||
return accumulator + 1; | ||
} | ||
|
||
return accumulator; | ||
}, 0); | ||
return accumulator; | ||
}, 0); | ||
|
||
return found === array.length; | ||
} | ||
|
||
return ( | ||
array | ||
.map((item) => JSON.stringify(item)) | ||
.indexOf(JSON.stringify(value)) >= 0 | ||
); | ||
return jsonValue.indexOf(JSON.stringify(value)) >= 0; | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default (items) => items.map((item) => JSON.stringify(item)); |