Comparing version 107.0.0 to 108.0.0
@@ -1,2 +0,2 @@ | ||
import { ComposeMany } from "./composeTyping.js"; | ||
import type { ComposeMany } from "./composeTyping.js"; | ||
import type { AnyAsync, Func, IsAsync, ParamOf, PromisifyFunction, UnaryFnUntyped } from "./typing.js"; | ||
@@ -3,0 +3,0 @@ type UnaryFn<A, R> = (a: A) => R; |
import type { Func, IsAsync, ParamOf } from "./typing.js"; | ||
export declare const filter: <F extends Func>(f: F) => (_: ParamOf<F>[]) => true extends IsAsync<F> ? Promise<ParamOf<F>[]> : ParamOf<F>[]; | ||
type ConstrainedTyping<F extends Func> = F extends ((value: ParamOf<F>) => value is infer S) ? S[] : ParamOf<F>[]; | ||
export declare const filter: <F extends Func>(f: F) => (_: ParamOf<F>[]) => true extends IsAsync<F> ? Promise<ConstrainedTyping<F>> : ConstrainedTyping<F>; | ||
export declare const find: <F extends Func>(predicate: F) => (xs: ParamOf<F>[]) => true extends IsAsync<F> ? Promise<ParamOf<F> | undefined> : ParamOf<F> | undefined; | ||
@@ -4,0 +5,0 @@ export declare const remove: <F extends Func>(f: F) => true extends IsAsync<F> ? (x: ParamOf<F>[]) => Promise<ParamOf<F>[]> : (x: ParamOf<F>[]) => ParamOf<F>[]; |
@@ -0,5 +1,5 @@ | ||
import { head, second } from "./array.js"; | ||
import { complement, pipe } from "./composition.js"; | ||
import { head, second } from "./array.js"; | ||
import { pairRight } from "./juxt.js"; | ||
import { map } from "./map.js"; | ||
import { pairRight } from "./juxt.js"; | ||
import { isPromise } from "./promise.js"; | ||
@@ -6,0 +6,0 @@ export const filter = (f) => |
import { allmap, anymap, concat, zip } from "./array.js"; | ||
import { identity, pipe } from "./composition.js"; | ||
import { isPromise } from "./promise.js"; | ||
import { map } from "./map.js"; | ||
import { isPromise } from "./index.js"; | ||
export const juxt = (...fs) => (...x) => { | ||
@@ -6,0 +6,0 @@ const result = []; |
@@ -18,3 +18,3 @@ import type { ElementOf, Func, IsAsync, ParamOf, Reducer, ReturnTypeUnwrapped, Unary } from "./typing.js"; | ||
export declare const entryMap: (f: import("./typing.js").UnaryFnUntyped) => (Obj: Record<any, any>) => IsAsync<(kvs: [any, any][]) => [any, any][] | Promise<[any, any][]>> extends true ? Promise<Record<ElementOf<Awaited<ReturnType<(kvs: [any, any][]) => [any, any][] | Promise<[any, any][]>>>>[0], ElementOf<Awaited<ReturnType<(kvs: [any, any][]) => [any, any][] | Promise<[any, any][]>>>>[1]>> : Record<ElementOf<Awaited<ReturnType<(kvs: [any, any][]) => [any, any][] | Promise<[any, any][]>>>>[0], ElementOf<Awaited<ReturnType<(kvs: [any, any][]) => [any, any][] | Promise<[any, any][]>>>>[1]>; | ||
export declare const entryFilter: <Function extends (((kv: [any, any]) => any))>(f: Function) => (Obj: Record<ParamOf<Function>[0], ParamOf<Function>[1]>) => IsAsync<(_: ParamOf<Function>[]) => true extends IsAsync<Function> ? Promise<ParamOf<Function>[]> : ParamOf<Function>[]> extends true ? Promise<Record<ElementOf<Awaited<ReturnType<(_: ParamOf<Function>[]) => true extends IsAsync<Function> ? Promise<ParamOf<Function>[]> : ParamOf<Function>[]>>>[0], ElementOf<Awaited<ReturnType<(_: ParamOf<Function>[]) => true extends IsAsync<Function> ? Promise<ParamOf<Function>[]> : ParamOf<Function>[]>>>[1]>> : Record<ElementOf<Awaited<ReturnType<(_: ParamOf<Function>[]) => true extends IsAsync<Function> ? Promise<ParamOf<Function>[]> : ParamOf<Function>[]>>>[0], ElementOf<Awaited<ReturnType<(_: ParamOf<Function>[]) => true extends IsAsync<Function> ? Promise<ParamOf<Function>[]> : ParamOf<Function>[]>>>[1]>; | ||
export declare const entryFilter: (f: Func) => (Obj: Record<any, any>) => IsAsync<(kvs: [any, any][]) => [any, any][] | Promise<[any, any][]>> extends true ? Promise<Record<ElementOf<Awaited<ReturnType<(kvs: [any, any][]) => [any, any][] | Promise<[any, any][]>>>>[0], ElementOf<Awaited<ReturnType<(kvs: [any, any][]) => [any, any][] | Promise<[any, any][]>>>>[1]>> : Record<ElementOf<Awaited<ReturnType<(kvs: [any, any][]) => [any, any][] | Promise<[any, any][]>>>>[0], ElementOf<Awaited<ReturnType<(kvs: [any, any][]) => [any, any][] | Promise<[any, any][]>>>>[1]>; | ||
type RecordKey = string | number | symbol; | ||
@@ -21,0 +21,0 @@ type EntryMap<F extends Func, OldKey extends RecordKey, OldValue, NewKey extends RecordKey, NewValue> = (obj: Record<OldKey, OldValue>) => true extends IsAsync<F> ? Promise<Record<NewKey, NewValue>> : Record<NewKey, NewValue>; |
@@ -0,7 +1,7 @@ | ||
import { head, second, wrapArray } from "./array.js"; | ||
import { applyTo, identity, pipe } from "./composition.js"; | ||
import { head, second, wrapArray } from "./array.js"; | ||
import { filter } from "./filter.js"; | ||
import { stack } from "./juxt.js"; | ||
import { map } from "./map.js"; | ||
import { reduce } from "./reduce.js"; | ||
import { stack } from "./juxt.js"; | ||
export const wrapObject = (key) => (value) => ({ [key]: value }); | ||
@@ -45,3 +45,3 @@ export const groupByManyReduce = (keys, reducer, initial) => (it) => { | ||
export const entryMap = pipe(map, onEntries); | ||
export const entryFilter = (f) => onEntries(filter(f)); | ||
export const entryFilter = pipe(filter, onEntries); | ||
export const valFilter = (f) => | ||
@@ -48,0 +48,0 @@ // @ts-expect-error can't infer typing here |
{ | ||
"name": "gamla", | ||
"version": "107.0.0", | ||
"version": "108.0.0", | ||
"description": "Functional programming with async and type safety", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -1,2 +0,2 @@ | ||
import { ComposeMany } from "./composeTyping.js"; | ||
import type { ComposeMany } from "./composeTyping.js"; | ||
import type { AnyAsync, Func, IsAsync, ParamOf, PromisifyFunction, UnaryFnUntyped } from "./typing.js"; | ||
@@ -3,0 +3,0 @@ type UnaryFn<A, R> = (a: A) => R; |
import type { Func, IsAsync, ParamOf } from "./typing.js"; | ||
export declare const filter: <F extends Func>(f: F) => (_: ParamOf<F>[]) => true extends IsAsync<F> ? Promise<ParamOf<F>[]> : ParamOf<F>[]; | ||
type ConstrainedTyping<F extends Func> = F extends ((value: ParamOf<F>) => value is infer S) ? S[] : ParamOf<F>[]; | ||
export declare const filter: <F extends Func>(f: F) => (_: ParamOf<F>[]) => true extends IsAsync<F> ? Promise<ConstrainedTyping<F>> : ConstrainedTyping<F>; | ||
export declare const find: <F extends Func>(predicate: F) => (xs: ParamOf<F>[]) => true extends IsAsync<F> ? Promise<ParamOf<F> | undefined> : ParamOf<F> | undefined; | ||
@@ -4,0 +5,0 @@ export declare const remove: <F extends Func>(f: F) => true extends IsAsync<F> ? (x: ParamOf<F>[]) => Promise<ParamOf<F>[]> : (x: ParamOf<F>[]) => ParamOf<F>[]; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.removeNulls = exports.intersectBy = exports.remove = exports.find = exports.filter = void 0; | ||
const array_js_1 = require("./array.js"); | ||
const composition_js_1 = require("./composition.js"); | ||
const array_js_1 = require("./array.js"); | ||
const juxt_js_1 = require("./juxt.js"); | ||
const map_js_1 = require("./map.js"); | ||
const juxt_js_1 = require("./juxt.js"); | ||
const promise_js_1 = require("./promise.js"); | ||
@@ -9,0 +9,0 @@ const filter = (f) => |
@@ -6,4 +6,4 @@ "use strict"; | ||
const composition_js_1 = require("./composition.js"); | ||
const promise_js_1 = require("./promise.js"); | ||
const map_js_1 = require("./map.js"); | ||
const index_js_1 = require("./index.js"); | ||
const juxt = (...fs) => (...x) => { | ||
@@ -14,3 +14,3 @@ const result = []; | ||
result.push(f(...x)); | ||
anyAsync = anyAsync || (0, index_js_1.isPromise)(result[result.length - 1]); | ||
anyAsync = anyAsync || (0, promise_js_1.isPromise)(result[result.length - 1]); | ||
} | ||
@@ -17,0 +17,0 @@ // @ts-expect-error reason=ts does not understand me :_( |
@@ -18,3 +18,3 @@ import type { ElementOf, Func, IsAsync, ParamOf, Reducer, ReturnTypeUnwrapped, Unary } from "./typing.js"; | ||
export declare const entryMap: (f: import("./typing.js").UnaryFnUntyped) => (Obj: Record<any, any>) => IsAsync<(kvs: [any, any][]) => [any, any][] | Promise<[any, any][]>> extends true ? Promise<Record<ElementOf<Awaited<ReturnType<(kvs: [any, any][]) => [any, any][] | Promise<[any, any][]>>>>[0], ElementOf<Awaited<ReturnType<(kvs: [any, any][]) => [any, any][] | Promise<[any, any][]>>>>[1]>> : Record<ElementOf<Awaited<ReturnType<(kvs: [any, any][]) => [any, any][] | Promise<[any, any][]>>>>[0], ElementOf<Awaited<ReturnType<(kvs: [any, any][]) => [any, any][] | Promise<[any, any][]>>>>[1]>; | ||
export declare const entryFilter: <Function extends (((kv: [any, any]) => any))>(f: Function) => (Obj: Record<ParamOf<Function>[0], ParamOf<Function>[1]>) => IsAsync<(_: ParamOf<Function>[]) => true extends IsAsync<Function> ? Promise<ParamOf<Function>[]> : ParamOf<Function>[]> extends true ? Promise<Record<ElementOf<Awaited<ReturnType<(_: ParamOf<Function>[]) => true extends IsAsync<Function> ? Promise<ParamOf<Function>[]> : ParamOf<Function>[]>>>[0], ElementOf<Awaited<ReturnType<(_: ParamOf<Function>[]) => true extends IsAsync<Function> ? Promise<ParamOf<Function>[]> : ParamOf<Function>[]>>>[1]>> : Record<ElementOf<Awaited<ReturnType<(_: ParamOf<Function>[]) => true extends IsAsync<Function> ? Promise<ParamOf<Function>[]> : ParamOf<Function>[]>>>[0], ElementOf<Awaited<ReturnType<(_: ParamOf<Function>[]) => true extends IsAsync<Function> ? Promise<ParamOf<Function>[]> : ParamOf<Function>[]>>>[1]>; | ||
export declare const entryFilter: (f: Func) => (Obj: Record<any, any>) => IsAsync<(kvs: [any, any][]) => [any, any][] | Promise<[any, any][]>> extends true ? Promise<Record<ElementOf<Awaited<ReturnType<(kvs: [any, any][]) => [any, any][] | Promise<[any, any][]>>>>[0], ElementOf<Awaited<ReturnType<(kvs: [any, any][]) => [any, any][] | Promise<[any, any][]>>>>[1]>> : Record<ElementOf<Awaited<ReturnType<(kvs: [any, any][]) => [any, any][] | Promise<[any, any][]>>>>[0], ElementOf<Awaited<ReturnType<(kvs: [any, any][]) => [any, any][] | Promise<[any, any][]>>>>[1]>; | ||
type RecordKey = string | number | symbol; | ||
@@ -21,0 +21,0 @@ type EntryMap<F extends Func, OldKey extends RecordKey, OldValue, NewKey extends RecordKey, NewValue> = (obj: Record<OldKey, OldValue>) => true extends IsAsync<F> ? Promise<Record<NewKey, NewValue>> : Record<NewKey, NewValue>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.applySpec = exports.mapTerminals = exports.keyMap = exports.valMap = exports.keyFilter = exports.valFilter = exports.entryFilter = exports.entryMap = exports.edgesToGraph = exports.groupBy = exports.addEntry = exports.groupByMany = exports.groupByReduce = exports.count = exports.groupByManyReduce = exports.wrapObject = void 0; | ||
const array_js_1 = require("./array.js"); | ||
const composition_js_1 = require("./composition.js"); | ||
const array_js_1 = require("./array.js"); | ||
const filter_js_1 = require("./filter.js"); | ||
const juxt_js_1 = require("./juxt.js"); | ||
const map_js_1 = require("./map.js"); | ||
const reduce_js_1 = require("./reduce.js"); | ||
const juxt_js_1 = require("./juxt.js"); | ||
const wrapObject = (key) => (value) => ({ [key]: value }); | ||
@@ -54,4 +54,3 @@ exports.wrapObject = wrapObject; | ||
exports.entryMap = (0, composition_js_1.pipe)(map_js_1.map, onEntries); | ||
const entryFilter = (f) => onEntries((0, filter_js_1.filter)(f)); | ||
exports.entryFilter = entryFilter; | ||
exports.entryFilter = (0, composition_js_1.pipe)(filter_js_1.filter, onEntries); | ||
const valFilter = (f) => | ||
@@ -58,0 +57,0 @@ // @ts-expect-error can't infer typing here |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
348799
2601