You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
992 B
Markdown
30 lines
992 B
Markdown
# Swiss Army Knifey Ramda
|
|
|
|
Tools you could have gotten somewhere else, but you still decided to go this way.
|
|
|
|
## Ramda Compose With Promise
|
|
|
|
Added typings to composeWithPromise
|
|
|
|
```ts
|
|
it('should await and return a composed result', async function() {
|
|
const paramToProp = (param: string) => ({ param });
|
|
const sleepingSentence = (s: number) => async ({ param }: { param: string }) => {
|
|
const d1 = new Date();
|
|
await sleep(s, TimeUnit.second);
|
|
const d2 = new Date();
|
|
return `a_[${param}], slept for: ${d2.getTime() - d1.getTime()}`;
|
|
};
|
|
const toUp = async (param: string) => param.toUpperCase();
|
|
const removeStart = async (param: string) => param.slice(1);
|
|
const composed = composeWithPromise(
|
|
removeStart,
|
|
sleepingSentence(1),
|
|
paramToProp,
|
|
toUp,
|
|
sleepingSentence(2),
|
|
paramToProp
|
|
);
|
|
return expect(composed('hey')).to.eventually.match(/_\[A_\[HEY\], SLEPT FOR: \d{4}\], slept for: \d{3,4}$/g);
|
|
});
|
|
``` |