kalagin / fp-multik

JS/TS lightweight value-multimethod util

Home Page:https://github.com/lulldev/fp-multik/blob/main/README.md

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Placeholder for selector and predicate arguments

kalagin opened this issue · comments

implement placeholder like https://github.com/ramda/ramda/blob/v0.28.0/source/__.js

for skip unused variables.

before:

import multik from 'fp-multik';

const convertFile = multik(
  (filepath: string, format: string) => format,
  ['json', (format, filepath) => console.log(`Convert ${filepath} as JSON...`)],
  ['html', (format, filepath) => console.log(`Convert ${filepath} as HTML...`)],
  ['csv', (format, filepath) => console.log(`Convert ${filepath} as CSV...`)],
  [(format, filepath) => console.log(`Convert ${filepath} by default as TXT...`)],
);

convertFile('/Users/file1.data', 'json');

after:

import multik, { __ } from 'fp-multik';

const convertFile = multik(
  (filepath: string, format: string) => format,
  ['json', (__, filepath) => console.log(`Convert ${filepath} as JSON...`)],
  ['html', (__, filepath) => console.log(`Convert ${filepath} as HTML...`)],
  ['csv', (__, filepath) => console.log(`Convert ${filepath} as CSV...`)],
  [(__, filepath) => console.log(`Convert ${filepath} by default as TXT...`)],
);

convertFile('/Users/file1.data', 'json');

in progress