@morphic-ts/common
Advanced tools
+11
-0
| /** | ||
| * @file Pattern stolen from fp-ts. Type defunctionalization (as describe in [Lightweight higher-kinded polymorphism](https://www.cl.cam.ac.uk/~jdy22/papers/lightweight-higher-kinded-polymorphism.pdf)) | ||
| */ | ||
| import type { ConfigType } from './config'; | ||
| /** | ||
@@ -38,1 +39,11 @@ * `* -> * -> *` constructors | ||
| export declare type Kind<URI extends URIS, R, E, A> = URItoKind<R, E, A>[URI]; | ||
| /** | ||
| * The URIS to Index ConfigType | ||
| * @since 0.0.1 | ||
| */ | ||
| export declare type ConfigTypeURIS = keyof ConfigType<any, any>; | ||
| /** | ||
| * Helper to resolve a ConfigType for a particular URI(s) | ||
| * @since 0.0.1 | ||
| */ | ||
| export declare type ConfigTypeKind<URI extends ConfigTypeURIS, E, A> = ConfigType<E, A>[URI]; |
+3
-0
@@ -0,1 +1,4 @@ | ||
| /** | ||
| * @file Pattern stolen from fp-ts. Type defunctionalization (as describe in [Lightweight higher-kinded polymorphism](https://www.cl.cam.ac.uk/~jdy22/papers/lightweight-higher-kinded-polymorphism.pdf)) | ||
| */ | ||
| export {}; |
+11
-17
@@ -0,1 +1,3 @@ | ||
| import type { Either } from 'fp-ts/es6/Either'; | ||
| import type { UnionToIntersection } from './core'; | ||
| /** | ||
@@ -12,25 +14,10 @@ * @since 0.0.1 | ||
| */ | ||
| export declare const projectFieldWithEnv: <T extends Record<any, (e: R, c: C) => Record<any, any>>, R, C>(t: T, env: R, c: C) => <K extends keyof ReturnType<T[keyof T]>>(k: K) => { [q in keyof T]: ReturnType<T[q]>[K]; }; | ||
| export declare const projectFieldWithEnv: <T extends Record<any, (e: R) => Record<any, any>>, R>(t: T, env: R) => <K extends keyof ReturnType<T[keyof T]>>(k: K) => { [q in keyof T]: ReturnType<T[q]>[K]; }; | ||
| /** | ||
| * @since 0.0.1 | ||
| */ | ||
| export declare function conjunction<A, B>(...x: [A, B]): A & B; | ||
| export declare function conjunction<A, B, C>(...x: [A, B, C]): A & B & C; | ||
| export declare function conjunction<A, B, C, D>(...x: [A, B, C, D]): A & B & C & D; | ||
| export declare function conjunction<A, B, C, D, E>(...x: [A, B, C, D, E]): A & B & C & D & E; | ||
| export declare function conjunction<A, B, C, D, E, F>(...x: [A, B, C, D, E, F]): A & B & C & D & E & F; | ||
| export declare function conjunction<A, B, C, D, E, F, G>(...x: [A, B, C, D, E, F, G]): A & B & C & D & E & F & G; | ||
| export declare function conjunction<A, B, C, D, E, F, G, H>(...x: [A, B, C, D, E, F, G, H]): A & B & C & D & E & F & G & H; | ||
| export declare function conjunction<A, B, C, D, E, F, G, H, I>(...x: [A, B, C, D, E, F, G, H, I]): A & B & C & D & E & F & G & H & I; | ||
| export declare function conjunction<A, B, C, D, E, F, G, H, I, J>(...x: [A, B, C, D, E, F, G, H, I, J]): A & B & C & D & E & F & G & H & I & J; | ||
| export declare function conjunction<A, B, C, D, E, F, G, H, I, J, K>(...x: [A, B, C, D, E, F, G, H, I, J, K]): A & B & C & D & E & F & G & H & I & J & K; | ||
| export declare function conjunction<A, B, C, D, E, F, G, H, I, J, K, L>(...x: [A, B, C, D, E, F, G, H, I, J, K, L]): A & B & C & D & E & F & G & H & I & J & K & L; | ||
| export declare function conjunction<A, B, C, D, E, F, G, H, I, J, K, L, M>(...x: [A, B, C, D, E, F, G, H, I, J, K, L, M]): A & B & C & D & E & F & G & H & I & J & K & L & M; | ||
| export declare const merge: <R extends unknown[]>(...x: R) => UnionToIntersection<R[number]>; | ||
| /** | ||
| * @since 0.0.1 | ||
| */ | ||
| export declare const merge: typeof conjunction; | ||
| /** | ||
| * @since 0.0.1 | ||
| */ | ||
| export declare const collect: <K extends string, A, B>(d: Record<K, A>, f: (k: K, a: A) => B) => B[]; | ||
@@ -49,1 +36,8 @@ /** | ||
| export declare type Includes<A, B, Y, N> = IsNever<B, Y, A extends B ? Y : N>; | ||
| /** | ||
| * @since 0.0.1 | ||
| * | ||
| * Returns a function returning the index of the first guard matching a particular Objet | ||
| * Caching the result under the given Symbol inside the Object | ||
| */ | ||
| export declare const getGuardId: (guards: ((x: unknown) => Either<any, any>)[], sym: symbol) => (a: unknown) => number; |
+29
-5
@@ -13,10 +13,7 @@ import { collect as Rcollect, record } from 'fp-ts/Record'; | ||
| */ | ||
| export const projectFieldWithEnv = (t, env, c) => (k) => record.map(t, p => p(env, c)[k]); | ||
| export function conjunction(...x) { | ||
| return Object.assign({}, ...x); | ||
| } | ||
| export const projectFieldWithEnv = (t, env) => (k) => record.map(t, p => p(env)[k]); | ||
| /** | ||
| * @since 0.0.1 | ||
| */ | ||
| export const merge = conjunction; | ||
| export const merge = (...x) => Object.assign({}, ...x); | ||
| /** | ||
@@ -38,1 +35,28 @@ * @since 0.0.1 | ||
| }; | ||
| /** | ||
| * @since 0.0.1 | ||
| * | ||
| * Returns a function returning the index of the first guard matching a particular Objet | ||
| * Caching the result under the given Symbol inside the Object | ||
| */ | ||
| export const getGuardId = (guards, sym) => { | ||
| const len = guards.length; | ||
| return (a) => { | ||
| const isObj = typeof a === 'object' && a !== null; | ||
| if (isObj) { | ||
| const r = a[sym]; | ||
| if (r !== undefined) { | ||
| return r; | ||
| } | ||
| } | ||
| for (let i = 0; i < len; i++) { | ||
| if (guards[i](a)._tag === 'Right') { | ||
| if (isObj) { | ||
| a[sym] = i; | ||
| } | ||
| return i; | ||
| } | ||
| } | ||
| return -1; | ||
| }; | ||
| }; |
+11
-0
| /** | ||
| * @file Pattern stolen from fp-ts. Type defunctionalization (as describe in [Lightweight higher-kinded polymorphism](https://www.cl.cam.ac.uk/~jdy22/papers/lightweight-higher-kinded-polymorphism.pdf)) | ||
| */ | ||
| import type { ConfigType } from './config'; | ||
| /** | ||
@@ -38,1 +39,11 @@ * `* -> * -> *` constructors | ||
| export declare type Kind<URI extends URIS, R, E, A> = URItoKind<R, E, A>[URI]; | ||
| /** | ||
| * The URIS to Index ConfigType | ||
| * @since 0.0.1 | ||
| */ | ||
| export declare type ConfigTypeURIS = keyof ConfigType<any, any>; | ||
| /** | ||
| * Helper to resolve a ConfigType for a particular URI(s) | ||
| * @since 0.0.1 | ||
| */ | ||
| export declare type ConfigTypeKind<URI extends ConfigTypeURIS, E, A> = ConfigType<E, A>[URI]; |
+3
-0
| "use strict"; | ||
| /** | ||
| * @file Pattern stolen from fp-ts. Type defunctionalization (as describe in [Lightweight higher-kinded polymorphism](https://www.cl.cam.ac.uk/~jdy22/papers/lightweight-higher-kinded-polymorphism.pdf)) | ||
| */ | ||
| Object.defineProperty(exports, "__esModule", { value: true }); |
+11
-17
@@ -0,1 +1,3 @@ | ||
| import type { Either } from 'fp-ts/lib/Either'; | ||
| import type { UnionToIntersection } from './core'; | ||
| /** | ||
@@ -12,25 +14,10 @@ * @since 0.0.1 | ||
| */ | ||
| export declare const projectFieldWithEnv: <T extends Record<any, (e: R, c: C) => Record<any, any>>, R, C>(t: T, env: R, c: C) => <K extends keyof ReturnType<T[keyof T]>>(k: K) => { [q in keyof T]: ReturnType<T[q]>[K]; }; | ||
| export declare const projectFieldWithEnv: <T extends Record<any, (e: R) => Record<any, any>>, R>(t: T, env: R) => <K extends keyof ReturnType<T[keyof T]>>(k: K) => { [q in keyof T]: ReturnType<T[q]>[K]; }; | ||
| /** | ||
| * @since 0.0.1 | ||
| */ | ||
| export declare function conjunction<A, B>(...x: [A, B]): A & B; | ||
| export declare function conjunction<A, B, C>(...x: [A, B, C]): A & B & C; | ||
| export declare function conjunction<A, B, C, D>(...x: [A, B, C, D]): A & B & C & D; | ||
| export declare function conjunction<A, B, C, D, E>(...x: [A, B, C, D, E]): A & B & C & D & E; | ||
| export declare function conjunction<A, B, C, D, E, F>(...x: [A, B, C, D, E, F]): A & B & C & D & E & F; | ||
| export declare function conjunction<A, B, C, D, E, F, G>(...x: [A, B, C, D, E, F, G]): A & B & C & D & E & F & G; | ||
| export declare function conjunction<A, B, C, D, E, F, G, H>(...x: [A, B, C, D, E, F, G, H]): A & B & C & D & E & F & G & H; | ||
| export declare function conjunction<A, B, C, D, E, F, G, H, I>(...x: [A, B, C, D, E, F, G, H, I]): A & B & C & D & E & F & G & H & I; | ||
| export declare function conjunction<A, B, C, D, E, F, G, H, I, J>(...x: [A, B, C, D, E, F, G, H, I, J]): A & B & C & D & E & F & G & H & I & J; | ||
| export declare function conjunction<A, B, C, D, E, F, G, H, I, J, K>(...x: [A, B, C, D, E, F, G, H, I, J, K]): A & B & C & D & E & F & G & H & I & J & K; | ||
| export declare function conjunction<A, B, C, D, E, F, G, H, I, J, K, L>(...x: [A, B, C, D, E, F, G, H, I, J, K, L]): A & B & C & D & E & F & G & H & I & J & K & L; | ||
| export declare function conjunction<A, B, C, D, E, F, G, H, I, J, K, L, M>(...x: [A, B, C, D, E, F, G, H, I, J, K, L, M]): A & B & C & D & E & F & G & H & I & J & K & L & M; | ||
| export declare const merge: <R extends unknown[]>(...x: R) => UnionToIntersection<R[number]>; | ||
| /** | ||
| * @since 0.0.1 | ||
| */ | ||
| export declare const merge: typeof conjunction; | ||
| /** | ||
| * @since 0.0.1 | ||
| */ | ||
| export declare const collect: <K extends string, A, B>(d: Record<K, A>, f: (k: K, a: A) => B) => B[]; | ||
@@ -49,1 +36,8 @@ /** | ||
| export declare type Includes<A, B, Y, N> = IsNever<B, Y, A extends B ? Y : N>; | ||
| /** | ||
| * @since 0.0.1 | ||
| * | ||
| * Returns a function returning the index of the first guard matching a particular Objet | ||
| * Caching the result under the given Symbol inside the Object | ||
| */ | ||
| export declare const getGuardId: (guards: ((x: unknown) => Either<any, any>)[], sym: symbol) => (a: unknown) => number; |
+37
-10
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.memo = exports.collect = exports.merge = exports.conjunction = exports.projectFieldWithEnv = exports.projectField = exports.mapRecord = void 0; | ||
| exports.getGuardId = exports.memo = exports.collect = exports.merge = exports.projectFieldWithEnv = exports.projectField = exports.mapRecord = void 0; | ||
| var tslib_1 = require("tslib"); | ||
@@ -21,7 +21,10 @@ var Record_1 = require("fp-ts/Record"); | ||
| */ | ||
| var projectFieldWithEnv = function (t, env, c) { return function (k) { | ||
| return Record_1.record.map(t, function (p) { return p(env, c)[k]; }); | ||
| var projectFieldWithEnv = function (t, env) { return function (k) { | ||
| return Record_1.record.map(t, function (p) { return p(env)[k]; }); | ||
| }; }; | ||
| exports.projectFieldWithEnv = projectFieldWithEnv; | ||
| function conjunction() { | ||
| /** | ||
| * @since 0.0.1 | ||
| */ | ||
| var merge = function () { | ||
| var x = []; | ||
@@ -32,11 +35,7 @@ for (var _i = 0; _i < arguments.length; _i++) { | ||
| return Object.assign.apply(Object, tslib_1.__spreadArrays([{}], x)); | ||
| } | ||
| exports.conjunction = conjunction; | ||
| }; | ||
| exports.merge = merge; | ||
| /** | ||
| * @since 0.0.1 | ||
| */ | ||
| exports.merge = conjunction; | ||
| /** | ||
| * @since 0.0.1 | ||
| */ | ||
| var collect = function (d, f) { return Record_1.collect(f)(d); }; | ||
@@ -57,1 +56,29 @@ exports.collect = collect; | ||
| exports.memo = memo; | ||
| /** | ||
| * @since 0.0.1 | ||
| * | ||
| * Returns a function returning the index of the first guard matching a particular Objet | ||
| * Caching the result under the given Symbol inside the Object | ||
| */ | ||
| var getGuardId = function (guards, sym) { | ||
| var len = guards.length; | ||
| return function (a) { | ||
| var isObj = typeof a === 'object' && a !== null; | ||
| if (isObj) { | ||
| var r = a[sym]; | ||
| if (r !== undefined) { | ||
| return r; | ||
| } | ||
| } | ||
| for (var i = 0; i < len; i++) { | ||
| if (guards[i](a)._tag === 'Right') { | ||
| if (isObj) { | ||
| a[sym] = i; | ||
| } | ||
| return i; | ||
| } | ||
| } | ||
| return -1; | ||
| }; | ||
| }; | ||
| exports.getGuardId = getGuardId; |
+2
-2
| { | ||
| "name": "@morphic-ts/common", | ||
| "version": "3.0.0-alpha.4", | ||
| "version": "3.0.0-alpha.5", | ||
| "description": "Morphic core common package", | ||
@@ -53,3 +53,3 @@ "author": "Stéphane Le Dorze <stephane.ledorze@gmail.com>", | ||
| }, | ||
| "gitHead": "bfecb6c0a52cbbd27891ac1e10a08a20ed78b2f0" | ||
| "gitHead": "6814d93b5dcebaaea723702136acb47a3ba15d2e" | ||
| } |
17681
2.42%536
14.29%