Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add fallback for unstructured Jamie Oliver recipes
Note: misses proper white-space handling.
- Loading branch information
1 parent
969945d
commit 1a44b99
Showing
2 changed files
with
46 additions
and
1 deletion.
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,8 @@ | ||
/** | ||
* Higher-order function, creating a function that will execute its given fallback in case it yields | ||
* no results. | ||
*/ | ||
module.exports = fallbackFn => primaryFn => (...args) => { | ||
const result = primaryFn(...args); | ||
return result.length ? result : fallbackFn(...args); | ||
}; |