Effect Key
retab-ui/effect-keyFreeUtility
Dependency-array key helpers for keyed effect lifecycles.
Install it
npx shadcn@latest add https://ui.retab.com/r/effect-key.jsonSource
1const objectEffectKeys = new WeakMap<object, string>();2let nextObjectEffectKey = 1;34export function effectKey(value: unknown): string {5 if (value === null) return "null";67 const valueType = typeof value;8 if (valueType === "object" || valueType === "function") {9 return objectEffectKey(value as object);10 }11 if (typeof value === "string") return `string:${value.length}:${value}`;12 if (typeof value === "symbol") {13 return `symbol:${String((value as symbol).description)}`;14 }15 return `${valueType}:${String(value)}`;16}1718export function joinEffectKey(parts: readonly unknown[]): string {19 return parts.map(effectKey).join("\u0000");20}2122function objectEffectKey(value: object): string {23 const existingKey = objectEffectKeys.get(value);24 if (existingKey) return existingKey;2526 const key = `object:${nextObjectEffectKey}`;27 nextObjectEffectKey += 1;28 objectEffectKeys.set(value, key);29 return key;30}
Files it writes
More from retab-ui
All 130 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| CSV parsercsv | retab-ui | Utilities | Free | no deps · 4 files | |
| Document source modeldocument-source | retab-ui | Utilities | Free | no deps | |
| DOCX Document Resourcedocx-document-resource | retab-ui | Utilities | Free | no deps · 5 files | |
| PDF Document Resourcepdf-document-resource | retab-ui | Utilities | Free | 1 dep · 6 files | |
| Segment Interactionsegment-interaction | retab-ui | Utilities | Free | no deps | |
| Segments modelsegments | retab-ui | Utilities | Free | no deps | |
| Utilsutils | retab-ui | Utilities | Free | 2 deps | |
| XLSX SheetJS flattenerxlsx-sheetjs-flattener | retab-ui | Utilities | Free | 1 dep |
