index.js.flow 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // @flow
  2. // array.js
  3. declare export function cons<A>(val: A, arr: Array<A>): Array<A>
  4. declare export function append<A>(val: A, arr: Array<A>): Array<A>
  5. declare export function drop<A>(val: number, arr: Array<A>): Array<A>
  6. declare export function tail<A>(arr: Array<A>): Array<A>
  7. declare export function copy<A>(arr: Array<A>): Array<A>
  8. declare export function map<A, B>(f: (val: A) => B, arr: Array<A>): Array<B>
  9. declare export function reduce<A, B>(f: (acc: A, val: B) => A, seed: A, arr: Array<B>): A
  10. declare export function replace<A>(toReplace: A, i: number, arr: Array<A>): Array<A>
  11. declare export function remove<A>(i: number, arr: Array<A>): Array<A>
  12. declare export function removeAll<A>(f: (val: A) => boolean, arr: Array<A>): Array<A>
  13. declare export function findIndex<A>(item: A, arr: Array<A>): number
  14. declare export function isArrayLike(x: any): boolean
  15. // function.js
  16. declare export function id<A>(A): A
  17. declare export function compose<A, B, C>(f: (B) => C, g: (A) => B): (A) => C
  18. declare export function apply<A, B>(f: (A) => B, A): B
  19. interface CurriedFunction2<A, B, C> {
  20. (): CurriedFunction2<A, B, C>,
  21. (A): (B) => C,
  22. (A, B): C
  23. }
  24. interface CurriedFunction3<A, B, C, D> {
  25. (): CurriedFunction3<A, B, C, D>,
  26. (A): CurriedFunction2<B, C, D>,
  27. (A, B): (C) => D,
  28. (A, B, C): D
  29. }
  30. interface CurriedFunction4<A, B, C, D, E> {
  31. (): CurriedFunction4<A, B, C, D, E>,
  32. (A): CurriedFunction3<B, C, D, E>,
  33. (A, B): CurriedFunction2<C, D, E>,
  34. (A, B, C): (D) => E,
  35. (A, B, C, D): E
  36. }
  37. declare export function curry2<A, B, C>(f: (A, B) => C): CurriedFunction2<A, B, C>
  38. declare export function curry3<A, B, C, D>(f: (A, B, C) => D): CurriedFunction3<A, B, C, D>
  39. declare export function curry4<A, B, C, D, E>(f: (A, B, C, D) => E): CurriedFunction4<A, B, C, D, E>