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