-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: strf-9673 Remove lodash from paper-handlebars deps (#237)
- Loading branch information
Showing
13 changed files
with
127 additions
and
136 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/** | ||
* Recursively compare objects | ||
*/ | ||
const typeOf = require("./kindOf"); | ||
|
||
function deepMatches(val, value) { | ||
if (typeOf(val) === "object") { | ||
if (Array.isArray(val) && Array.isArray(value)) { | ||
return matchArray(val, value); | ||
} else { | ||
return matchObject(val, value); | ||
} | ||
} else { | ||
return isMatch(val, value); | ||
} | ||
} | ||
|
||
function containsMatch(array, value) { | ||
var len = array.length; | ||
var i = -1; | ||
|
||
while (++i < len) { | ||
if (deepMatches(array[i], value)) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
function matchArray(arr, value) { | ||
var len = value.length; | ||
var i = -1; | ||
|
||
while (++i < len) { | ||
if (!containsMatch(arr, value[i])) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
|
||
function matchObject(obj, value) { | ||
for (var key in value) { | ||
if (value.hasOwnProperty(key)) { | ||
if (deepMatches(obj[key], value[key]) === false) { | ||
return false; | ||
} | ||
} | ||
} | ||
return true; | ||
} | ||
|
||
function isMatch(target, val) { | ||
return target === val; | ||
} | ||
|
||
module.exports = deepMatches; |
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
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
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
Oops, something went wrong.