diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2025-01-11 17:05:25 -0400 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2025-01-11 17:05:25 -0400 |
commit | 13f91d9ff89dcf0ca8b7895b21b1e0cf43df38f9 (patch) | |
tree | f25a02cd225c505ec8d1b16f5f3b59e77f8fd4a8 /src/reverse.js | |
parent | 3cc050187760c758c4760121281ff9a7e0b626f5 (diff) |
find, reverse: fr.bind + bindReverse
Diffstat (limited to 'src/reverse.js')
-rw-r--r-- | src/reverse.js | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/reverse.js b/src/reverse.js index 0f235369..324cbabe 100644 --- a/src/reverse.js +++ b/src/reverse.js @@ -1,5 +1,13 @@ import * as fr from './find-reverse.js'; +function reverseHelper(spec) { + const cache = new WeakMap(); + + return (thing, data) => { + return ({spec, from: thing, data: data.length}); + }; +} + const hardcodedReverseSpecs = {}; const findReverseHelperConfig = { @@ -28,5 +36,12 @@ export function findReverseSpec(key) { export default fr.tokenProxy({ findSpec: findReverseSpec, - prepareBehavior: spec => from => ({spec, from}), + prepareBehavior: reverseHelper, }); + +export function bindReverse(wikiData, opts) { + return fr.bind(wikiData, opts, { + getAllSpecs: getAllReverseSpecs, + prepareBehavior: reverseHelper, + }); +} |