0.12.1 • Published 8 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
8 months ago
0.13.0-next.15
8 months ago
0.13.0-next.14
8 months ago
0.13.0-next.13
8 months ago
0.12.1
8 months ago
0.13.0-next.12
8 months ago
0.13.0-next.11
8 months ago
0.13.0-next.10
8 months ago
0.13.0-next.9
8 months ago
0.13.0-next.8
8 months ago
0.11.0
9 months ago
0.12.0
8 months ago
0.13.0-next.1
8 months ago
0.13.0-next.3
8 months ago
0.13.0-next.2
8 months ago
0.13.0-next.5
8 months ago
0.13.0-next.4
8 months ago
0.13.0-next.7
8 months ago
0.13.0-next.6
8 months ago
0.10.10
10 months ago
0.10.0
11 months ago
0.10.0-alpha.1
1 year ago
0.10.9
10 months ago
0.10.1
11 months ago
0.10.0-beta.2
1 year ago
0.10.2
11 months ago
0.10.0-beta.3
12 months ago
0.10.3
11 months ago
0.10.4
11 months ago
0.10.0-beta.1
1 year ago
0.10.5
10 months ago
0.10.6
10 months ago
0.10.7
10 months ago
0.10.0-beta.4
12 months ago
0.10.8
10 months ago
0.9.1
1 year ago
0.9.0
1 year ago
0.9.0-next.1
1 year ago