@morphic-ts/common
Advanced tools
Comparing version 0.7.0-alpha.0 to 1.0.0-alpha.0
@@ -5,7 +5,7 @@ import { Kind, URIS, URIS2, Kind2 } from './HKT'; | ||
*/ | ||
export declare type OfType<F extends URIS, A> = Kind<F, A>; | ||
export declare type OfType<F extends URIS, A, RC> = Kind<F, RC, A>; | ||
/** | ||
* @since 0.0.1 | ||
*/ | ||
export declare type OfType2<F extends URIS2, L, A> = Kind2<F, L, A>; | ||
export declare type OfType2<F extends URIS2, L, A, RC> = Kind2<F, RC, L, A>; | ||
declare type Function1 = (a: any) => any; | ||
@@ -33,3 +33,3 @@ /** | ||
*/ | ||
export declare type KeepNotUndefined<O> = UnionToIntersection<NonNullable<{ | ||
export declare type KeepNotUndefinedOrUnknown<O> = UnionToIntersection<NonNullable<{ | ||
[k in keyof O]: undefined extends O[k] ? never : { | ||
@@ -39,3 +39,3 @@ [x in k]: O[k]; | ||
}[keyof O]>>; | ||
declare type KeepOptionalIfUndefined<O> = UnionToIntersection<NonNullable<{ | ||
export declare type KeepOptionalIfUndefinedOrUnknownOrUnknown<O> = UnionToIntersection<NonNullable<{ | ||
[k in keyof O]: undefined extends O[k] ? { | ||
@@ -48,45 +48,3 @@ [x in k]?: O[k]; | ||
*/ | ||
export declare type OptionalIfUndefined<T> = Compact<KeepNotUndefined<T> & KeepOptionalIfUndefined<T>>; | ||
/** | ||
* Expose Configuration type for (a) specific interpreter(s) types | ||
* @since 0.0.1 | ||
*/ | ||
export declare type ByInterp<Config, Interp extends URIS | URIS2> = MaybeUndefinedIfOptional<OptionalIfUndefined<{ | ||
[I in Interp]: I extends keyof Config ? Config[I] : undefined; | ||
}>>; | ||
/** | ||
* @since 0.0.1 | ||
*/ | ||
export declare type MaybeUndefinedIfOptional<X> = keyof KeepNotUndefined<X> extends never ? X | undefined : X; | ||
/** | ||
* @since 0.0.1 | ||
*/ | ||
export declare type isOptionalConfig<C, Y> = keyof KeepNotUndefined<ByInterp<C, URIS | URIS2>> extends never ? Y : 'a configuration is required'; | ||
/** | ||
* generates a config wrapper: | ||
* | ||
* Example: | ||
* | ||
* ```typescript | ||
* const eqConfig = genConfig(EqURI) | ||
* ``` | ||
* | ||
* Usage: | ||
* | ||
* ```typescript | ||
* summonAs(F => F.unknown(eqConfig({ compare: 'default-circular' }))) | ||
* summonAs(F => F.unknown({...eqConfig({ compare: 'default-circular' }), ...iotsConfig(x => x)})) | ||
* ``` | ||
* | ||
* @since 0.0.1 | ||
*/ | ||
export declare const genConfig: <Uri extends URIS | URIS2>(uri: Uri) => ConfigWrapper<Uri>; | ||
/** | ||
* @since 0.0.1 | ||
*/ | ||
export interface ConfigWrapper<Uri extends URIS | URIS2> { | ||
<T>(config: T extends { | ||
[k in Uri]?: infer Config; | ||
} ? Config : never): T; | ||
} | ||
export declare type OptionalIfUndefinedOrUnknown<T> = Compact<KeepNotUndefinedOrUnknown<T> & KeepOptionalIfUndefinedOrUnknownOrUnknown<T>>; | ||
export {}; |
@@ -19,20 +19,1 @@ /** | ||
} | ||
/** | ||
* generates a config wrapper: | ||
* | ||
* Example: | ||
* | ||
* ```typescript | ||
* const eqConfig = genConfig(EqURI) | ||
* ``` | ||
* | ||
* Usage: | ||
* | ||
* ```typescript | ||
* summonAs(F => F.unknown(eqConfig({ compare: 'default-circular' }))) | ||
* summonAs(F => F.unknown({...eqConfig({ compare: 'default-circular' }), ...iotsConfig(x => x)})) | ||
* ``` | ||
* | ||
* @since 0.0.1 | ||
*/ | ||
export const genConfig = uri => config => ({ [uri]: config }); |
@@ -8,4 +8,5 @@ /** | ||
*/ | ||
export interface HKT<URI, A> { | ||
export interface HKT<URI, R, A> { | ||
readonly _URI: URI; | ||
(_R: R): void; | ||
readonly _A: A; | ||
@@ -17,3 +18,3 @@ } | ||
*/ | ||
export interface HKT2<URI, E, A> extends HKT<URI, A> { | ||
export interface HKT2<URI, R, E, A> extends HKT<URI, R, A> { | ||
readonly _E: E; | ||
@@ -25,3 +26,4 @@ } | ||
*/ | ||
export interface URItoKind<A> { | ||
export interface URItoKind<R, A> { | ||
_R: R; | ||
_A: A; | ||
@@ -33,3 +35,4 @@ } | ||
*/ | ||
export interface URItoKind2<E, A> { | ||
export interface URItoKind2<R, E, A> { | ||
_R: R; | ||
_A: A; | ||
@@ -42,3 +45,3 @@ _E: E; | ||
*/ | ||
export declare type URIS = Exclude<keyof URItoKind<any>, '_A'>; | ||
export declare type URIS = Exclude<keyof URItoKind<any, any>, '_A' | '_R'>; | ||
/** | ||
@@ -48,3 +51,3 @@ * `* -> * -> *` constructors | ||
*/ | ||
export declare type URIS2 = Exclude<keyof URItoKind2<any, any>, '_A' | '_E'>; | ||
export declare type URIS2 = Exclude<keyof URItoKind2<any, any, any>, '_A' | '_E' | '_R'>; | ||
/** | ||
@@ -54,3 +57,3 @@ * `* -> *` constructors | ||
*/ | ||
export declare type Kind<URI extends URIS, A> = URI extends URIS ? URItoKind<A>[URI] : any; | ||
export declare type Kind<URI extends URIS, R, A> = URI extends URIS ? URItoKind<R, A>[URI] : any; | ||
/** | ||
@@ -60,2 +63,2 @@ * `* -> * -> *` constructors | ||
*/ | ||
export declare type Kind2<URI extends URIS2, E, A> = URI extends URIS2 ? URItoKind2<E, A>[URI] : any; | ||
export declare type Kind2<URI extends URIS2, R, E, A> = URI extends URIS2 ? URItoKind2<R, E, A>[URI] : any; |
@@ -12,2 +12,6 @@ /** | ||
*/ | ||
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; | ||
@@ -37,1 +41,3 @@ export declare function conjunction<A, B, C>(...x: [A, B, C]): A & B & C; | ||
export declare const memo: <A>(get: () => A) => () => A; | ||
export declare type IsNever<X, Y, N> = 'X' | X extends 'X' ? Y : N; | ||
export declare type Includes<A, B, Y, N> = IsNever<B, Y, A extends B ? Y : N>; |
@@ -10,2 +10,6 @@ import { record } from 'fp-ts'; | ||
export const projectField = (t) => (k) => record.record.map(t, p => p[k]); | ||
/** | ||
* @since 0.0.1 | ||
*/ | ||
export const projectFieldWithEnv = (t, env) => (k) => record.record.map(t, p => p(env)[k]); | ||
export function conjunction(...x) { | ||
@@ -12,0 +16,0 @@ return Object.assign({}, ...x); |
@@ -5,7 +5,7 @@ import { Kind, URIS, URIS2, Kind2 } from './HKT'; | ||
*/ | ||
export declare type OfType<F extends URIS, A> = Kind<F, A>; | ||
export declare type OfType<F extends URIS, A, RC> = Kind<F, RC, A>; | ||
/** | ||
* @since 0.0.1 | ||
*/ | ||
export declare type OfType2<F extends URIS2, L, A> = Kind2<F, L, A>; | ||
export declare type OfType2<F extends URIS2, L, A, RC> = Kind2<F, RC, L, A>; | ||
declare type Function1 = (a: any) => any; | ||
@@ -33,3 +33,3 @@ /** | ||
*/ | ||
export declare type KeepNotUndefined<O> = UnionToIntersection<NonNullable<{ | ||
export declare type KeepNotUndefinedOrUnknown<O> = UnionToIntersection<NonNullable<{ | ||
[k in keyof O]: undefined extends O[k] ? never : { | ||
@@ -39,3 +39,3 @@ [x in k]: O[k]; | ||
}[keyof O]>>; | ||
declare type KeepOptionalIfUndefined<O> = UnionToIntersection<NonNullable<{ | ||
export declare type KeepOptionalIfUndefinedOrUnknownOrUnknown<O> = UnionToIntersection<NonNullable<{ | ||
[k in keyof O]: undefined extends O[k] ? { | ||
@@ -48,45 +48,3 @@ [x in k]?: O[k]; | ||
*/ | ||
export declare type OptionalIfUndefined<T> = Compact<KeepNotUndefined<T> & KeepOptionalIfUndefined<T>>; | ||
/** | ||
* Expose Configuration type for (a) specific interpreter(s) types | ||
* @since 0.0.1 | ||
*/ | ||
export declare type ByInterp<Config, Interp extends URIS | URIS2> = MaybeUndefinedIfOptional<OptionalIfUndefined<{ | ||
[I in Interp]: I extends keyof Config ? Config[I] : undefined; | ||
}>>; | ||
/** | ||
* @since 0.0.1 | ||
*/ | ||
export declare type MaybeUndefinedIfOptional<X> = keyof KeepNotUndefined<X> extends never ? X | undefined : X; | ||
/** | ||
* @since 0.0.1 | ||
*/ | ||
export declare type isOptionalConfig<C, Y> = keyof KeepNotUndefined<ByInterp<C, URIS | URIS2>> extends never ? Y : 'a configuration is required'; | ||
/** | ||
* generates a config wrapper: | ||
* | ||
* Example: | ||
* | ||
* ```typescript | ||
* const eqConfig = genConfig(EqURI) | ||
* ``` | ||
* | ||
* Usage: | ||
* | ||
* ```typescript | ||
* summonAs(F => F.unknown(eqConfig({ compare: 'default-circular' }))) | ||
* summonAs(F => F.unknown({...eqConfig({ compare: 'default-circular' }), ...iotsConfig(x => x)})) | ||
* ``` | ||
* | ||
* @since 0.0.1 | ||
*/ | ||
export declare const genConfig: <Uri extends URIS | URIS2>(uri: Uri) => ConfigWrapper<Uri>; | ||
/** | ||
* @since 0.0.1 | ||
*/ | ||
export interface ConfigWrapper<Uri extends URIS | URIS2> { | ||
<T>(config: T extends { | ||
[k in Uri]?: infer Config; | ||
} ? Config : never): T; | ||
} | ||
export declare type OptionalIfUndefinedOrUnknown<T> = Compact<KeepNotUndefinedOrUnknown<T> & KeepOptionalIfUndefinedOrUnknownOrUnknown<T>>; | ||
export {}; |
@@ -22,23 +22,1 @@ "use strict"; | ||
exports.cacheUnaryFunction = cacheUnaryFunction; | ||
/** | ||
* generates a config wrapper: | ||
* | ||
* Example: | ||
* | ||
* ```typescript | ||
* const eqConfig = genConfig(EqURI) | ||
* ``` | ||
* | ||
* Usage: | ||
* | ||
* ```typescript | ||
* summonAs(F => F.unknown(eqConfig({ compare: 'default-circular' }))) | ||
* summonAs(F => F.unknown({...eqConfig({ compare: 'default-circular' }), ...iotsConfig(x => x)})) | ||
* ``` | ||
* | ||
* @since 0.0.1 | ||
*/ | ||
exports.genConfig = function (uri) { return function (config) { | ||
var _a; | ||
return (_a = {}, _a[uri] = config, _a); | ||
}; }; |
@@ -8,4 +8,5 @@ /** | ||
*/ | ||
export interface HKT<URI, A> { | ||
export interface HKT<URI, R, A> { | ||
readonly _URI: URI; | ||
(_R: R): void; | ||
readonly _A: A; | ||
@@ -17,3 +18,3 @@ } | ||
*/ | ||
export interface HKT2<URI, E, A> extends HKT<URI, A> { | ||
export interface HKT2<URI, R, E, A> extends HKT<URI, R, A> { | ||
readonly _E: E; | ||
@@ -25,3 +26,4 @@ } | ||
*/ | ||
export interface URItoKind<A> { | ||
export interface URItoKind<R, A> { | ||
_R: R; | ||
_A: A; | ||
@@ -33,3 +35,4 @@ } | ||
*/ | ||
export interface URItoKind2<E, A> { | ||
export interface URItoKind2<R, E, A> { | ||
_R: R; | ||
_A: A; | ||
@@ -42,3 +45,3 @@ _E: E; | ||
*/ | ||
export declare type URIS = Exclude<keyof URItoKind<any>, '_A'>; | ||
export declare type URIS = Exclude<keyof URItoKind<any, any>, '_A' | '_R'>; | ||
/** | ||
@@ -48,3 +51,3 @@ * `* -> * -> *` constructors | ||
*/ | ||
export declare type URIS2 = Exclude<keyof URItoKind2<any, any>, '_A' | '_E'>; | ||
export declare type URIS2 = Exclude<keyof URItoKind2<any, any, any>, '_A' | '_E' | '_R'>; | ||
/** | ||
@@ -54,3 +57,3 @@ * `* -> *` constructors | ||
*/ | ||
export declare type Kind<URI extends URIS, A> = URI extends URIS ? URItoKind<A>[URI] : any; | ||
export declare type Kind<URI extends URIS, R, A> = URI extends URIS ? URItoKind<R, A>[URI] : any; | ||
/** | ||
@@ -60,2 +63,2 @@ * `* -> * -> *` constructors | ||
*/ | ||
export declare type Kind2<URI extends URIS2, E, A> = URI extends URIS2 ? URItoKind2<E, A>[URI] : any; | ||
export declare type Kind2<URI extends URIS2, R, E, A> = URI extends URIS2 ? URItoKind2<R, E, A>[URI] : any; |
@@ -12,2 +12,6 @@ /** | ||
*/ | ||
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; | ||
@@ -37,1 +41,3 @@ export declare function conjunction<A, B, C>(...x: [A, B, C]): A & B & C; | ||
export declare const memo: <A>(get: () => A) => () => A; | ||
export declare type IsNever<X, Y, N> = 'X' | X extends 'X' ? Y : N; | ||
export declare type Includes<A, B, Y, N> = IsNever<B, Y, A extends B ? Y : N>; |
@@ -15,2 +15,8 @@ "use strict"; | ||
}; }; | ||
/** | ||
* @since 0.0.1 | ||
*/ | ||
exports.projectFieldWithEnv = function (t, env) { return function (k) { | ||
return fp_ts_1.record.record.map(t, function (p) { return p(env)[k]; }); | ||
}; }; | ||
function conjunction() { | ||
@@ -17,0 +23,0 @@ var x = []; |
{ | ||
"name": "@morphic-ts/common", | ||
"version": "0.7.0-alpha.0", | ||
"version": "1.0.0-alpha.0", | ||
"description": "Morphic core common package", | ||
@@ -53,3 +53,3 @@ "author": "Stéphane Le Dorze <stephane.ledorze@gmail.com>", | ||
}, | ||
"gitHead": "33dd3db1be51504ccce523d0ce855ee63812b78e" | ||
"gitHead": "b9182e63aa40877a6a939135b1ace3db0b11a8ac" | ||
} |
19695
19
524