arrows icon indicating copy to clipboard operation
arrows copied to clipboard

Improvements for compose

Open reggi opened this issue 6 years ago • 2 comments

Cool library! I've been hunting / trying to make a good compositional library with typescript support.

In my initial test here:

import { compose } from '@arrows/composition'
 
const addPrefixes = compose(
  (text: string) => `prefix1-${text}`,
  (text: string) => 3,
  (text: string) => `prefix2-${text}`,
)
 
addPrefixes('arrows') // -> "prefix1-prefix2-arrows"

Here are some thoughts on how to improve typing:

  1. The parameter type of addPrefixes should be string, because it's the parameter of the first function in compose.
  2. You can see above I have the 2nd function which returns 3 and the 4th which takes a string and that shouldn't be allowed.

reggi avatar Nov 18 '19 09:11 reggi

Thank you, I will look into that.

caderek avatar Nov 18 '19 12:11 caderek

@caderek "better late than never"

if this changes ok - i can fix pipe function next

ivklgn avatar Mar 28 '22 20:03 ivklgn