Comparing version 32.0.0 to 33.0.0
@@ -0,5 +1,5 @@ | ||
import { complement, pipe } from "./composition.js"; | ||
import { head, second } from "./array.js"; | ||
import { complement, pipe } from "./composition.js"; | ||
import { map } from "./map.js"; | ||
import { pairRight } from "./juxt.js"; | ||
import { map } from "./map.js"; | ||
export const filter = (f) => | ||
@@ -6,0 +6,0 @@ // @ts-expect-error typing head is hard. |
@@ -15,2 +15,3 @@ import { all, any, concat, zip } from "./array.js"; | ||
export const pairRight = (f) => juxt((identity), f); | ||
export const pairLeft = (f) => juxt(f, (identity)); | ||
export const stack = (...functions) => | ||
@@ -17,0 +18,0 @@ // @ts-expect-error reason: too complex |
@@ -6,3 +6,3 @@ { | ||
"name": "gamla", | ||
"version": "32.0.0", | ||
"version": "33.0.0", | ||
"description": "Functional programming with async and type safety", | ||
@@ -9,0 +9,0 @@ "license": "MIT", |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.removeNulls = exports.intersectBy = exports.remove = exports.find = exports.filter = void 0; | ||
const composition_js_1 = require("./composition.js"); | ||
const array_js_1 = require("./array.js"); | ||
const composition_js_1 = require("./composition.js"); | ||
const map_js_1 = require("./map.js"); | ||
const juxt_js_1 = require("./juxt.js"); | ||
const map_js_1 = require("./map.js"); | ||
const filter = (f) => | ||
@@ -9,0 +9,0 @@ // @ts-expect-error typing head is hard. |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.anyjuxt = exports.alljuxt = exports.juxtCat = exports.stack = exports.pairRight = exports.juxt = void 0; | ||
exports.anyjuxt = exports.alljuxt = exports.juxtCat = exports.stack = exports.pairLeft = exports.pairRight = exports.juxt = void 0; | ||
const array_js_1 = require("./array.js"); | ||
@@ -20,2 +20,4 @@ const composition_js_1 = require("./composition.js"); | ||
exports.pairRight = pairRight; | ||
const pairLeft = (f) => (0, exports.juxt)(f, (composition_js_1.identity)); | ||
exports.pairLeft = pairLeft; | ||
const stack = (...functions) => | ||
@@ -22,0 +24,0 @@ // @ts-expect-error reason: too complex |
@@ -1,7 +0,6 @@ | ||
import { AnyAsync, AsyncFunction, Func, Last, ReturnTypeUnwrapped } from "./typing.js"; | ||
import { AnyAsync, AsyncFunction, Func, Last, ParamOf, ReturnTypeUnwrapped } from "./typing.js"; | ||
type UnaryFn<A, R> = (a: A) => R; | ||
type UnaryFnUntyped = (a: any) => any; | ||
type Arg<F extends Func> = Parameters<F>[0]; | ||
type Res<F> = F extends UnaryFn<any, infer R> ? R : never; | ||
type ValidCompose<F1 extends Func, F2 extends Func> = Res<F1> extends (Arg<F2> | Promise<Arg<F2>>) ? F1 : (...arg: Parameters<F1>) => Arg<F2>; | ||
type ValidCompose<F1 extends Func, F2 extends Func> = Res<F1> extends (ParamOf<F2> | Promise<ParamOf<F2>>) ? F1 : (...arg: Parameters<F1>) => ParamOf<F2>; | ||
type ValidPipe<FS extends Func[]> = FS extends [ | ||
@@ -20,3 +19,3 @@ infer F1 extends Func, | ||
export declare const complement: <F extends Func>(f: F) => (...x: Parameters<F>) => boolean; | ||
export declare const sideEffect: <F extends UnaryFnUntyped>(f: F) => (x: Parameters<F>[0]) => F extends AsyncFunction ? Promise<Parameters<F>[0]> : Parameters<F>[0]; | ||
export declare const sideEffect: <F extends UnaryFnUntyped>(f: F) => (x: ParamOf<F>) => F extends AsyncFunction ? Promise<ParamOf<F>> : ParamOf<F>; | ||
export declare const wrapSideEffect: <Args extends unknown[], Result>(cleanup: (...args: Args) => void | Promise<void>) => (f: (...args: Args) => Result) => (...args: Args) => Result | Promise<Result>; | ||
@@ -23,0 +22,0 @@ export declare const applyTo: <A extends unknown[]>(...args: A) => (f: (...args: A) => unknown) => unknown; |
import { AsyncFunction, Func, ParamOf } from "./typing.js"; | ||
export declare const filter: <F extends Func>(f: F) => (_: ParamOf<F>[]) => F extends AsyncFunction ? Promise<ParamOf<F>[]> : ParamOf<F>[]; | ||
export declare const find: <Fn extends Func>(predicate: Fn) => (_: ParamOf<Fn>[]) => [(_: ParamOf<Fn>[]) => Fn extends AsyncFunction ? Promise<ParamOf<Fn>[]> : ParamOf<Fn>[], <T extends string | any[]>(x: T) => T[0]] extends infer T_1 ? T_1 extends [(_: ParamOf<Fn>[]) => Fn extends AsyncFunction ? Promise<ParamOf<Fn>[]> : ParamOf<Fn>[], <T extends string | any[]>(x: T) => T[0]] ? T_1 extends import("./typing.js").AnyAsync<T_1> ? Promise<import("./typing.js").ReturnTypeUnwrapped<import("./typing.js").Last<T_1>>> : ReturnType<import("./typing.js").Last<T_1>> : never : never; | ||
export declare const remove: <F extends Func>(f: F) => F extends AsyncFunction ? (x: Parameters<F>[0][]) => Promise<Parameters<F>[0][]> : (x: Parameters<F>[0][]) => Parameters<F>[0][]; | ||
export declare const remove: <F extends Func>(f: F) => F extends AsyncFunction ? (x: ParamOf<F>[]) => Promise<ParamOf<F>[]> : (x: ParamOf<F>[]) => ParamOf<F>[]; | ||
type Primitive = string | number | boolean | null | undefined; | ||
@@ -6,0 +6,0 @@ export declare const intersectBy: <T>(f: (x: T) => Primitive) => (arrays: T[][]) => T[]; |
@@ -1,2 +0,2 @@ | ||
import { AnyAsync, Func, ReturnTypeUnwrapped, Union } from "./typing.js"; | ||
import { AnyAsync, Func, ParamOf, ReturnTypeUnwrapped, Union } from "./typing.js"; | ||
type Results<Functions extends Func[]> = { | ||
@@ -12,8 +12,9 @@ [i in keyof Functions]: ReturnTypeUnwrapped<Functions[i]>; | ||
type juxtCatOutput<Functions extends Func[]> = Functions extends AnyAsync<Functions> ? Promise<ArrayOfOneOf<AwaitedResults<Functions>>> : ArrayOfOneOf<Results<Functions>>; | ||
export declare const juxt: <Functions extends Func[]>(...fs: Functions) => (...x: Parameters<Functions[0]>) => JuxtOutput<Functions>; | ||
export declare const pairRight: <Function_1 extends Func>(f: Function_1) => (x: Parameters<Function_1>[0]) => JuxtOutput<[(x: Parameters<Function_1>[0]) => Parameters<Function_1>[0], Function_1]>; | ||
export declare const stack: <Functions extends Func[]>(...functions: Functions) => (_: { [i in keyof Functions]: Parameters<Functions[i]>[0]; }) => JuxtOutput<Functions>; | ||
export declare const juxtCat: <Functions extends Func[]>(...fs: Functions) => (..._: Parameters<Functions[0]>) => juxtCatOutput<Functions>; | ||
export declare const juxt: <Fs extends Func[]>(...fs: Fs) => (...x: Parameters<Fs[0]>) => JuxtOutput<Fs>; | ||
export declare const pairRight: <F extends Func>(f: F) => (x: ParamOf<F>) => JuxtOutput<[(x: ParamOf<F>) => ParamOf<F>, F]>; | ||
export declare const pairLeft: <F extends Func>(f: F) => (...x: Parameters<F>) => JuxtOutput<[F, (x: ParamOf<F>) => ParamOf<F>]>; | ||
export declare const stack: <Functions extends Func[]>(...functions: Functions) => (_: { [i in keyof Functions]: ParamOf<Functions[i]>; }) => JuxtOutput<Functions>; | ||
export declare const juxtCat: <Fs extends Func[]>(...fs: Fs) => (..._: Parameters<Fs[0]>) => juxtCatOutput<Fs>; | ||
export declare const alljuxt: <Functions extends Func[]>(...fs: Functions) => (..._: Parameters<Functions[0]>) => Functions extends AnyAsync<Functions> ? Promise<boolean> : boolean; | ||
export declare const anyjuxt: <Functions extends Func[]>(...fs: Functions) => (..._: Parameters<Functions[0]>) => Functions extends AnyAsync<Functions> ? Promise<boolean> : boolean; | ||
export {}; |
@@ -1,4 +0,4 @@ | ||
import { AsyncFunction, Func, ReturnTypeUnwrapped } from "./typing.js"; | ||
import { AsyncFunction, Func, ParamOf, ReturnTypeUnwrapped } from "./typing.js"; | ||
export declare const reduce: <Function_1 extends (state: any, element: any) => any>(reducer: Function_1, initial: () => ReturnTypeUnwrapped<Function_1>) => (xs: Parameters<Function_1>[1][]) => ReturnType<Function_1>; | ||
export declare const min: <F extends Func>(key: F) => (xs: Parameters<F>[0][]) => F extends AsyncFunction ? Promise<Parameters<F>[0]> : Parameters<F>[0]; | ||
export declare const max: <F extends Func>(key: F) => (xs: Parameters<F>[0][]) => F extends AsyncFunction ? Promise<Parameters<F>[0]> : Parameters<F>[0]; | ||
export declare const min: <F extends Func>(key: F) => (xs: ParamOf<F>[]) => F extends AsyncFunction ? Promise<ParamOf<F>> : ParamOf<F>; | ||
export declare const max: <F extends Func>(key: F) => (xs: ParamOf<F>[]) => F extends AsyncFunction ? Promise<ParamOf<F>> : ParamOf<F>; |
194872
1755