@byjohann/utils
Advanced tools
Comparing version 0.3.0 to 0.3.1
@@ -1,59 +0,7 @@ | ||
export { getPathname, joinURL, withLeadingSlash, withTrailingSlash, withoutBase, withoutTrailingSlash } from './path/index.js'; | ||
type MaybeArray<T> = T | T[]; | ||
/** | ||
* Converts `MaybeArray<T>` to `Array<T>`. | ||
*/ | ||
declare function toArray<T>(array?: MaybeArray<T> | null | undefined): T[]; | ||
/** | ||
* Converts an array of objects to a comma-separated values (CSV) string | ||
* that contains only the `columns` specified. | ||
*/ | ||
declare function createCsv<T extends Record<string, any>>(data: T[], columns: (keyof T)[], | ||
/** @default ',' */ | ||
delimiter?: string): string; | ||
declare function escapeCsvValue(value: unknown): string; | ||
/** | ||
* Type-safe wrapper around `JSON.stringify` falling back to the original value | ||
* if it is not a string or an error is thrown. | ||
*/ | ||
declare function tryParseJSON<T = unknown>(value: unknown): T; | ||
declare function interopDefault<T>(m: T | Promise<T>): Promise<T extends { | ||
default: infer U; | ||
} ? U : T>; | ||
/** | ||
* Strictly typed `Object.keys`. | ||
*/ | ||
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 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. | ||
*/ | ||
declare function template(str: string, variables: Record<string | number, any>, fallback?: string | ((key: string) => string)): string; | ||
/** | ||
* Generates a random string. | ||
* | ||
* @remarks Ported from nanoid. | ||
* @see https://github.com/ai/nanoid | ||
*/ | ||
declare function generateRandomId(size?: number, dict?: string): string; | ||
/** | ||
* Removes common leading whitespace from a template string while | ||
* also remove empty lines at the beginning and end. | ||
*/ | ||
declare function unindent(str: TemplateStringsArray | string): string; | ||
export { type MaybeArray, createCsv, deepApply, escapeCsvValue, generateRandomId, interopDefault, objectEntries, objectKeys, template, toArray, tryParseJSON, unindent }; | ||
export { MaybeArray, toArray } from './array.js'; | ||
export { createCsv, escapeCsvValue } from './csv.js'; | ||
export { tryParseJSON } from './json.js'; | ||
export { interopDefault } from './module.js'; | ||
export { deepApply, objectEntries, objectKeys } from './object.js'; | ||
export { getPathname, joinURL, withLeadingSlash, withTrailingSlash, withoutBase, withoutTrailingSlash } from './path.js'; | ||
export { generateRandomId, template, unindent } from './string.js'; |
{ | ||
"name": "@byjohann/utils", | ||
"type": "module", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"packageManager": "pnpm@9.5.0", | ||
@@ -23,5 +23,33 @@ "description": "A collection of utilities for my projects", | ||
}, | ||
"./array": { | ||
"types": "./dist/array.d.mts", | ||
"default": "./dist/array.mjs" | ||
}, | ||
"./csv": { | ||
"types": "./dist/csv.d.mts", | ||
"default": "./dist/csv.mjs" | ||
}, | ||
"./is": { | ||
"types": "./dist/is.d.mts", | ||
"default": "./dist/is.mjs" | ||
}, | ||
"./json": { | ||
"types": "./dist/json.d.mts", | ||
"default": "./dist/json.mjs" | ||
}, | ||
"./module": { | ||
"types": "./dist/module.d.mts", | ||
"default": "./dist/module.mjs" | ||
}, | ||
"./object": { | ||
"types": "./dist/object.d.mts", | ||
"default": "./dist/object.mjs" | ||
}, | ||
"./path": { | ||
"types": "./dist/path/index.d.mts", | ||
"default": "./dist/path/index.mjs" | ||
"types": "./dist/path.d.mts", | ||
"default": "./dist/path.mjs" | ||
}, | ||
"./string": { | ||
"types": "./dist/string.d.mts", | ||
"default": "./dist/string.mjs" | ||
} | ||
@@ -28,0 +56,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
15067
30
241
1