diff --git a/packages/lib/Tools.ts b/packages/lib/Tools.ts index 7ec01b7..f7c6e54 100644 --- a/packages/lib/Tools.ts +++ b/packages/lib/Tools.ts @@ -1,7 +1,7 @@ import {throttle} from 'throttle-debounce' import {bech32, utf8} from "@scure/base" -// Data types +// Dealing with nil export type Nil = null | undefined @@ -117,6 +117,8 @@ export const ne = (v: T) => (x: T) => x !== v export const prop = (k: string) => (x: Record) => x[k] +export const assoc = (k: K, v: T) => (o: U) => ({...o, [k as K]: v}) as U & Record + export const hash = (s: string) => Math.abs(s.split("").reduce((a, b) => ((a << 5) - a + b.charCodeAt(0)) | 0, 0)).toString()