@byjohann/utils
Advanced tools
Comparing version 0.1.2 to 0.2.0
@@ -26,14 +26,18 @@ type MaybeArray<T> = T | T[]; | ||
*/ | ||
declare function objectKeys<T extends object>(obj: T): Array<`${keyof T & (string | number | boolean | null | undefined)}`>; | ||
declare function objectKeys<T extends Record<any, any>>(obj: T): Array<`${keyof T & (string | number | boolean | null | undefined)}`>; | ||
/** | ||
* Strictly typed `Object.entries`. | ||
*/ | ||
declare function objectEntries<T extends object>(obj: T): Array<[keyof T, T[keyof T]]>; | ||
declare function objectEntries<T extends Record<any, any>>(obj: T): Array<[keyof T, T[keyof T]]>; | ||
/** | ||
* Deeply applies a callback to each key-value pair in the object. | ||
*/ | ||
declare function deepApply<T extends Record<any, any>>(data: T, callback: (item: T, key: keyof T, value: T[keyof T]) => void): void; | ||
/** | ||
* Simple template engine to replace variables in a string | ||
* Simple template engine to replace variables in a string. | ||
*/ | ||
declare function template(str: string, variables: Record<string | number, any>, fallback?: string | ((key: string) => string)): string; | ||
/** | ||
* Generates a random string | ||
* Generates a random string. | ||
*/ | ||
@@ -47,2 +51,2 @@ declare function generateRandomId(size?: number, dict?: string): string; | ||
export { type MaybeArray, createCsv, escapeCsvValue, generateRandomId, objectEntries, objectKeys, template, toArray, tryParseJson, unindent }; | ||
export { type MaybeArray, createCsv, deepApply, escapeCsvValue, generateRandomId, objectEntries, objectKeys, template, toArray, tryParseJson, unindent }; |
{ | ||
"name": "@byjohann/utils", | ||
"type": "module", | ||
"version": "0.1.2", | ||
"version": "0.2.0", | ||
"packageManager": "pnpm@9.5.0", | ||
@@ -6,0 +6,0 @@ "description": "A collection of utilities for my projects", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
9028
127