-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* all * assemble * Works but dangerous * Working! * Even better * assembleP * assocWith * assocWithP * backoff * Batch * combine * combineAll * combineAllP * combineP * combineWith * Dep shuffle * Comment * combineWithP * Better combined * convergeP * Move ZipArgs * Better convergeP * copyPath * copyProp * evolveP * juxtP * mapP * move * Oops * normalizeBy * onSuccess * onSuccessP * overP * promisify * reject * rename * renameAll * renamePath * renamePick * resolve * tapP * unlessP * useWithP * validate * validateWith * whenP * Wildcard export * s/lib/src/ * LOUD exports * Browser * Wildcard again * Fix commands * Bump @types/ramda * v2 changes * Bump
- Loading branch information
1 parent
6f0147f
commit c46cfae
Showing
83 changed files
with
2,573 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
export { default as all } from './types/all' | ||
export { default as assemble } from './types/assemble' | ||
export { default as assembleP } from './types/assembleP' | ||
export { default as assocWith } from './types/assocWith' | ||
export { default as assocWithP } from './types/assocWithP' | ||
export { default as backoff } from './types/backoff' | ||
export { default as batch } from './types/batch' | ||
export { default as combine } from './types/combine' | ||
export { default as combineAll } from './types/combineAll' | ||
export { default as combineAllP } from './types/combineAllP' | ||
export { default as combineP } from './types/combineP' | ||
export { default as combineWith } from './types/combineWith' | ||
export { default as combineWithP } from './types/combineWithP' | ||
export { default as convergeP } from './types/convergeP' | ||
export { default as copyPath } from './types/copyPath' | ||
export { default as copyProp } from './types/copyProp' | ||
export { default as evolveP } from './types/evolveP' | ||
export { default as juxtP } from './types/juxtP' | ||
export { default as mapP } from './types/mapP' | ||
export { default as move } from './types/move' | ||
export { default as normalizeBy } from './types/normalizeBy' | ||
export { default as onSuccess } from './types/onSuccess' | ||
export { default as onSuccessP } from './types/onSuccessP' | ||
export { default as overP } from './types/overP' | ||
export { default as promisify } from './types/promisify' | ||
export { default as reject } from './types/reject' | ||
export { default as rename } from './types/rename' | ||
export { default as renameAll } from './types/renameAll' | ||
export { default as renamePath } from './types/renamePath' | ||
export { default as renamePick } from './types/renamePick' | ||
export { default as resolve } from './types/resolve' | ||
export { default as tapP } from './types/tapP' | ||
export { default as unlessP } from './types/unlessP' | ||
export { default as useWithP } from './types/useWithP' | ||
export { default as validate } from './types/validate' | ||
export { default as validateWith } from './types/validateWith' | ||
export { default as whenP } from './types/whenP' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { expectType } from 'tsd' | ||
import { all } from '..' | ||
|
||
expectType<Promise<[ number, number ]>>( | ||
all([ Promise.resolve(1), Promise.resolve(2) ]) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { add } from 'ramda' | ||
import { expectAssignable } from 'tsd' | ||
import { assemble } from '..' | ||
|
||
const xfrmsUnary = { | ||
foo: [[ add(1) ]] as [[ (x: number) => number ]], | ||
bar: [{ baz: add(2) }] as [{ baz: (x: number) => number }], | ||
bat: 1 | ||
} as const | ||
|
||
type ExpectationUnary = { | ||
foo: [[ number ]], | ||
bar: [{ baz: number }], | ||
bat: number | ||
} | ||
|
||
expectAssignable<ExpectationUnary>(assemble(xfrmsUnary, 1)) | ||
expectAssignable<ExpectationUnary>(assemble(xfrmsUnary)(1)) | ||
|
||
const xfrmsNary = { | ||
foo: (one: string, two: string) => [ one, two ].join(','), | ||
bar: { | ||
baz: (one: string, two: string, three: string) => [ one, two, three ].join('|'), | ||
}, | ||
bat: 1 | ||
} | ||
|
||
type ExpectationNary = { | ||
foo: string, | ||
bar: { baz: string }, | ||
bat: number | ||
} | ||
|
||
expectAssignable<ExpectationNary>(assemble(xfrmsNary, 'one', 'two', 'three')) | ||
expectAssignable<ExpectationNary>(assemble(xfrmsNary)('one', 'two', 'three')) | ||
expectAssignable<ExpectationNary>(assemble(xfrmsNary)('one')('two', 'three')) | ||
expectAssignable<ExpectationNary>(assemble(xfrmsNary)('one')('two')('three')) | ||
|
||
const xfrms0ary = { | ||
foo: (...params: string[]) => params.join(','), | ||
bar: { | ||
baz: (...params: string[]) => params.join('|'), | ||
}, | ||
bat: 1 | ||
} | ||
|
||
type Expectation0ary = { | ||
foo: string, | ||
bar: { | ||
baz: string, | ||
}, | ||
bat: number | ||
} | ||
|
||
expectAssignable<Expectation0ary>(assemble(xfrms0ary, 'one', 'two', 'three')) | ||
expectAssignable<Expectation0ary>(assemble(xfrms0ary)('one', 'two', 'three')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { curry } from 'ramda' | ||
import { expectAssignable } from 'tsd' | ||
import { assembleP } from '..' | ||
|
||
const add = curry((a: number, b: number) => Promise.resolve(a + b)) | ||
const mult = curry((a: number, b: number) => Promise.resolve(a * b)) | ||
|
||
const xfrmsUnary = { | ||
foo: [[ add(1) ]] as [[ (x: number) => Promise<number> ]], | ||
bar: [{ baz: mult(2) }] as [{ baz: (x: number) => Promise<number> }], | ||
bat: 1 | ||
} as const | ||
|
||
type ExpectationUnary = Promise<{ | ||
foo: [[ number ]], | ||
bar: [{ baz: number }], | ||
bat: number | ||
}> | ||
|
||
expectAssignable<ExpectationUnary>(assembleP(xfrmsUnary, 1)) | ||
expectAssignable<ExpectationUnary>(assembleP(xfrmsUnary)(1)) | ||
|
||
const xfrmsNary = { | ||
foo: (one: string, two: string) => Promise.resolve([ one, two ].join(',')), | ||
bar: { | ||
baz: (one: string, two: string, three: string) => Promise.resolve([ one, two, three ].join('|')), | ||
}, | ||
bat: 1 | ||
} | ||
|
||
type ExpectationNary = Promise<{ | ||
foo: string, | ||
bar: { baz: string }, | ||
bat: number | ||
}> | ||
|
||
expectAssignable<ExpectationNary>(assembleP(xfrmsNary, 'one', 'two', 'three')) | ||
expectAssignable<ExpectationNary>(assembleP(xfrmsNary)('one', 'two', 'three')) | ||
expectAssignable<ExpectationNary>(assembleP(xfrmsNary)('one')('two', 'three')) | ||
expectAssignable<ExpectationNary>(assembleP(xfrmsNary)('one')('two')('three')) | ||
|
||
const xfrms0ary = { | ||
foo: (...params: string[]) => Promise.resolve(params.join(',')), | ||
bar: { | ||
baz: (...params: string[]) => Promise.resolve(params.join('|')), | ||
}, | ||
bat: 1 | ||
} | ||
|
||
type Expectation0ary = Promise<{ | ||
foo: string, | ||
bar: { | ||
baz: string, | ||
}, | ||
bat: number | ||
}> | ||
|
||
expectAssignable<Expectation0ary>(assembleP(xfrms0ary, 'one', 'two', 'three')) | ||
expectAssignable<Expectation0ary>(assembleP(xfrms0ary)('one', 'two', 'three')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { expectAssignable } from 'tsd' | ||
|
||
import { assocWith } from '..' | ||
|
||
function concatBarToFoo(obj: { foo: 'foo' }): 'foobar' { | ||
return obj.foo + 'bar' as 'foobar' | ||
} | ||
|
||
type Result = { foo: 'foo', baz: 'foobar' } | ||
|
||
expectAssignable<Result>(assocWith('baz', concatBarToFoo, { foo: 'foo' })) | ||
expectAssignable<Result>(assocWith('baz')(concatBarToFoo)({ foo: 'foo' })) | ||
expectAssignable<Result>(assocWith('baz', concatBarToFoo)({ foo: 'foo' })) | ||
expectAssignable<Result>(assocWith('baz')(concatBarToFoo, { foo: 'foo' })) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { expectAssignable } from 'tsd' | ||
|
||
import { assocWithP } from '..' | ||
|
||
async function concatBarToFoo(obj: { foo: 'foo' }): Promise<'foobar'> { | ||
return obj.foo + 'bar' as 'foobar' | ||
} | ||
|
||
type Result = Promise<{ foo: 'foo', baz: 'foobar' }> | ||
|
||
expectAssignable<Result>(assocWithP('baz', concatBarToFoo, { foo: 'foo' })) | ||
expectAssignable<Result>(assocWithP('baz')(concatBarToFoo)({ foo: 'foo' })) | ||
expectAssignable<Result>(assocWithP('baz', concatBarToFoo)({ foo: 'foo' })) | ||
expectAssignable<Result>(assocWithP('baz')(concatBarToFoo, { foo: 'foo' })) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { expectType } from 'tsd' | ||
|
||
import { backoff } from '..' | ||
|
||
async function f(a: 'foo', b: 'bar'): Promise<'baz'> { | ||
return 'baz' | ||
} | ||
|
||
expectType<typeof f>(backoff(undefined, f)) | ||
expectType<typeof f>(backoff()(f)) | ||
expectType<typeof f>(backoff({ base: 16, tries: 5 }, f)) | ||
expectType<typeof f>(backoff({ base: 16, tries: 5 })(f)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { expectAssignable } from 'tsd' | ||
|
||
import { batch } from '..' | ||
|
||
interface In { inputId: string } | ||
interface Out { outputId: string } | ||
|
||
async function asyncListFn(args: In[]): Promise<Out[]> { | ||
return [{ outputId: 'bar' }] | ||
} | ||
|
||
const batchedWoOptions = batch(undefined, asyncListFn) | ||
expectAssignable<Promise<Out>>(batchedWoOptions({ inputId: 'foo' })) | ||
|
||
const batchedWOptions = batch({ limit: 2, wait: 16 }, asyncListFn) | ||
expectAssignable<Promise<Out>>(batchedWOptions({ inputId: 'bar' })) | ||
|
||
const batchedWithMatching = batch({ | ||
inputKey: (x: { inputId: string }) => x.inputId, | ||
outputKey: (x: { outputId: string }) => x.outputId, | ||
}, asyncListFn) | ||
|
||
expectAssignable<Promise<Out>>(batchedWithMatching({ inputId: 'bar' })) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { expectAssignable } from 'tsd' | ||
|
||
import { combine } from '..' | ||
|
||
const mixin = { foo: 'bar' as const } | ||
const input = { baz: 'bip' as const } | ||
|
||
function K(x: typeof mixin) { | ||
return (y: typeof input) => x | ||
} | ||
|
||
type Expectation = { foo: 'bar', baz: 'bip' } | ||
|
||
expectAssignable<Expectation>(combine(K(mixin))(input)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { expectAssignable } from 'tsd' | ||
|
||
import { combineAll } from '..' | ||
|
||
const input = { baz: 3 as const } | ||
|
||
const actions = [ | ||
K({ foo: 1 as const }), | ||
K({ bar: 2 as const }), | ||
] as const | ||
|
||
function K<T>(x: T) { | ||
return (y: typeof input) => x | ||
} | ||
|
||
type Expectation = { | ||
foo: 1, | ||
bar: 2, | ||
baz: 3, | ||
} | ||
|
||
expectAssignable<Expectation>(combineAll(actions)(input)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { expectAssignable } from 'tsd' | ||
|
||
import { combineAllP } from '..' | ||
|
||
const input = { baz: 3 as const } | ||
|
||
const actions = [ | ||
K(Promise.resolve({ foo: 1 as const })), | ||
K(Promise.resolve({ bar: 2 as const })), | ||
] as const | ||
|
||
function K<T>(x: T) { | ||
return (y: typeof input) => x | ||
} | ||
|
||
type Expectation = Promise<{ | ||
foo: 1, | ||
bar: 2, | ||
baz: 3, | ||
}> | ||
|
||
expectAssignable<Expectation>(combineAllP(actions)(input)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { expectAssignable } from 'tsd' | ||
|
||
import { combineP } from '..' | ||
|
||
const mixin = { foo: 'bar' as const } | ||
const input = { baz: 'bip' as const } | ||
|
||
function K(x: typeof mixin) { | ||
return async (y: typeof input) => x | ||
} | ||
|
||
type Expectation = Promise<{ foo: 'bar', baz: 'bip' }> | ||
|
||
expectAssignable<Expectation>(combineP(K(mixin))(input)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Add, Multiply } from 'ts-arithmetic' | ||
import { expectType } from 'tsd' | ||
|
||
import { combineWith } from '..' | ||
|
||
declare function add(a: 2): { | ||
(b: 3): Add<2, 3> | ||
} | ||
|
||
declare function multiply(a: 3, b: 5): Multiply<3, 5> | ||
|
||
expectType<15>(combineWith(multiply)(add(2))(3)) | ||
expectType<15>(combineWith(multiply, add(2))(3)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Add, Multiply } from 'ts-arithmetic' | ||
import { expectType } from 'tsd' | ||
|
||
import { combineWithP } from '..' | ||
|
||
declare function add(a: 2): { | ||
(b: 3): Promise<Add<2, 3>> | ||
} | ||
|
||
declare function multiply(a: 3, b: 5): Promise<Multiply<3, 5>> | ||
|
||
expectType<Promise<15>>(combineWithP(multiply)(add(2))(3)) | ||
expectType<Promise<15>>(combineWithP(multiply, add(2))(3)) |
Oops, something went wrong.