@faast/ts-common
Advanced tools
Comparing version 0.2.1 to 0.2.2
import * as t from 'io-ts'; | ||
export declare function partialRecord<KS extends t.KeyofType<any>, T extends t.Any>(k: KS, type: T, name?: string): t.PartialC<Record<keyof KS['keys'], T>>; | ||
export declare function autoImplement<T>(getValues: () => T): new () => T; | ||
export declare const nullable: <T extends t.Mixed>(codec: T) => t.UnionC<[T, t.NullC]>; | ||
@@ -3,0 +5,0 @@ export declare const optional: <T extends t.Mixed>(codec: T) => t.UnionC<[T, t.UndefinedC]>; |
import * as t from 'io-ts'; | ||
import { map } from 'fp-ts/lib/Record'; | ||
import { isEmptyObject } from '#/guards'; | ||
export function partialRecord(k, type, name) { | ||
return t.partial(map(k.keys, () => type), name); | ||
} | ||
export function autoImplement(getValues) { | ||
return class { | ||
constructor() { | ||
Object.assign(this, getValues()); | ||
} | ||
}; | ||
} | ||
export const nullable = (codec) => t.union([codec, t.nullType], `${codec.name}Nullable`); | ||
@@ -4,0 +15,0 @@ export const optional = (codec) => t.union([codec, t.undefined], `${codec.name}Optional`); |
export * from './DateT'; | ||
export * from './Logger'; | ||
export * from './helpers'; | ||
export * from './basic'; |
{ | ||
"name": "@faast/ts-common", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "Common typescript types and utils used by faast", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
import * as t from 'io-ts' | ||
import { map } from 'fp-ts/lib/Record' | ||
import { isEmptyObject } from '#/guards' | ||
export function partialRecord<KS extends t.KeyofType<any>, T extends t.Any>( | ||
k: KS, | ||
type: T, | ||
name?: string, | ||
): t.PartialC<Record<keyof KS['keys'], T>> { | ||
return t.partial(map(k.keys, () => type) as any, name) | ||
} | ||
export function autoImplement<T>(getValues: () => T) { | ||
return class { | ||
constructor() { | ||
Object.assign(this, getValues()) | ||
} | ||
} as new () => T | ||
} | ||
export const nullable = <T extends t.Mixed>(codec: T) => t.union([codec, t.nullType], `${codec.name}Nullable`) | ||
@@ -5,0 +22,0 @@ export const optional = <T extends t.Mixed>(codec: T) => t.union([codec, t.undefined], `${codec.name}Optional`) |
export * from './DateT' | ||
export * from './Logger' | ||
export * from './helpers' | ||
export * from './basic' |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
599854
55
7860
1