-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into @chrispader/feat/use-json-patch-for-merge
- Loading branch information
Showing
10 changed files
with
58 additions
and
330 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
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,29 @@ | ||
import _ from 'underscore'; | ||
|
||
/** | ||
* Returns true if the haystack begins with the needle | ||
* | ||
* @param {String} haystack The full string to be searched | ||
* @param {String} needle The case-sensitive string to search for | ||
* @return {Boolean} Returns true if the haystack starts with the needle. | ||
*/ | ||
function startsWith(haystack, needle) { | ||
return _.isString(haystack) | ||
&& _.isString(needle) | ||
&& haystack.startsWith(needle); | ||
} | ||
|
||
/** | ||
* Checks if parameter is a string or function. | ||
* If it is a string, then we will just return it. | ||
* If it is a function, then we will call it with | ||
* any additional arguments and return the result. | ||
* | ||
* @param {String|Function} parameter | ||
* @returns {*} | ||
*/ | ||
function result(parameter, ...args) { | ||
return _.isFunction(parameter) ? parameter(...args) : parameter; | ||
} | ||
|
||
export {startsWith, result}; |
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.