kalagin/fp-multik

Predicate action as value

kalagin opened this issue · 0 comments

add user's choice possibility indicate value or function in predicate action

before:

import multik from 'fp-multik';

const greet = multik(
  (data) => data.lang,
  ["english", () => "Hello"),
  ["french", () => "Bonjour")
);

greet({ id: 1, lang: "french" }); // "Bonjour"

after:

import multik from 'fp-multik';

const greet = multik(
  (data) => data.lang,
  ["english", "Hello"),
  ["french",  "Bonjour")
);

greet({ id: 1, lang: "french" }); // "Bonjour"

or (valid situation):

import multik from 'fp-multik';

const greet = multik(
  (data) => data.lang,
  ["english", "Hello"),
  ["french",  () => "Bonjour")
);

greet({ id: 1, lang: "french" }); // "Bonjour"

please add tests for these cases