Skip to content

Commit

Permalink
add index.d.ts and declare it in package.json
Browse files Browse the repository at this point in the history
  • Loading branch information
Lordfirespeed committed Aug 24, 2024
1 parent 10406f9 commit 1660056
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
24 changes: 24 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
type CPSFn<
Callbacks extends Array<(...args: unknown[]) => void>
> = (...args: Callbacks) => void

type ChainFns<
FromCallbacks extends Array<(...args: unknown[]) => void>,
ToCallbacks extends Array<(...args: unknown[]) => void>,
> = {
[T in keyof FromCallbacks]?: (...args: Parameters<FromCallbacks[T]>) => CPSFn<ToCallbacks> | undefined
}

type CPS<
Callbacks extends Array<(...args: unknown[]) => void>
> = CPSFn<Callbacks> & {
chain<
ToCallbacks extends Array<(...args: unknown[]) => void>
>(...fns: ChainFns<Callbacks, ToCallbacks>): CPS<ToCallbacks>
}

declare function CPS<
Callbacks extends Array<(...args: unknown[]) => void>
>(fn: CPSFn<Callbacks>): CPS<Callbacks>

export { CPS, CPSFn }
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
"name": "cpsfy",
"description": "Tiny goodies for Continuation-Passing-Style functions",
"main": "index.js",
"types": "index.d.ts",
"files": [
"index.js",
"index.d.ts",
"utils.js"
],
"repository": "https://github.com/dmitriz/cpsfy.git",
Expand Down

0 comments on commit 1660056

Please sign in to comment.