Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add bindElementToQueries utility function for libraries using t…
…his API (#18) * Add bindQueriesToElement utility function for libraries using this API * Add documentation and update contributors * Rename to bindElementToQueries as this seems to be more appropriate Closes #17
- Loading branch information
Showing
5 changed files
with
34 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import * as queries from './queries' | ||
|
||
function bindElementToQueries(element) { | ||
return Object.entries(queries).reduce( | ||
(helpers, [key, fn]) => { | ||
helpers[key] = fn.bind(null, element) | ||
return helpers | ||
}, | ||
{}, | ||
) | ||
} | ||
|
||
export {bindElementToQueries} |
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