utilful 2.5.0 → 2.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/array.mjs +1 -2
- package/dist/csv.d.mts +2 -5
- package/dist/csv.mjs +1 -2
- package/dist/defu.mjs +1 -2
- package/dist/emitter.mjs +1 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +2 -3
- package/dist/json.mjs +1 -2
- package/dist/module.mjs +1 -2
- package/dist/object.d.mts +5 -1
- package/dist/object.mjs +4 -2
- package/dist/path.mjs +1 -2
- package/dist/result.d.mts +2 -2
- package/dist/result.mjs +1 -2
- package/dist/string.mjs +2 -3
- package/dist/types.mjs +1 -1
- package/package.json +9 -8
package/dist/array.mjs
CHANGED
package/dist/csv.d.mts
CHANGED
|
@@ -102,9 +102,7 @@ declare function createCSVAsync<T extends Record<string, unknown>>(data: AsyncIt
|
|
|
102
102
|
* escapeCSVValue('contains "quotes"') // "contains ""quotes"""
|
|
103
103
|
*/
|
|
104
104
|
declare function escapeCSVValue(value: unknown, options?: {
|
|
105
|
-
/** @default ',' */
|
|
106
|
-
delimiter?: string;
|
|
107
|
-
/** @default false */
|
|
105
|
+
/** @default ',' */delimiter?: string; /** @default false */
|
|
108
106
|
quoteAll?: boolean;
|
|
109
107
|
}): string;
|
|
110
108
|
/**
|
|
@@ -122,8 +120,7 @@ declare function escapeCSVValue(value: unknown, options?: {
|
|
|
122
120
|
* // [{ name: 'John', age: '30' }, { name: 'Jane', age: '25' }]
|
|
123
121
|
*/
|
|
124
122
|
declare function parseCSV<Header extends string>(csv?: string | null | undefined, options?: {
|
|
125
|
-
/** @default ',' */
|
|
126
|
-
delimiter?: string;
|
|
123
|
+
/** @default ',' */delimiter?: string;
|
|
127
124
|
/**
|
|
128
125
|
* Trim whitespace from headers and values.
|
|
129
126
|
* @default true
|
package/dist/csv.mjs
CHANGED
|
@@ -291,6 +291,5 @@ function inferColumns(rows) {
|
|
|
291
291
|
}
|
|
292
292
|
return columns;
|
|
293
293
|
}
|
|
294
|
-
|
|
295
294
|
//#endregion
|
|
296
|
-
export { createCSV, createCSVAsync, createCSVStream, escapeCSVValue, parseCSV, parseCSVFromLines, parseCSVStream };
|
|
295
|
+
export { createCSV, createCSVAsync, createCSVStream, escapeCSVValue, parseCSV, parseCSVFromLines, parseCSVStream };
|
package/dist/defu.mjs
CHANGED
package/dist/emitter.mjs
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -4,9 +4,9 @@ import { DefuFn, DefuMerger, createDefu, defu } from "./defu.mjs";
|
|
|
4
4
|
import { Emitter, EventHandlerList, EventHandlerMap, EventType, Handler, WildCardEventHandlerList, WildcardHandler, createEmitter } from "./emitter.mjs";
|
|
5
5
|
import { cloneJSON, tryParseJSON } from "./json.mjs";
|
|
6
6
|
import { interopDefault } from "./module.mjs";
|
|
7
|
-
import { deepApply, memoize, objectEntries, objectKeys } from "./object.mjs";
|
|
7
|
+
import { deepApply, isObject, memoize, objectEntries, objectKeys } from "./object.mjs";
|
|
8
8
|
import { QueryObject, QueryValue, getPathname, joinURL, withBase, withLeadingSlash, withQuery, withTrailingSlash, withoutBase, withoutLeadingSlash, withoutTrailingSlash } from "./path.mjs";
|
|
9
9
|
import { Err, ErrData, Ok, OkData, Result, ResultData, err, isErr, isOk, ok, toResult, tryCatch, unwrapResult } from "./result.mjs";
|
|
10
10
|
import { generateRandomId, template } from "./string.mjs";
|
|
11
11
|
import { AutocompletableString, BrandedType, LooseAutocomplete, UnifyIntersection } from "./types.mjs";
|
|
12
|
-
export { AutocompletableString, BrandedType, CSVCreateOptions, CSVRow, DefuFn, DefuMerger, Emitter, Err, ErrData, EventHandlerList, EventHandlerMap, EventType, Handler, LooseAutocomplete, MaybeArray, Ok, OkData, QueryObject, QueryValue, Result, ResultData, UnifyIntersection, WildCardEventHandlerList, WildcardHandler, cloneJSON, createCSV, createCSVAsync, createCSVStream, createDefu, createEmitter, deepApply, defu, err, escapeCSVValue, generateRandomId, getPathname, interopDefault, isErr, isOk, joinURL, memoize, objectEntries, objectKeys, ok, parseCSV, parseCSVFromLines, parseCSVStream, template, toArray, toResult, tryCatch, tryParseJSON, unwrapResult, withBase, withLeadingSlash, withQuery, withTrailingSlash, withoutBase, withoutLeadingSlash, withoutTrailingSlash };
|
|
12
|
+
export { AutocompletableString, BrandedType, CSVCreateOptions, CSVRow, DefuFn, DefuMerger, Emitter, Err, ErrData, EventHandlerList, EventHandlerMap, EventType, Handler, LooseAutocomplete, MaybeArray, Ok, OkData, QueryObject, QueryValue, Result, ResultData, UnifyIntersection, WildCardEventHandlerList, WildcardHandler, cloneJSON, createCSV, createCSVAsync, createCSVStream, createDefu, createEmitter, deepApply, defu, err, escapeCSVValue, generateRandomId, getPathname, interopDefault, isErr, isObject, isOk, joinURL, memoize, objectEntries, objectKeys, ok, parseCSV, parseCSVFromLines, parseCSVStream, template, toArray, toResult, tryCatch, tryParseJSON, unwrapResult, withBase, withLeadingSlash, withQuery, withTrailingSlash, withoutBase, withoutLeadingSlash, withoutTrailingSlash };
|
package/dist/index.mjs
CHANGED
|
@@ -4,9 +4,8 @@ import { createDefu, defu } from "./defu.mjs";
|
|
|
4
4
|
import { createEmitter } from "./emitter.mjs";
|
|
5
5
|
import { cloneJSON, tryParseJSON } from "./json.mjs";
|
|
6
6
|
import { interopDefault } from "./module.mjs";
|
|
7
|
-
import { deepApply, memoize, objectEntries, objectKeys } from "./object.mjs";
|
|
7
|
+
import { deepApply, isObject, memoize, objectEntries, objectKeys } from "./object.mjs";
|
|
8
8
|
import { getPathname, joinURL, withBase, withLeadingSlash, withQuery, withTrailingSlash, withoutBase, withoutLeadingSlash, withoutTrailingSlash } from "./path.mjs";
|
|
9
9
|
import { Err, Ok, err, isErr, isOk, ok, toResult, tryCatch, unwrapResult } from "./result.mjs";
|
|
10
10
|
import { generateRandomId, template } from "./string.mjs";
|
|
11
|
-
|
|
12
|
-
export { Err, Ok, cloneJSON, createCSV, createCSVAsync, createCSVStream, createDefu, createEmitter, deepApply, defu, err, escapeCSVValue, generateRandomId, getPathname, interopDefault, isErr, isOk, joinURL, memoize, objectEntries, objectKeys, ok, parseCSV, parseCSVFromLines, parseCSVStream, template, toArray, toResult, tryCatch, tryParseJSON, unwrapResult, withBase, withLeadingSlash, withQuery, withTrailingSlash, withoutBase, withoutLeadingSlash, withoutTrailingSlash };
|
|
11
|
+
export { Err, Ok, cloneJSON, createCSV, createCSVAsync, createCSVStream, createDefu, createEmitter, deepApply, defu, err, escapeCSVValue, generateRandomId, getPathname, interopDefault, isErr, isObject, isOk, joinURL, memoize, objectEntries, objectKeys, ok, parseCSV, parseCSVFromLines, parseCSVStream, template, toArray, toResult, tryCatch, tryParseJSON, unwrapResult, withBase, withLeadingSlash, withQuery, withTrailingSlash, withoutBase, withoutLeadingSlash, withoutTrailingSlash };
|
package/dist/json.mjs
CHANGED
package/dist/module.mjs
CHANGED
package/dist/object.d.mts
CHANGED
|
@@ -28,5 +28,9 @@ declare function objectEntries<T extends Record<any, any>>(obj: T): Array<[keyof
|
|
|
28
28
|
* Deeply applies a callback to every key-value pair in the given object, as well as nested objects and arrays.
|
|
29
29
|
*/
|
|
30
30
|
declare function deepApply<T extends Record<any, any>>(data: T, callback: (item: T, key: keyof T, value: T[keyof T]) => void): void;
|
|
31
|
+
/**
|
|
32
|
+
* Checks if a value is a plain object.
|
|
33
|
+
*/
|
|
34
|
+
declare function isObject(value: unknown): value is Record<any, any>;
|
|
31
35
|
//#endregion
|
|
32
|
-
export { deepApply, memoize, objectEntries, objectKeys };
|
|
36
|
+
export { deepApply, isObject, memoize, objectEntries, objectKeys };
|
package/dist/object.mjs
CHANGED
|
@@ -43,9 +43,11 @@ function deepApply(data, callback) {
|
|
|
43
43
|
} else if (isObject(value)) deepApply(value, callback);
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* Checks if a value is a plain object.
|
|
48
|
+
*/
|
|
46
49
|
function isObject(value) {
|
|
47
50
|
return Object.prototype.toString.call(value) === "[object Object]";
|
|
48
51
|
}
|
|
49
|
-
|
|
50
52
|
//#endregion
|
|
51
|
-
export { deepApply, memoize, objectEntries, objectKeys };
|
|
53
|
+
export { deepApply, isObject, memoize, objectEntries, objectKeys };
|
package/dist/path.mjs
CHANGED
|
@@ -123,6 +123,5 @@ function normalizeQueryValue(value) {
|
|
|
123
123
|
if (typeof value === "object") return JSON.stringify(value);
|
|
124
124
|
return String(value);
|
|
125
125
|
}
|
|
126
|
-
|
|
127
126
|
//#endregion
|
|
128
|
-
export { getPathname, joinURL, withBase, withLeadingSlash, withQuery, withTrailingSlash, withoutBase, withoutLeadingSlash, withoutTrailingSlash };
|
|
127
|
+
export { getPathname, joinURL, withBase, withLeadingSlash, withQuery, withTrailingSlash, withoutBase, withoutLeadingSlash, withoutTrailingSlash };
|
package/dist/result.d.mts
CHANGED
|
@@ -16,7 +16,7 @@ type ResultData<T, E> = OkData<T> | ErrData<E>;
|
|
|
16
16
|
*/
|
|
17
17
|
declare class Ok<T, E = never> {
|
|
18
18
|
readonly value: T;
|
|
19
|
-
readonly ok
|
|
19
|
+
readonly ok = true;
|
|
20
20
|
constructor(value: T);
|
|
21
21
|
/** Transforms the success value. */
|
|
22
22
|
map<U>(fn: (value: T) => U): Ok<U, E>;
|
|
@@ -41,7 +41,7 @@ declare class Ok<T, E = never> {
|
|
|
41
41
|
*/
|
|
42
42
|
declare class Err<T, E> {
|
|
43
43
|
readonly error: E;
|
|
44
|
-
readonly ok
|
|
44
|
+
readonly ok = false;
|
|
45
45
|
constructor(error: E);
|
|
46
46
|
/** No-op on Err, returns self with new value type. */
|
|
47
47
|
map<U>(_fn: (value: T) => U): Err<U, E>;
|
package/dist/result.mjs
CHANGED
|
@@ -104,6 +104,5 @@ function tryCatch(fnOrPromise) {
|
|
|
104
104
|
if (fnOrPromise instanceof Promise) return toResult(fnOrPromise).then((result) => unwrapResult(result));
|
|
105
105
|
return unwrapResult(toResult(fnOrPromise));
|
|
106
106
|
}
|
|
107
|
-
|
|
108
107
|
//#endregion
|
|
109
|
-
export { Err, Ok, err, isErr, isOk, ok, toResult, tryCatch, unwrapResult };
|
|
108
|
+
export { Err, Ok, err, isErr, isOk, ok, toResult, tryCatch, unwrapResult };
|
package/dist/string.mjs
CHANGED
|
@@ -11,7 +11,7 @@ const URL_ALPHABET = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvw
|
|
|
11
11
|
*/
|
|
12
12
|
function template(str, variables, fallback) {
|
|
13
13
|
return str.replace(/\{(\w+)\}/g, (_, key) => {
|
|
14
|
-
return variables[key]
|
|
14
|
+
return variables[key] != null ? String(variables[key]) : (typeof fallback === "function" ? fallback(key) : fallback) ?? key;
|
|
15
15
|
});
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
@@ -27,6 +27,5 @@ function generateRandomId(size = 16, dict = URL_ALPHABET) {
|
|
|
27
27
|
while (i--) id += dict[Math.random() * len | 0];
|
|
28
28
|
return id;
|
|
29
29
|
}
|
|
30
|
-
|
|
31
30
|
//#endregion
|
|
32
|
-
export { generateRandomId, template };
|
|
31
|
+
export { generateRandomId, template };
|
package/dist/types.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "utilful",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.5.
|
|
5
|
-
"packageManager": "pnpm@10.
|
|
4
|
+
"version": "2.5.2",
|
|
5
|
+
"packageManager": "pnpm@10.30.3",
|
|
6
6
|
"description": "A collection of TypeScript utilities",
|
|
7
7
|
"author": "Johann Schopplich <hello@johannschopplich.com>",
|
|
8
8
|
"license": "MIT",
|
|
@@ -78,13 +78,14 @@
|
|
|
78
78
|
"release": "bumpp"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
81
|
-
"@antfu/eslint-config": "^7.
|
|
82
|
-
"@types/node": "^25.
|
|
83
|
-
"bumpp": "^10.4.
|
|
84
|
-
"eslint": "^
|
|
85
|
-
"
|
|
81
|
+
"@antfu/eslint-config": "^7.6.1",
|
|
82
|
+
"@types/node": "^25.3.5",
|
|
83
|
+
"bumpp": "^10.4.1",
|
|
84
|
+
"eslint": "^10.0.2",
|
|
85
|
+
"eslint-flat-config-utils": "^3.0.1",
|
|
86
|
+
"tsdown": "^0.21.0",
|
|
86
87
|
"typescript": "^5.9.3",
|
|
87
|
-
"vitest": "^4.0.
|
|
88
|
+
"vitest": "^4.0.18"
|
|
88
89
|
},
|
|
89
90
|
"pnpm": {
|
|
90
91
|
"onlyBuiltDependencies": [
|