« get me outta code hell

inputSoupyFind.js « wiki-data « composite « data « src - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data/composite/wiki-data/inputSoupyFind.js
blob: 020f49908e2d41f9ccd3bfd4138d97c7f2f4005e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import {input} from '#composite';
import {anyOf, isFunction, isString} from '#validators';

function inputSoupyFind() {
  return input({
    validate:
      anyOf(
        isFunction,
        val => {
          isString(val);

          if (!val.startsWith('_soupyFind:')) {
            throw new Error(`Expected soupyFind.input() token`);
          }

          return true;
        }),
  });
}

inputSoupyFind.input = key =>
  input.value('_soupyFind:' + key);

export default inputSoupyFind;

export function getSoupyFindInputKey(value) {
  return value.slice('_soupyFind:'.length);
}