0.12.1 • Published 11 months ago
@canvas-js/utils v0.12.1
@canvas-js/utils
API
assert
export function assert(condition: unknown, message?: string): asserts condition {
if (!condition) {
throw new Error(message ?? "assertion failed")
}
}
signalInvalidType
export function signalInvalidType(type: never): never {
console.error(type)
throw new TypeError("internal error: invalid type")
}
mapEntries
export const mapEntries = <K extends string, S, T>(object: Record<K, S>, map: (entry: [key: K, value: S]) => T) =>
Object.fromEntries(Object.entries<S>(object).map(([key, value]) => [key, map([key as K, value])])) as Record<K, T>
mapKeys
export const mapKeys = <K extends string, S, T>(object: Record<K, S>, map: (key: K) => T) =>
Object.fromEntries(Object.entries<S>(object).map(([key, value]) => [key, map(key as K)])) as Record<K, T>
mapValues
export const mapValues = <K extends string, S, T>(object: Record<K, S>, map: (value: S) => T) =>
Object.fromEntries(Object.entries<S>(object).map(([key, value]) => [key, map(value)])) as Record<K, T>
0.13.0-next.16
11 months ago
0.13.0-next.15
11 months ago
0.13.0-next.14
11 months ago
0.13.0-next.13
11 months ago
0.12.1
11 months ago
0.13.0-next.12
11 months ago
0.13.0-next.11
11 months ago
0.13.0-next.10
11 months ago
0.13.0-next.9
11 months ago
0.13.0-next.8
11 months ago
0.11.0
12 months ago
0.12.0
11 months ago
0.13.0-next.1
11 months ago
0.13.0-next.3
11 months ago
0.13.0-next.2
11 months ago
0.13.0-next.5
11 months ago
0.13.0-next.4
11 months ago
0.13.0-next.7
11 months ago
0.13.0-next.6
11 months ago
0.10.10
1 year ago
0.10.0
1 year ago
0.10.0-alpha.1
1 year ago
0.10.9
1 year ago
0.10.1
1 year ago
0.10.0-beta.2
1 year ago
0.10.2
1 year ago
0.10.0-beta.3
1 year ago
0.10.3
1 year ago
0.10.4
1 year ago
0.10.0-beta.1
1 year ago
0.10.5
1 year ago
0.10.6
1 year ago
0.10.7
1 year ago
0.10.0-beta.4
1 year ago
0.10.8
1 year ago
0.9.1
1 year ago
0.9.0
1 year ago
0.9.0-next.1
1 year ago