@phryxia/oof
TypeScript icon, indicating that this package has built-in type declarations

1.0.7 • Public • Published

oof!

oof is a tiny TypeScript library for functional programming utilities with type safety. When learning functional paradigm with JavaScript, you may feel some despair of typing pipe (or go) correctly.

API

// you only type once
const foo = oof((x: string) => x.length)
  .compose(num => num === 42)
  .compose(isTruthUnveiled => isTruthUnveiled ? () => console.log("I'm die. Thank you forever.") : () => {})

// you can call this directly
foo() // foo(x: string): () => void

// want to proceed more?
const bar = foo.compose()

Why?

// You're currently writing a nice composed function...
pipe(
  (value: string) => returnsSomeNiceComplexType(),
  // Parameter 'iWantNoImplicitAnyBeTrue' implicitly has an 'any' type (7006)
  (iWantNoImplicitAnyBeTrue) => butYouCantBecauseAboveTypeIsHell(),
)

// This is also verbose
// since most of the time you start with inner things
const result = pipe<[Do, I, Have, To, Declare, These, Always, QuestionMark]>(
  what,
  if,
  you,
  add,
  other,
  functions,
  somewhere,
  between,
  these // type error: Expected 8 arguments, but got 9 (2554)
)

// of course, this anyscript often ends up with 
// "Uncaught ReferenceError: peace is not defined"
result.peace()

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.0.70latest
1.0.401.0.4
1.0.301.0.3
1.0.201.0.2
1.0.101.0.1

Version History

VersionDownloads (Last 7 Days)Published
1.0.70
1.0.60
1.0.50
1.0.40
1.0.30
1.0.20
1.0.10

Package Sidebar

Install

npm i @phryxia/oof

Weekly Downloads

0

Version

1.0.7

License

MIT

Unpacked Size

4.1 kB

Total Files

12

Last publish

Collaborators

  • phryxia