Add abortThunk, bump versions

This commit is contained in:
Jon Staab
2025-01-29 10:08:58 -08:00
parent 5522d7d2a0
commit 369a89dc60
6 changed files with 20 additions and 8 deletions
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "@welshman/lib",
"version": "0.0.38",
"version": "0.0.39",
"author": "hodlbod",
"license": "MIT",
"description": "A collection of utilities.",
@@ -30,4 +30,4 @@
"@types/events": "^3.0.3",
"events": "^3.3.0"
}
}
}
+7 -1
View File
@@ -622,12 +622,18 @@ export const prop =
(x: Record<string, unknown>) =>
x[k] as T
/** Returns a function that adds/updates property on object */
/** Returns a function that adds/updates a property on object */
export const assoc =
<K extends string, T, U>(k: K, v: T) =>
(o: U) =>
({...o, [k as K]: v}) as U & Record<K, T>
/** Returns a function that removes a property on object */
export const dissoc =
<K extends string, T extends Obj>(k: K) =>
(o: T) =>
omit([k], o)
/** Generates a hash string from input string */
export const hash = (s: string) =>
Math.abs(s.split("").reduce((a, b) => ((a << 5) - a + b.charCodeAt(0)) | 0, 0)).toString()