umsizi 0.3.0 → 0.5.0
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/README.md +62 -0
- package/dist/index.d.ts +74 -5
- package/dist/index.js +57 -4
- package/dist/index.js.map +1 -1
- package/dist/next.d.ts +23 -2
- package/dist/next.js +28 -2
- package/dist/next.js.map +1 -0
- package/dist/node.d.ts +19 -2
- package/dist/node.js +22 -2
- package/dist/node.js.map +1 -0
- package/dist/react.d.ts +22 -2
- package/dist/react.js +24 -2
- package/dist/react.js.map +1 -0
- package/package.json +1 -1
- package/dist/index-DtjbEW43.d.ts +0 -19
- package/dist/index-dktuz4mv.d.ts +0 -22
- package/dist/index-rZiv1o95.d.ts +0 -23
- package/dist/next-C3wp7UoQ.js +0 -29
- package/dist/next-C3wp7UoQ.js.map +0 -1
- package/dist/node-D-nlzpmG.js +0 -23
- package/dist/node-D-nlzpmG.js.map +0 -1
- package/dist/react-BCidSnzT.js +0 -25
- package/dist/react-BCidSnzT.js.map +0 -1
package/README.md
CHANGED
|
@@ -198,6 +198,68 @@ if (hasOwn(user, key)) {
|
|
|
198
198
|
}
|
|
199
199
|
```
|
|
200
200
|
|
|
201
|
+
#### `isPlainObject`
|
|
202
|
+
|
|
203
|
+
```ts
|
|
204
|
+
import { isPlainObject } from "umsizi";
|
|
205
|
+
|
|
206
|
+
const payload: unknown = { id: "1" };
|
|
207
|
+
|
|
208
|
+
if (isPlainObject(payload)) {
|
|
209
|
+
payload.id;
|
|
210
|
+
}
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
#### `isRecord`
|
|
214
|
+
|
|
215
|
+
```ts
|
|
216
|
+
import { isRecord } from "umsizi";
|
|
217
|
+
|
|
218
|
+
const payload: unknown = { id: "1" };
|
|
219
|
+
|
|
220
|
+
if (isRecord(payload)) {
|
|
221
|
+
payload.id;
|
|
222
|
+
}
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
#### `hasKeys`
|
|
226
|
+
|
|
227
|
+
```ts
|
|
228
|
+
import { hasKeys } from "umsizi";
|
|
229
|
+
|
|
230
|
+
const user = { id: "1", role: "admin" } as const;
|
|
231
|
+
|
|
232
|
+
if (hasKeys(user, "id", "role")) {
|
|
233
|
+
user.id;
|
|
234
|
+
user.role;
|
|
235
|
+
}
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
#### `requireKeys`
|
|
239
|
+
|
|
240
|
+
```ts
|
|
241
|
+
import { requireKeys } from "umsizi";
|
|
242
|
+
|
|
243
|
+
const user = { id: "1", role: "admin" } as const;
|
|
244
|
+
const ensured = requireKeys(user, "id", "role");
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
#### `assertKeys`
|
|
248
|
+
|
|
249
|
+
```ts
|
|
250
|
+
import { assertKeys } from "umsizi";
|
|
251
|
+
|
|
252
|
+
const user: { id?: string; role?: string } = {
|
|
253
|
+
id: "1",
|
|
254
|
+
role: "admin",
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
assertKeys(user, "id", "role");
|
|
258
|
+
|
|
259
|
+
user.id;
|
|
260
|
+
user.role;
|
|
261
|
+
```
|
|
262
|
+
|
|
201
263
|
#### `mapValues`
|
|
202
264
|
|
|
203
265
|
```ts
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
//#region src/core/assert-keys.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Asserts that a plain object has all of the requested own keys.
|
|
4
|
+
*
|
|
5
|
+
* Prefer the rest-key form for the strongest autocomplete and inference.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* const user = { id: "1", role: "admin" } as const;
|
|
10
|
+
*
|
|
11
|
+
* assertKeys(user, "id", "role");
|
|
12
|
+
* user.id; // "1"
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
declare function assertKeys<T extends object, const FirstKey extends keyof T, const RestKeys extends readonly (keyof T)[]>(value: T, firstKey: FirstKey, ...restKeys: RestKeys): asserts value is T & Required<Pick<T, FirstKey | RestKeys[number]>>;
|
|
16
|
+
declare function assertKeys<T extends object, const FirstKey extends keyof T, const RestKeys extends readonly (keyof T)[]>(value: T, keys: readonly [FirstKey, ...RestKeys]): asserts value is T & Required<Pick<T, FirstKey | RestKeys[number]>>;
|
|
17
|
+
declare function assertKeys<T extends object>(value: T, keys: readonly (keyof T)[]): asserts value is T;
|
|
18
|
+
//#endregion
|
|
5
19
|
//#region src/core/types.d.ts
|
|
6
20
|
type StringKeyOf<T extends object> = Extract<keyof T, string>;
|
|
7
21
|
type ObjectEntry<T extends object> = { [K in StringKeyOf<T>]: readonly [K, T[K]] }[StringKeyOf<T>];
|
|
@@ -49,6 +63,24 @@ declare function compactObject<T extends object>(object: T): CompactedObject<T>;
|
|
|
49
63
|
declare function filterValues<T extends object, S extends T[Extract<keyof T, string>]>(object: T, predicate: ValueGuard<T, S>): FilteredValues<T, S>;
|
|
50
64
|
declare function filterValues<T extends object>(object: T, predicate: ValuePredicate<T>): FilteredValues<T, T[Extract<keyof T, string>]>;
|
|
51
65
|
//#endregion
|
|
66
|
+
//#region src/core/has-keys.d.ts
|
|
67
|
+
/**
|
|
68
|
+
* Checks whether a plain object has all of the requested own keys.
|
|
69
|
+
*
|
|
70
|
+
* Prefer the rest-key form for the strongest autocomplete and inference.
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```ts
|
|
74
|
+
* const user = { id: "1", role: "admin" } as const;
|
|
75
|
+
*
|
|
76
|
+
* hasKeys(user, "id", "role"); // true
|
|
77
|
+
* hasKeys(user, ["id", "role"] as const); // true
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
declare function hasKeys<T extends object, const FirstKey extends keyof T, const RestKeys extends readonly (keyof T)[]>(value: T, firstKey: FirstKey, ...restKeys: RestKeys): value is T & Required<Pick<T, FirstKey | RestKeys[number]>>;
|
|
81
|
+
declare function hasKeys<T extends object, const FirstKey extends keyof T, const RestKeys extends readonly (keyof T)[]>(value: T, keys: readonly [FirstKey, ...RestKeys]): value is T & Required<Pick<T, FirstKey | RestKeys[number]>>;
|
|
82
|
+
declare function hasKeys<T extends object>(value: T, keys: readonly (keyof T)[]): value is T;
|
|
83
|
+
//#endregion
|
|
52
84
|
//#region src/core/has-own.d.ts
|
|
53
85
|
/**
|
|
54
86
|
* Checks whether an object has the given property as its own key.
|
|
@@ -97,6 +129,25 @@ declare function identity<T>(value: T): T;
|
|
|
97
129
|
*/
|
|
98
130
|
declare function isEmpty(object: object): boolean;
|
|
99
131
|
//#endregion
|
|
132
|
+
//#region src/core/is-plain-object.d.ts
|
|
133
|
+
/**
|
|
134
|
+
* Checks whether a value is a plain object with a prototype of
|
|
135
|
+
* `Object.prototype` or `null`.
|
|
136
|
+
*
|
|
137
|
+
* Arrays, functions, boxed primitives, dates, maps, sets, and class instances
|
|
138
|
+
* all return `false`.
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* ```ts
|
|
142
|
+
* const payload: unknown = { id: "1" };
|
|
143
|
+
*
|
|
144
|
+
* if (isPlainObject(payload)) {
|
|
145
|
+
* payload.id;
|
|
146
|
+
* }
|
|
147
|
+
* ```
|
|
148
|
+
*/
|
|
149
|
+
declare function isPlainObject(value: unknown): value is Record<PropertyKey, unknown>;
|
|
150
|
+
//#endregion
|
|
100
151
|
//#region src/core/map-values.d.ts
|
|
101
152
|
/**
|
|
102
153
|
* Maps the values of an object's own enumerable string-keyed properties while
|
|
@@ -148,6 +199,24 @@ declare function pick<T extends object, const Keys extends readonly (keyof T)[]>
|
|
|
148
199
|
declare function pick<T extends object, const FirstKey extends keyof T, const RestKeys extends readonly (keyof T)[]>(object: T, keys: readonly [FirstKey, ...RestKeys]): Pick<T, FirstKey | RestKeys[number]>;
|
|
149
200
|
declare function pick<T extends object>(object: T, keys: readonly (keyof T)[]): Partial<T>;
|
|
150
201
|
//#endregion
|
|
202
|
+
//#region src/core/require-keys.d.ts
|
|
203
|
+
/**
|
|
204
|
+
* Requires that a plain object has all of the requested own keys.
|
|
205
|
+
*
|
|
206
|
+
* Prefer the rest-key form for the strongest autocomplete and inference.
|
|
207
|
+
*
|
|
208
|
+
* @example
|
|
209
|
+
* ```ts
|
|
210
|
+
* const user = { id: "1", role: "admin" } as const;
|
|
211
|
+
* const result = requireKeys(user, "id", "role");
|
|
212
|
+
*
|
|
213
|
+
* result.id; // "1"
|
|
214
|
+
* ```
|
|
215
|
+
*/
|
|
216
|
+
declare function requireKeys<T extends object, const FirstKey extends keyof T, const RestKeys extends readonly (keyof T)[]>(value: T, firstKey: FirstKey, ...restKeys: RestKeys): T & Required<Pick<T, FirstKey | RestKeys[number]>>;
|
|
217
|
+
declare function requireKeys<T extends object, const FirstKey extends keyof T, const RestKeys extends readonly (keyof T)[]>(value: T, keys: readonly [FirstKey, ...RestKeys]): T & Required<Pick<T, FirstKey | RestKeys[number]>>;
|
|
218
|
+
declare function requireKeys<T extends object>(value: T, keys: readonly (keyof T)[]): T;
|
|
219
|
+
//#endregion
|
|
151
220
|
//#region src/core/typed-entries.d.ts
|
|
152
221
|
/**
|
|
153
222
|
* Returns the own enumerable string-keyed entries of an object with preserved
|
|
@@ -198,5 +267,5 @@ declare function typedFromEntries<const T extends EntryTuples>(entries: T): Obje
|
|
|
198
267
|
*/
|
|
199
268
|
declare function typedKeys<T extends object>(object: T): Array<StringKeyOf<T>>;
|
|
200
269
|
//#endregion
|
|
201
|
-
export { compactObject, filterValues,
|
|
270
|
+
export { assertKeys, compactObject, filterValues, hasKeys, hasOwn, identity, isEmpty, isPlainObject, isPlainObject as isRecord, mapValues, omit, pick, requireKeys, typedEntries, typedFromEntries, typedKeys };
|
|
202
271
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
//#region src/core/has-keys.ts
|
|
2
|
+
function hasKeys(value, firstKeyOrKeys, ...restKeys) {
|
|
3
|
+
if (value === null || typeof value !== "object") return false;
|
|
4
|
+
const prototype = Object.getPrototypeOf(value);
|
|
5
|
+
if (prototype !== Object.prototype && prototype !== null) return false;
|
|
6
|
+
const keys = Array.isArray(firstKeyOrKeys) ? firstKeyOrKeys : [firstKeyOrKeys, ...restKeys];
|
|
7
|
+
for (const key of keys) if (!Object.hasOwn(value, key)) return false;
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region src/core/require-keys.ts
|
|
13
|
+
function requireKeys(value, firstKeyOrKeys, ...restKeys) {
|
|
14
|
+
const keys = Array.isArray(firstKeyOrKeys) ? firstKeyOrKeys : [firstKeyOrKeys, ...restKeys];
|
|
15
|
+
if (hasKeys(value, keys)) return value;
|
|
16
|
+
const missingKeys = [];
|
|
17
|
+
if (value !== null && typeof value === "object") {
|
|
18
|
+
const prototype = Object.getPrototypeOf(value);
|
|
19
|
+
if (prototype === Object.prototype || prototype === null) {
|
|
20
|
+
for (const key of keys) if (!Object.hasOwn(value, key)) missingKeys.push(key);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
if (missingKeys.length === 0) missingKeys.push(...keys);
|
|
24
|
+
throw new TypeError(`M:${missingKeys.map(String).join()}`);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/core/assert-keys.ts
|
|
29
|
+
function assertKeys(value, firstKeyOrKeys, ...restKeys) {
|
|
30
|
+
requireKeys(value, firstKeyOrKeys, ...restKeys);
|
|
31
|
+
}
|
|
4
32
|
|
|
33
|
+
//#endregion
|
|
5
34
|
//#region src/core/typed-keys.ts
|
|
6
35
|
/**
|
|
7
36
|
* Returns the own enumerable string keys of an object with preserved key types.
|
|
@@ -112,6 +141,30 @@ function isEmpty(object) {
|
|
|
112
141
|
return true;
|
|
113
142
|
}
|
|
114
143
|
|
|
144
|
+
//#endregion
|
|
145
|
+
//#region src/core/is-plain-object.ts
|
|
146
|
+
/**
|
|
147
|
+
* Checks whether a value is a plain object with a prototype of
|
|
148
|
+
* `Object.prototype` or `null`.
|
|
149
|
+
*
|
|
150
|
+
* Arrays, functions, boxed primitives, dates, maps, sets, and class instances
|
|
151
|
+
* all return `false`.
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* ```ts
|
|
155
|
+
* const payload: unknown = { id: "1" };
|
|
156
|
+
*
|
|
157
|
+
* if (isPlainObject(payload)) {
|
|
158
|
+
* payload.id;
|
|
159
|
+
* }
|
|
160
|
+
* ```
|
|
161
|
+
*/
|
|
162
|
+
function isPlainObject(value) {
|
|
163
|
+
if (value === null || typeof value !== "object") return false;
|
|
164
|
+
const prototype = Object.getPrototypeOf(value);
|
|
165
|
+
return prototype === Object.prototype || prototype === null;
|
|
166
|
+
}
|
|
167
|
+
|
|
115
168
|
//#endregion
|
|
116
169
|
//#region src/core/map-values.ts
|
|
117
170
|
/**
|
|
@@ -193,5 +246,5 @@ function typedFromEntries(entries) {
|
|
|
193
246
|
}
|
|
194
247
|
|
|
195
248
|
//#endregion
|
|
196
|
-
export { compactObject, filterValues,
|
|
249
|
+
export { assertKeys, compactObject, filterValues, hasKeys, hasOwn, identity, isEmpty, isPlainObject, isPlainObject as isRecord, mapValues, omit, pick, requireKeys, typedEntries, typedFromEntries, typedKeys };
|
|
197
250
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["result: Partial<T>","result: Partial<T>"],"sources":["../src/core/typed-keys.ts","../src/core/compact-object.ts","../src/core/filter-values.ts","../src/core/has-own.ts","../src/core/identity.ts","../src/core/is-empty.ts","../src/core/map-values.ts","../src/core/omit.ts","../src/core/pick.ts","../src/core/typed-entries.ts","../src/core/typed-from-entries.ts"],"sourcesContent":["import type { StringKeyOf } from \"./types\";\n\n/**\n * Returns the own enumerable string keys of an object with preserved key types.\n *\n * This is a typed wrapper around `Object.keys`.\n *\n * @example\n * ```ts\n * const user = { id: \"1\", name: \"Umsizi\" } as const;\n *\n * typedKeys(user); // [\"id\", \"name\"]\n * ```\n */\nexport function typedKeys<T extends object>(object: T): Array<StringKeyOf<T>> {\n\treturn Object.keys(object) as Array<StringKeyOf<T>>;\n}\n","import { typedKeys } from \"./typed-keys\";\nimport type { CompactedObject } from \"./types\";\n\n/**\n * Creates a new object with all `null` and `undefined` values removed.\n *\n * Other falsy values such as `0`, `false`, `\"\"`, and `NaN` are preserved.\n *\n * @example\n * ```ts\n * const user = { id: \"1\", nickname: null, active: false } as const;\n *\n * compactObject(user); // { id: \"1\", active: false }\n * ```\n */\nexport function compactObject<T extends object>(object: T): CompactedObject<T> {\n\tconst result = {} as CompactedObject<T>;\n\n\tfor (const key of typedKeys(object)) {\n\t\tconst value = object[key];\n\n\t\tif (value != null) {\n\t\t\tresult[key] = value as Exclude<T[typeof key], null | undefined>;\n\t\t}\n\t}\n\n\treturn result;\n}\n","import { typedKeys } from \"./typed-keys\";\nimport type { FilteredValues, ValueGuard, ValuePredicate } from \"./types\";\n\n/**\n * Filters an object's own enumerable string-keyed properties by value.\n *\n * Supports both boolean predicates and type-guard predicates. The result type\n * remains partial because any property may be removed at runtime.\n *\n * @example\n * ```ts\n * const settings = { retries: 3, label: \"\", timeout: null } as const;\n *\n * filterValues(settings, (value) => value !== null);\n * // { retries: 3, label: \"\" }\n * ```\n */\nexport function filterValues<\n\tT extends object,\n\tS extends T[Extract<keyof T, string>],\n>(object: T, predicate: ValueGuard<T, S>): FilteredValues<T, S>;\nexport function filterValues<T extends object>(\n\tobject: T,\n\tpredicate: ValuePredicate<T>,\n): FilteredValues<T, T[Extract<keyof T, string>]>;\nexport function filterValues<T extends object>(\n\tobject: T,\n\tpredicate: ValuePredicate<T>,\n): FilteredValues<T, T[Extract<keyof T, string>]> {\n\tconst result = {} as FilteredValues<T, T[Extract<keyof T, string>]>;\n\n\tfor (const key of typedKeys(object)) {\n\t\tconst value = object[key];\n\n\t\tif (predicate(value, key, object)) {\n\t\t\tresult[key] = value;\n\t\t}\n\t}\n\n\treturn result;\n}\n","/**\n * Checks whether an object has the given property as its own key.\n *\n * This is a typed wrapper around `Object.hasOwn` that narrows the provided key\n * when the check succeeds.\n *\n * @example\n * ```ts\n * const user = { id: \"1\" };\n * const key: string = \"id\";\n *\n * if (hasOwn(user, key)) {\n * user[key]; // key is narrowed to \"id\"\n * }\n * ```\n */\nexport function hasOwn<T extends object, K extends PropertyKey>(\n\tobject: T,\n\tkey: K,\n): key is Extract<K, keyof T> {\n\treturn Object.hasOwn(object, key);\n}\n","/**\n * Returns the given value unchanged.\n *\n * Useful as a default callback, a type-inference anchor, or a no-op\n * placeholder where a transform function is expected.\n *\n * @example\n * ```ts\n * identity(\"umsizi\"); // \"umsizi\"\n * ```\n */\nexport function identity<T>(value: T): T {\n\treturn value;\n}\n","/**\n * Returns `true` when an object has no own enumerable properties.\n *\n * Both string keys and symbol keys are considered. Non-enumerable properties\n * are ignored.\n *\n * @example\n * ```ts\n * isEmpty({}); // true\n * isEmpty({ id: \"1\" }); // false\n * ```\n */\nexport function isEmpty(object: object): boolean {\n\tif (Object.keys(object).length > 0) {\n\t\treturn false;\n\t}\n\n\tfor (const key of Object.getOwnPropertySymbols(object)) {\n\t\tif (Object.prototype.propertyIsEnumerable.call(object, key)) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\treturn true;\n}\n","import { typedKeys } from \"./typed-keys\";\nimport type { MappedValues, ValueMapper } from \"./types\";\n\n/**\n * Maps the values of an object's own enumerable string-keyed properties while\n * preserving the original enumerable string-key set.\n *\n * @example\n * ```ts\n * const counts = { draft: 1, published: 2 };\n *\n * mapValues(counts, (value) => value * 2);\n * // { draft: 2, published: 4 }\n * ```\n */\nexport function mapValues<T extends object, R>(\n\tobject: T,\n\tmapper: ValueMapper<T, R>,\n): MappedValues<T, R> {\n\tconst result = {} as MappedValues<T, R>;\n\n\tfor (const key of typedKeys(object)) {\n\t\tresult[key] = mapper(object[key], key, object);\n\t}\n\n\treturn result;\n}\n","/**\n * Creates a new object excluding the selected own enumerable properties.\n *\n * Prefer the rest-key form for the strongest autocomplete and inference.\n *\n * @example\n * ```ts\n * const user = { id: \"1\", name: \"Umsizi\", role: \"admin\" } as const;\n *\n * omit(user, \"id\", \"name\"); // { role: \"admin\" }\n * omit(user, [\"role\"] as const); // { id: \"1\", name: \"Umsizi\" }\n * ```\n */\nexport function omit<T extends object, const Keys extends readonly (keyof T)[]>(\n\tobject: T,\n\t...keys: Keys\n): Omit<T, Keys[number]>;\nexport function omit<\n\tT extends object,\n\tconst FirstKey extends keyof T,\n\tconst RestKeys extends readonly (keyof T)[],\n>(\n\tobject: T,\n\tkeys: readonly [FirstKey, ...RestKeys],\n): Omit<T, FirstKey | RestKeys[number]>;\nexport function omit<T extends object>(\n\tobject: T,\n\tkeys: readonly (keyof T)[],\n): Partial<T>;\nexport function omit<T extends object>(\n\tobject: T,\n\tfirstKeyOrKeys: keyof T | readonly (keyof T)[],\n\t...restKeys: readonly (keyof T)[]\n): Partial<T> {\n\tconst keys = (\n\t\tArray.isArray(firstKeyOrKeys)\n\t\t\t? firstKeyOrKeys\n\t\t\t: [firstKeyOrKeys, ...restKeys]\n\t) as readonly (keyof T)[];\n\tconst omittedKeys = new Set<PropertyKey>(keys as readonly PropertyKey[]);\n\tconst result: Partial<T> = {};\n\n\tfor (const key of Reflect.ownKeys(object) as (keyof T)[]) {\n\t\tif (\n\t\t\tObject.prototype.propertyIsEnumerable.call(object, key) &&\n\t\t\t!omittedKeys.has(key)\n\t\t) {\n\t\t\t(result as T)[key] = object[key];\n\t\t}\n\t}\n\n\treturn result;\n}\n","import { hasOwn } from \"./has-own\";\n\n/**\n * Creates a new object containing only the selected own properties.\n *\n * Prefer the rest-key form for the strongest autocomplete and inference.\n *\n * @example\n * ```ts\n * const user = { id: \"1\", name: \"Umsizi\", role: \"admin\" } as const;\n *\n * pick(user, \"name\"); // { name: \"Umsizi\" }\n * pick(user, [\"id\", \"role\"] as const); // { id: \"1\", role: \"admin\" }\n * ```\n */\nexport function pick<T extends object, const Keys extends readonly (keyof T)[]>(\n\tobject: T,\n\t...keys: Keys\n): Pick<T, Keys[number]>;\nexport function pick<\n\tT extends object,\n\tconst FirstKey extends keyof T,\n\tconst RestKeys extends readonly (keyof T)[],\n>(\n\tobject: T,\n\tkeys: readonly [FirstKey, ...RestKeys],\n): Pick<T, FirstKey | RestKeys[number]>;\nexport function pick<T extends object>(\n\tobject: T,\n\tkeys: readonly (keyof T)[],\n): Partial<T>;\nexport function pick<T extends object>(\n\tobject: T,\n\tfirstKeyOrKeys: keyof T | readonly (keyof T)[],\n\t...restKeys: readonly (keyof T)[]\n): Partial<T> {\n\tconst keys = (\n\t\tArray.isArray(firstKeyOrKeys)\n\t\t\t? firstKeyOrKeys\n\t\t\t: [firstKeyOrKeys, ...restKeys]\n\t) as readonly (keyof T)[];\n\tconst result: Partial<T> = {};\n\n\tfor (const key of keys) {\n\t\tif (hasOwn(object, key)) {\n\t\t\tresult[key] = object[key];\n\t\t}\n\t}\n\n\treturn result;\n}\n","import type { ObjectEntries } from \"./types\";\n\n/**\n * Returns the own enumerable string-keyed entries of an object with preserved\n * key/value pairing.\n *\n * This is a typed wrapper around `Object.entries`.\n *\n * @example\n * ```ts\n * const user = { id: \"1\", active: true } as const;\n *\n * typedEntries(user); // [[\"id\", \"1\"], [\"active\", true]]\n * ```\n */\nexport function typedEntries<T extends object>(object: T): ObjectEntries<T> {\n\treturn Object.entries(object) as unknown as ObjectEntries<T>;\n}\n","import type { EntryTuples, ObjectFromEntries } from \"./types\";\n\n/**\n * Creates an object from entries while preserving the key and value types from\n * the input tuple array.\n *\n * This is a typed wrapper around `Object.fromEntries`.\n *\n * @example\n * ```ts\n * const status = typedFromEntries([\n * [\"id\", \"1\"],\n * [\"active\", true],\n * ] as const);\n *\n * // inferred as: { id: \"1\"; active: true }\n * ```\n */\nexport function typedFromEntries<const T extends EntryTuples>(\n\tentries: T,\n): ObjectFromEntries<T> {\n\treturn Object.fromEntries(entries) as ObjectFromEntries<T>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAcA,SAAgB,UAA4B,QAAkC;AAC7E,QAAO,OAAO,KAAK,OAAO;;;;;;;;;;;;;;;;;ACA3B,SAAgB,cAAgC,QAA+B;CAC9E,MAAM,SAAS,EAAE;AAEjB,MAAK,MAAM,OAAO,UAAU,OAAO,EAAE;EACpC,MAAM,QAAQ,OAAO;AAErB,MAAI,SAAS,KACZ,QAAO,OAAO;;AAIhB,QAAO;;;;;ACDR,SAAgB,aACf,QACA,WACiD;CACjD,MAAM,SAAS,EAAE;AAEjB,MAAK,MAAM,OAAO,UAAU,OAAO,EAAE;EACpC,MAAM,QAAQ,OAAO;AAErB,MAAI,UAAU,OAAO,KAAK,OAAO,CAChC,QAAO,OAAO;;AAIhB,QAAO;;;;;;;;;;;;;;;;;;;;;ACvBR,SAAgB,OACf,QACA,KAC6B;AAC7B,QAAO,OAAO,OAAO,QAAQ,IAAI;;;;;;;;;;;;;;;;ACTlC,SAAgB,SAAY,OAAa;AACxC,QAAO;;;;;;;;;;;;;;;;;ACAR,SAAgB,QAAQ,QAAyB;AAChD,KAAI,OAAO,KAAK,OAAO,CAAC,SAAS,EAChC,QAAO;AAGR,MAAK,MAAM,OAAO,OAAO,sBAAsB,OAAO,CACrD,KAAI,OAAO,UAAU,qBAAqB,KAAK,QAAQ,IAAI,CAC1D,QAAO;AAIT,QAAO;;;;;;;;;;;;;;;;;ACRR,SAAgB,UACf,QACA,QACqB;CACrB,MAAM,SAAS,EAAE;AAEjB,MAAK,MAAM,OAAO,UAAU,OAAO,CAClC,QAAO,OAAO,OAAO,OAAO,MAAM,KAAK,OAAO;AAG/C,QAAO;;;;;ACIR,SAAgB,KACf,QACA,gBACA,GAAG,UACU;CACb,MAAM,OACL,MAAM,QAAQ,eAAe,GAC1B,iBACA,CAAC,gBAAgB,GAAG,SAAS;CAEjC,MAAM,cAAc,IAAI,IAAiB,KAA+B;CACxE,MAAMA,SAAqB,EAAE;AAE7B,MAAK,MAAM,OAAO,QAAQ,QAAQ,OAAO,CACxC,KACC,OAAO,UAAU,qBAAqB,KAAK,QAAQ,IAAI,IACvD,CAAC,YAAY,IAAI,IAAI,CAErB,CAAC,OAAa,OAAO,OAAO;AAI9B,QAAO;;;;;ACpBR,SAAgB,KACf,QACA,gBACA,GAAG,UACU;CACb,MAAM,OACL,MAAM,QAAQ,eAAe,GAC1B,iBACA,CAAC,gBAAgB,GAAG,SAAS;CAEjC,MAAMC,SAAqB,EAAE;AAE7B,MAAK,MAAM,OAAO,KACjB,KAAI,OAAO,QAAQ,IAAI,CACtB,QAAO,OAAO,OAAO;AAIvB,QAAO;;;;;;;;;;;;;;;;;;AClCR,SAAgB,aAA+B,QAA6B;AAC3E,QAAO,OAAO,QAAQ,OAAO;;;;;;;;;;;;;;;;;;;;;ACE9B,SAAgB,iBACf,SACuB;AACvB,QAAO,OAAO,YAAY,QAAQ"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["missingKeys: Array<keyof T>","result: Partial<T>","result: Partial<T>"],"sources":["../src/core/has-keys.ts","../src/core/require-keys.ts","../src/core/assert-keys.ts","../src/core/typed-keys.ts","../src/core/compact-object.ts","../src/core/filter-values.ts","../src/core/has-own.ts","../src/core/identity.ts","../src/core/is-empty.ts","../src/core/is-plain-object.ts","../src/core/map-values.ts","../src/core/omit.ts","../src/core/pick.ts","../src/core/typed-entries.ts","../src/core/typed-from-entries.ts"],"sourcesContent":["/**\n * Checks whether a plain object has all of the requested own keys.\n *\n * Prefer the rest-key form for the strongest autocomplete and inference.\n *\n * @example\n * ```ts\n * const user = { id: \"1\", role: \"admin\" } as const;\n *\n * hasKeys(user, \"id\", \"role\"); // true\n * hasKeys(user, [\"id\", \"role\"] as const); // true\n * ```\n */\nexport function hasKeys<\n\tT extends object,\n\tconst FirstKey extends keyof T,\n\tconst RestKeys extends readonly (keyof T)[],\n>(\n\tvalue: T,\n\tfirstKey: FirstKey,\n\t...restKeys: RestKeys\n): value is T & Required<Pick<T, FirstKey | RestKeys[number]>>;\nexport function hasKeys<\n\tT extends object,\n\tconst FirstKey extends keyof T,\n\tconst RestKeys extends readonly (keyof T)[],\n>(\n\tvalue: T,\n\tkeys: readonly [FirstKey, ...RestKeys],\n): value is T & Required<Pick<T, FirstKey | RestKeys[number]>>;\nexport function hasKeys<T extends object>(\n\tvalue: T,\n\tkeys: readonly (keyof T)[],\n): value is T;\nexport function hasKeys<T extends object>(\n\tvalue: T,\n\tfirstKeyOrKeys: keyof T | readonly (keyof T)[],\n\t...restKeys: readonly (keyof T)[]\n): boolean {\n\tif (value === null || typeof value !== \"object\") {\n\t\treturn false;\n\t}\n\n\tconst prototype = Object.getPrototypeOf(value);\n\n\tif (prototype !== Object.prototype && prototype !== null) {\n\t\treturn false;\n\t}\n\n\tconst keys = Array.isArray(firstKeyOrKeys)\n\t\t? firstKeyOrKeys\n\t\t: ([firstKeyOrKeys, ...restKeys] as readonly (keyof T)[]);\n\n\tfor (const key of keys) {\n\t\tif (!Object.hasOwn(value, key)) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\treturn true;\n}\n","import { hasKeys } from \"./has-keys\";\n\n/**\n * Requires that a plain object has all of the requested own keys.\n *\n * Prefer the rest-key form for the strongest autocomplete and inference.\n *\n * @example\n * ```ts\n * const user = { id: \"1\", role: \"admin\" } as const;\n * const result = requireKeys(user, \"id\", \"role\");\n *\n * result.id; // \"1\"\n * ```\n */\nexport function requireKeys<\n\tT extends object,\n\tconst FirstKey extends keyof T,\n\tconst RestKeys extends readonly (keyof T)[],\n>(\n\tvalue: T,\n\tfirstKey: FirstKey,\n\t...restKeys: RestKeys\n): T & Required<Pick<T, FirstKey | RestKeys[number]>>;\nexport function requireKeys<\n\tT extends object,\n\tconst FirstKey extends keyof T,\n\tconst RestKeys extends readonly (keyof T)[],\n>(\n\tvalue: T,\n\tkeys: readonly [FirstKey, ...RestKeys],\n): T & Required<Pick<T, FirstKey | RestKeys[number]>>;\nexport function requireKeys<T extends object>(\n\tvalue: T,\n\tkeys: readonly (keyof T)[],\n): T;\nexport function requireKeys<T extends object>(\n\tvalue: T,\n\tfirstKeyOrKeys: keyof T | readonly (keyof T)[],\n\t...restKeys: readonly (keyof T)[]\n): T {\n\tconst keys = Array.isArray(firstKeyOrKeys)\n\t\t? firstKeyOrKeys\n\t\t: ([firstKeyOrKeys, ...restKeys] as readonly (keyof T)[]);\n\n\tif (hasKeys(value, keys)) {\n\t\treturn value;\n\t}\n\n\tconst missingKeys: Array<keyof T> = [];\n\n\tif (value !== null && typeof value === \"object\") {\n\t\tconst prototype = Object.getPrototypeOf(value);\n\n\t\tif (prototype === Object.prototype || prototype === null) {\n\t\t\tfor (const key of keys) {\n\t\t\t\tif (!Object.hasOwn(value, key)) {\n\t\t\t\t\tmissingKeys.push(key);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif (missingKeys.length === 0) {\n\t\tmissingKeys.push(...keys);\n\t}\n\n\tthrow new TypeError(`M:${missingKeys.map(String).join()}`);\n}\n","import { requireKeys } from \"./require-keys\";\n\n/**\n * Asserts that a plain object has all of the requested own keys.\n *\n * Prefer the rest-key form for the strongest autocomplete and inference.\n *\n * @example\n * ```ts\n * const user = { id: \"1\", role: \"admin\" } as const;\n *\n * assertKeys(user, \"id\", \"role\");\n * user.id; // \"1\"\n * ```\n */\nexport function assertKeys<\n\tT extends object,\n\tconst FirstKey extends keyof T,\n\tconst RestKeys extends readonly (keyof T)[],\n>(\n\tvalue: T,\n\tfirstKey: FirstKey,\n\t...restKeys: RestKeys\n): asserts value is T & Required<Pick<T, FirstKey | RestKeys[number]>>;\nexport function assertKeys<\n\tT extends object,\n\tconst FirstKey extends keyof T,\n\tconst RestKeys extends readonly (keyof T)[],\n>(\n\tvalue: T,\n\tkeys: readonly [FirstKey, ...RestKeys],\n): asserts value is T & Required<Pick<T, FirstKey | RestKeys[number]>>;\nexport function assertKeys<T extends object>(\n\tvalue: T,\n\tkeys: readonly (keyof T)[],\n): asserts value is T;\nexport function assertKeys<T extends object>(\n\tvalue: T,\n\tfirstKeyOrKeys: keyof T | readonly (keyof T)[],\n\t...restKeys: readonly (keyof T)[]\n): void {\n\trequireKeys(value, firstKeyOrKeys as keyof T, ...restKeys);\n}\n","import type { StringKeyOf } from \"./types\";\n\n/**\n * Returns the own enumerable string keys of an object with preserved key types.\n *\n * This is a typed wrapper around `Object.keys`.\n *\n * @example\n * ```ts\n * const user = { id: \"1\", name: \"Umsizi\" } as const;\n *\n * typedKeys(user); // [\"id\", \"name\"]\n * ```\n */\nexport function typedKeys<T extends object>(object: T): Array<StringKeyOf<T>> {\n\treturn Object.keys(object) as Array<StringKeyOf<T>>;\n}\n","import { typedKeys } from \"./typed-keys\";\nimport type { CompactedObject } from \"./types\";\n\n/**\n * Creates a new object with all `null` and `undefined` values removed.\n *\n * Other falsy values such as `0`, `false`, `\"\"`, and `NaN` are preserved.\n *\n * @example\n * ```ts\n * const user = { id: \"1\", nickname: null, active: false } as const;\n *\n * compactObject(user); // { id: \"1\", active: false }\n * ```\n */\nexport function compactObject<T extends object>(object: T): CompactedObject<T> {\n\tconst result = {} as CompactedObject<T>;\n\n\tfor (const key of typedKeys(object)) {\n\t\tconst value = object[key];\n\n\t\tif (value != null) {\n\t\t\tresult[key] = value as Exclude<T[typeof key], null | undefined>;\n\t\t}\n\t}\n\n\treturn result;\n}\n","import { typedKeys } from \"./typed-keys\";\nimport type { FilteredValues, ValueGuard, ValuePredicate } from \"./types\";\n\n/**\n * Filters an object's own enumerable string-keyed properties by value.\n *\n * Supports both boolean predicates and type-guard predicates. The result type\n * remains partial because any property may be removed at runtime.\n *\n * @example\n * ```ts\n * const settings = { retries: 3, label: \"\", timeout: null } as const;\n *\n * filterValues(settings, (value) => value !== null);\n * // { retries: 3, label: \"\" }\n * ```\n */\nexport function filterValues<\n\tT extends object,\n\tS extends T[Extract<keyof T, string>],\n>(object: T, predicate: ValueGuard<T, S>): FilteredValues<T, S>;\nexport function filterValues<T extends object>(\n\tobject: T,\n\tpredicate: ValuePredicate<T>,\n): FilteredValues<T, T[Extract<keyof T, string>]>;\nexport function filterValues<T extends object>(\n\tobject: T,\n\tpredicate: ValuePredicate<T>,\n): FilteredValues<T, T[Extract<keyof T, string>]> {\n\tconst result = {} as FilteredValues<T, T[Extract<keyof T, string>]>;\n\n\tfor (const key of typedKeys(object)) {\n\t\tconst value = object[key];\n\n\t\tif (predicate(value, key, object)) {\n\t\t\tresult[key] = value;\n\t\t}\n\t}\n\n\treturn result;\n}\n","/**\n * Checks whether an object has the given property as its own key.\n *\n * This is a typed wrapper around `Object.hasOwn` that narrows the provided key\n * when the check succeeds.\n *\n * @example\n * ```ts\n * const user = { id: \"1\" };\n * const key: string = \"id\";\n *\n * if (hasOwn(user, key)) {\n * user[key]; // key is narrowed to \"id\"\n * }\n * ```\n */\nexport function hasOwn<T extends object, K extends PropertyKey>(\n\tobject: T,\n\tkey: K,\n): key is Extract<K, keyof T> {\n\treturn Object.hasOwn(object, key);\n}\n","/**\n * Returns the given value unchanged.\n *\n * Useful as a default callback, a type-inference anchor, or a no-op\n * placeholder where a transform function is expected.\n *\n * @example\n * ```ts\n * identity(\"umsizi\"); // \"umsizi\"\n * ```\n */\nexport function identity<T>(value: T): T {\n\treturn value;\n}\n","/**\n * Returns `true` when an object has no own enumerable properties.\n *\n * Both string keys and symbol keys are considered. Non-enumerable properties\n * are ignored.\n *\n * @example\n * ```ts\n * isEmpty({}); // true\n * isEmpty({ id: \"1\" }); // false\n * ```\n */\nexport function isEmpty(object: object): boolean {\n\tif (Object.keys(object).length > 0) {\n\t\treturn false;\n\t}\n\n\tfor (const key of Object.getOwnPropertySymbols(object)) {\n\t\tif (Object.prototype.propertyIsEnumerable.call(object, key)) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\treturn true;\n}\n","/**\n * Checks whether a value is a plain object with a prototype of\n * `Object.prototype` or `null`.\n *\n * Arrays, functions, boxed primitives, dates, maps, sets, and class instances\n * all return `false`.\n *\n * @example\n * ```ts\n * const payload: unknown = { id: \"1\" };\n *\n * if (isPlainObject(payload)) {\n * \tpayload.id;\n * }\n * ```\n */\nexport function isPlainObject(\n\tvalue: unknown,\n): value is Record<PropertyKey, unknown> {\n\tif (value === null || typeof value !== \"object\") {\n\t\treturn false;\n\t}\n\n\tconst prototype = Object.getPrototypeOf(value);\n\n\treturn prototype === Object.prototype || prototype === null;\n}\n","import { typedKeys } from \"./typed-keys\";\nimport type { MappedValues, ValueMapper } from \"./types\";\n\n/**\n * Maps the values of an object's own enumerable string-keyed properties while\n * preserving the original enumerable string-key set.\n *\n * @example\n * ```ts\n * const counts = { draft: 1, published: 2 };\n *\n * mapValues(counts, (value) => value * 2);\n * // { draft: 2, published: 4 }\n * ```\n */\nexport function mapValues<T extends object, R>(\n\tobject: T,\n\tmapper: ValueMapper<T, R>,\n): MappedValues<T, R> {\n\tconst result = {} as MappedValues<T, R>;\n\n\tfor (const key of typedKeys(object)) {\n\t\tresult[key] = mapper(object[key], key, object);\n\t}\n\n\treturn result;\n}\n","/**\n * Creates a new object excluding the selected own enumerable properties.\n *\n * Prefer the rest-key form for the strongest autocomplete and inference.\n *\n * @example\n * ```ts\n * const user = { id: \"1\", name: \"Umsizi\", role: \"admin\" } as const;\n *\n * omit(user, \"id\", \"name\"); // { role: \"admin\" }\n * omit(user, [\"role\"] as const); // { id: \"1\", name: \"Umsizi\" }\n * ```\n */\nexport function omit<T extends object, const Keys extends readonly (keyof T)[]>(\n\tobject: T,\n\t...keys: Keys\n): Omit<T, Keys[number]>;\nexport function omit<\n\tT extends object,\n\tconst FirstKey extends keyof T,\n\tconst RestKeys extends readonly (keyof T)[],\n>(\n\tobject: T,\n\tkeys: readonly [FirstKey, ...RestKeys],\n): Omit<T, FirstKey | RestKeys[number]>;\nexport function omit<T extends object>(\n\tobject: T,\n\tkeys: readonly (keyof T)[],\n): Partial<T>;\nexport function omit<T extends object>(\n\tobject: T,\n\tfirstKeyOrKeys: keyof T | readonly (keyof T)[],\n\t...restKeys: readonly (keyof T)[]\n): Partial<T> {\n\tconst keys = (\n\t\tArray.isArray(firstKeyOrKeys)\n\t\t\t? firstKeyOrKeys\n\t\t\t: [firstKeyOrKeys, ...restKeys]\n\t) as readonly (keyof T)[];\n\tconst omittedKeys = new Set<PropertyKey>(keys as readonly PropertyKey[]);\n\tconst result: Partial<T> = {};\n\n\tfor (const key of Reflect.ownKeys(object) as (keyof T)[]) {\n\t\tif (\n\t\t\tObject.prototype.propertyIsEnumerable.call(object, key) &&\n\t\t\t!omittedKeys.has(key)\n\t\t) {\n\t\t\t(result as T)[key] = object[key];\n\t\t}\n\t}\n\n\treturn result;\n}\n","import { hasOwn } from \"./has-own\";\n\n/**\n * Creates a new object containing only the selected own properties.\n *\n * Prefer the rest-key form for the strongest autocomplete and inference.\n *\n * @example\n * ```ts\n * const user = { id: \"1\", name: \"Umsizi\", role: \"admin\" } as const;\n *\n * pick(user, \"name\"); // { name: \"Umsizi\" }\n * pick(user, [\"id\", \"role\"] as const); // { id: \"1\", role: \"admin\" }\n * ```\n */\nexport function pick<T extends object, const Keys extends readonly (keyof T)[]>(\n\tobject: T,\n\t...keys: Keys\n): Pick<T, Keys[number]>;\nexport function pick<\n\tT extends object,\n\tconst FirstKey extends keyof T,\n\tconst RestKeys extends readonly (keyof T)[],\n>(\n\tobject: T,\n\tkeys: readonly [FirstKey, ...RestKeys],\n): Pick<T, FirstKey | RestKeys[number]>;\nexport function pick<T extends object>(\n\tobject: T,\n\tkeys: readonly (keyof T)[],\n): Partial<T>;\nexport function pick<T extends object>(\n\tobject: T,\n\tfirstKeyOrKeys: keyof T | readonly (keyof T)[],\n\t...restKeys: readonly (keyof T)[]\n): Partial<T> {\n\tconst keys = (\n\t\tArray.isArray(firstKeyOrKeys)\n\t\t\t? firstKeyOrKeys\n\t\t\t: [firstKeyOrKeys, ...restKeys]\n\t) as readonly (keyof T)[];\n\tconst result: Partial<T> = {};\n\n\tfor (const key of keys) {\n\t\tif (hasOwn(object, key)) {\n\t\t\tresult[key] = object[key];\n\t\t}\n\t}\n\n\treturn result;\n}\n","import type { ObjectEntries } from \"./types\";\n\n/**\n * Returns the own enumerable string-keyed entries of an object with preserved\n * key/value pairing.\n *\n * This is a typed wrapper around `Object.entries`.\n *\n * @example\n * ```ts\n * const user = { id: \"1\", active: true } as const;\n *\n * typedEntries(user); // [[\"id\", \"1\"], [\"active\", true]]\n * ```\n */\nexport function typedEntries<T extends object>(object: T): ObjectEntries<T> {\n\treturn Object.entries(object) as unknown as ObjectEntries<T>;\n}\n","import type { EntryTuples, ObjectFromEntries } from \"./types\";\n\n/**\n * Creates an object from entries while preserving the key and value types from\n * the input tuple array.\n *\n * This is a typed wrapper around `Object.fromEntries`.\n *\n * @example\n * ```ts\n * const status = typedFromEntries([\n * [\"id\", \"1\"],\n * [\"active\", true],\n * ] as const);\n *\n * // inferred as: { id: \"1\"; active: true }\n * ```\n */\nexport function typedFromEntries<const T extends EntryTuples>(\n\tentries: T,\n): ObjectFromEntries<T> {\n\treturn Object.fromEntries(entries) as ObjectFromEntries<T>;\n}\n"],"mappings":"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"}
|
package/dist/next.d.ts
CHANGED
|
@@ -1,2 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region src/next/normalize-pathname.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Normalizes a path-like string for routing/comparison purposes.
|
|
4
|
+
*
|
|
5
|
+
* - Ensures a leading slash.
|
|
6
|
+
* - Collapses consecutive slashes into one.
|
|
7
|
+
* - Strips a trailing slash (except for the root path).
|
|
8
|
+
* - An empty string normalizes to `"/"`.
|
|
9
|
+
*
|
|
10
|
+
* Query strings and fragments are treated as opaque path characters and are
|
|
11
|
+
* not parsed or stripped — pass only the pathname segment of a URL.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* normalizePathname("dashboard"); // "/dashboard"
|
|
16
|
+
* normalizePathname("//dashboard///settings/"); // "/dashboard/settings"
|
|
17
|
+
* normalizePathname(""); // "/"
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
declare function normalizePathname(pathname: string): string;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { normalizePathname };
|
|
23
|
+
//# sourceMappingURL=next.d.ts.map
|
package/dist/next.js
CHANGED
|
@@ -1,3 +1,29 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/next/normalize-pathname.ts
|
|
2
|
+
/**
|
|
3
|
+
* Normalizes a path-like string for routing/comparison purposes.
|
|
4
|
+
*
|
|
5
|
+
* - Ensures a leading slash.
|
|
6
|
+
* - Collapses consecutive slashes into one.
|
|
7
|
+
* - Strips a trailing slash (except for the root path).
|
|
8
|
+
* - An empty string normalizes to `"/"`.
|
|
9
|
+
*
|
|
10
|
+
* Query strings and fragments are treated as opaque path characters and are
|
|
11
|
+
* not parsed or stripped — pass only the pathname segment of a URL.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* normalizePathname("dashboard"); // "/dashboard"
|
|
16
|
+
* normalizePathname("//dashboard///settings/"); // "/dashboard/settings"
|
|
17
|
+
* normalizePathname(""); // "/"
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
function normalizePathname(pathname) {
|
|
21
|
+
if (pathname === "") return "/";
|
|
22
|
+
const normalized = pathname.replace(/\/{2,}/g, "/").replace(/\/$/, "");
|
|
23
|
+
if (normalized === "") return "/";
|
|
24
|
+
return normalized.startsWith("/") ? normalized : `/${normalized}`;
|
|
25
|
+
}
|
|
2
26
|
|
|
3
|
-
|
|
27
|
+
//#endregion
|
|
28
|
+
export { normalizePathname };
|
|
29
|
+
//# sourceMappingURL=next.js.map
|
package/dist/next.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"next.js","names":[],"sources":["../src/next/normalize-pathname.ts"],"sourcesContent":["/**\n * Normalizes a path-like string for routing/comparison purposes.\n *\n * - Ensures a leading slash.\n * - Collapses consecutive slashes into one.\n * - Strips a trailing slash (except for the root path).\n * - An empty string normalizes to `\"/\"`.\n *\n * Query strings and fragments are treated as opaque path characters and are\n * not parsed or stripped — pass only the pathname segment of a URL.\n *\n * @example\n * ```ts\n * normalizePathname(\"dashboard\"); // \"/dashboard\"\n * normalizePathname(\"//dashboard///settings/\"); // \"/dashboard/settings\"\n * normalizePathname(\"\"); // \"/\"\n * ```\n */\nexport function normalizePathname(pathname: string): string {\n\tif (pathname === \"\") {\n\t\treturn \"/\";\n\t}\n\n\tconst normalized = pathname.replace(/\\/{2,}/g, \"/\").replace(/\\/$/, \"\");\n\n\tif (normalized === \"\") {\n\t\treturn \"/\";\n\t}\n\n\treturn normalized.startsWith(\"/\") ? normalized : `/${normalized}`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAkBA,SAAgB,kBAAkB,UAA0B;AAC3D,KAAI,aAAa,GAChB,QAAO;CAGR,MAAM,aAAa,SAAS,QAAQ,WAAW,IAAI,CAAC,QAAQ,OAAO,GAAG;AAEtE,KAAI,eAAe,GAClB,QAAO;AAGR,QAAO,WAAW,WAAW,IAAI,GAAG,aAAa,IAAI"}
|
package/dist/node.d.ts
CHANGED
|
@@ -1,2 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region src/node/has-file-extension.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Checks whether a file path ends with the given extension.
|
|
4
|
+
*
|
|
5
|
+
* The leading dot on `extension` is optional — both `"ts"` and `".ts"` are
|
|
6
|
+
* accepted. The comparison is case-sensitive and is a plain `endsWith`
|
|
7
|
+
* check, so it does not validate that `filePath` is a well-formed path.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* hasFileExtension("src/index.ts", ".ts"); // true
|
|
12
|
+
* hasFileExtension("package.json", "json"); // true
|
|
13
|
+
* hasFileExtension("README.md", "ts"); // false
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
declare function hasFileExtension(filePath: string, extension: string): boolean;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { hasFileExtension };
|
|
19
|
+
//# sourceMappingURL=node.d.ts.map
|
package/dist/node.js
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/node/has-file-extension.ts
|
|
2
|
+
/**
|
|
3
|
+
* Checks whether a file path ends with the given extension.
|
|
4
|
+
*
|
|
5
|
+
* The leading dot on `extension` is optional — both `"ts"` and `".ts"` are
|
|
6
|
+
* accepted. The comparison is case-sensitive and is a plain `endsWith`
|
|
7
|
+
* check, so it does not validate that `filePath` is a well-formed path.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* hasFileExtension("src/index.ts", ".ts"); // true
|
|
12
|
+
* hasFileExtension("package.json", "json"); // true
|
|
13
|
+
* hasFileExtension("README.md", "ts"); // false
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
function hasFileExtension(filePath, extension) {
|
|
17
|
+
const normalizedExtension = extension.startsWith(".") ? extension : `.${extension}`;
|
|
18
|
+
return filePath.endsWith(normalizedExtension);
|
|
19
|
+
}
|
|
2
20
|
|
|
3
|
-
|
|
21
|
+
//#endregion
|
|
22
|
+
export { hasFileExtension };
|
|
23
|
+
//# sourceMappingURL=node.js.map
|
package/dist/node.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.js","names":[],"sources":["../src/node/has-file-extension.ts"],"sourcesContent":["/**\n * Checks whether a file path ends with the given extension.\n *\n * The leading dot on `extension` is optional — both `\"ts\"` and `\".ts\"` are\n * accepted. The comparison is case-sensitive and is a plain `endsWith`\n * check, so it does not validate that `filePath` is a well-formed path.\n *\n * @example\n * ```ts\n * hasFileExtension(\"src/index.ts\", \".ts\"); // true\n * hasFileExtension(\"package.json\", \"json\"); // true\n * hasFileExtension(\"README.md\", \"ts\"); // false\n * ```\n */\nexport function hasFileExtension(filePath: string, extension: string): boolean {\n\tconst normalizedExtension = extension.startsWith(\".\")\n\t\t? extension\n\t\t: `.${extension}`;\n\n\treturn filePath.endsWith(normalizedExtension);\n}\n"],"mappings":";;;;;;;;;;;;;;;AAcA,SAAgB,iBAAiB,UAAkB,WAA4B;CAC9E,MAAM,sBAAsB,UAAU,WAAW,IAAI,GAClD,YACA,IAAI;AAEP,QAAO,SAAS,SAAS,oBAAoB"}
|
package/dist/react.d.ts
CHANGED
|
@@ -1,2 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region src/react/is-render-function.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Type guard for values that are callable in render-oriented code paths
|
|
4
|
+
* (e.g. `children` passed as a render prop).
|
|
5
|
+
*
|
|
6
|
+
* Matches any callable value, including async functions, generator
|
|
7
|
+
* functions, and class constructors — it does not distinguish between
|
|
8
|
+
* function kinds, only "is this safe to call as a function".
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* const children: unknown = () => "ready";
|
|
13
|
+
*
|
|
14
|
+
* if (isRenderFunction(children)) {
|
|
15
|
+
* children();
|
|
16
|
+
* }
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
declare function isRenderFunction(value: unknown): value is (...args: readonly unknown[]) => unknown;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { isRenderFunction };
|
|
22
|
+
//# sourceMappingURL=react.d.ts.map
|
package/dist/react.js
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/react/is-render-function.ts
|
|
2
|
+
/**
|
|
3
|
+
* Type guard for values that are callable in render-oriented code paths
|
|
4
|
+
* (e.g. `children` passed as a render prop).
|
|
5
|
+
*
|
|
6
|
+
* Matches any callable value, including async functions, generator
|
|
7
|
+
* functions, and class constructors — it does not distinguish between
|
|
8
|
+
* function kinds, only "is this safe to call as a function".
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* const children: unknown = () => "ready";
|
|
13
|
+
*
|
|
14
|
+
* if (isRenderFunction(children)) {
|
|
15
|
+
* children();
|
|
16
|
+
* }
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
function isRenderFunction(value) {
|
|
20
|
+
return typeof value === "function";
|
|
21
|
+
}
|
|
2
22
|
|
|
3
|
-
|
|
23
|
+
//#endregion
|
|
24
|
+
export { isRenderFunction };
|
|
25
|
+
//# sourceMappingURL=react.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react.js","names":[],"sources":["../src/react/is-render-function.ts"],"sourcesContent":["/**\n * Type guard for values that are callable in render-oriented code paths\n * (e.g. `children` passed as a render prop).\n *\n * Matches any callable value, including async functions, generator\n * functions, and class constructors — it does not distinguish between\n * function kinds, only \"is this safe to call as a function\".\n *\n * @example\n * ```ts\n * const children: unknown = () => \"ready\";\n *\n * if (isRenderFunction(children)) {\n * children();\n * }\n * ```\n */\nexport function isRenderFunction(\n\tvalue: unknown,\n): value is (...args: readonly unknown[]) => unknown {\n\treturn typeof value === \"function\";\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAiBA,SAAgB,iBACf,OACoD;AACpD,QAAO,OAAO,UAAU"}
|
package/package.json
CHANGED
package/dist/index-DtjbEW43.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
//#region src/node/has-file-extension.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* Checks whether a file path ends with the given extension.
|
|
4
|
-
*
|
|
5
|
-
* The leading dot on `extension` is optional — both `"ts"` and `".ts"` are
|
|
6
|
-
* accepted. The comparison is case-sensitive and is a plain `endsWith`
|
|
7
|
-
* check, so it does not validate that `filePath` is a well-formed path.
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```ts
|
|
11
|
-
* hasFileExtension("src/index.ts", ".ts"); // true
|
|
12
|
-
* hasFileExtension("package.json", "json"); // true
|
|
13
|
-
* hasFileExtension("README.md", "ts"); // false
|
|
14
|
-
* ```
|
|
15
|
-
*/
|
|
16
|
-
declare function hasFileExtension(filePath: string, extension: string): boolean;
|
|
17
|
-
//#endregion
|
|
18
|
-
export { hasFileExtension as t };
|
|
19
|
-
//# sourceMappingURL=index-DtjbEW43.d.ts.map
|
package/dist/index-dktuz4mv.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
//#region src/react/is-render-function.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* Type guard for values that are callable in render-oriented code paths
|
|
4
|
-
* (e.g. `children` passed as a render prop).
|
|
5
|
-
*
|
|
6
|
-
* Matches any callable value, including async functions, generator
|
|
7
|
-
* functions, and class constructors — it does not distinguish between
|
|
8
|
-
* function kinds, only "is this safe to call as a function".
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```ts
|
|
12
|
-
* const children: unknown = () => "ready";
|
|
13
|
-
*
|
|
14
|
-
* if (isRenderFunction(children)) {
|
|
15
|
-
* children();
|
|
16
|
-
* }
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
declare function isRenderFunction(value: unknown): value is (...args: readonly unknown[]) => unknown;
|
|
20
|
-
//#endregion
|
|
21
|
-
export { isRenderFunction as t };
|
|
22
|
-
//# sourceMappingURL=index-dktuz4mv.d.ts.map
|
package/dist/index-rZiv1o95.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
//#region src/next/normalize-pathname.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* Normalizes a path-like string for routing/comparison purposes.
|
|
4
|
-
*
|
|
5
|
-
* - Ensures a leading slash.
|
|
6
|
-
* - Collapses consecutive slashes into one.
|
|
7
|
-
* - Strips a trailing slash (except for the root path).
|
|
8
|
-
* - An empty string normalizes to `"/"`.
|
|
9
|
-
*
|
|
10
|
-
* Query strings and fragments are treated as opaque path characters and are
|
|
11
|
-
* not parsed or stripped — pass only the pathname segment of a URL.
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```ts
|
|
15
|
-
* normalizePathname("dashboard"); // "/dashboard"
|
|
16
|
-
* normalizePathname("//dashboard///settings/"); // "/dashboard/settings"
|
|
17
|
-
* normalizePathname(""); // "/"
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
declare function normalizePathname(pathname: string): string;
|
|
21
|
-
//#endregion
|
|
22
|
-
export { normalizePathname as t };
|
|
23
|
-
//# sourceMappingURL=index-rZiv1o95.d.ts.map
|
package/dist/next-C3wp7UoQ.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
//#region src/next/normalize-pathname.ts
|
|
2
|
-
/**
|
|
3
|
-
* Normalizes a path-like string for routing/comparison purposes.
|
|
4
|
-
*
|
|
5
|
-
* - Ensures a leading slash.
|
|
6
|
-
* - Collapses consecutive slashes into one.
|
|
7
|
-
* - Strips a trailing slash (except for the root path).
|
|
8
|
-
* - An empty string normalizes to `"/"`.
|
|
9
|
-
*
|
|
10
|
-
* Query strings and fragments are treated as opaque path characters and are
|
|
11
|
-
* not parsed or stripped — pass only the pathname segment of a URL.
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```ts
|
|
15
|
-
* normalizePathname("dashboard"); // "/dashboard"
|
|
16
|
-
* normalizePathname("//dashboard///settings/"); // "/dashboard/settings"
|
|
17
|
-
* normalizePathname(""); // "/"
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
function normalizePathname(pathname) {
|
|
21
|
-
if (pathname === "") return "/";
|
|
22
|
-
const normalized = pathname.replace(/\/{2,}/g, "/").replace(/\/$/, "");
|
|
23
|
-
if (normalized === "") return "/";
|
|
24
|
-
return normalized.startsWith("/") ? normalized : `/${normalized}`;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
//#endregion
|
|
28
|
-
export { normalizePathname as t };
|
|
29
|
-
//# sourceMappingURL=next-C3wp7UoQ.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"next-C3wp7UoQ.js","names":[],"sources":["../src/next/normalize-pathname.ts"],"sourcesContent":["/**\n * Normalizes a path-like string for routing/comparison purposes.\n *\n * - Ensures a leading slash.\n * - Collapses consecutive slashes into one.\n * - Strips a trailing slash (except for the root path).\n * - An empty string normalizes to `\"/\"`.\n *\n * Query strings and fragments are treated as opaque path characters and are\n * not parsed or stripped — pass only the pathname segment of a URL.\n *\n * @example\n * ```ts\n * normalizePathname(\"dashboard\"); // \"/dashboard\"\n * normalizePathname(\"//dashboard///settings/\"); // \"/dashboard/settings\"\n * normalizePathname(\"\"); // \"/\"\n * ```\n */\nexport function normalizePathname(pathname: string): string {\n\tif (pathname === \"\") {\n\t\treturn \"/\";\n\t}\n\n\tconst normalized = pathname.replace(/\\/{2,}/g, \"/\").replace(/\\/$/, \"\");\n\n\tif (normalized === \"\") {\n\t\treturn \"/\";\n\t}\n\n\treturn normalized.startsWith(\"/\") ? normalized : `/${normalized}`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAkBA,SAAgB,kBAAkB,UAA0B;AAC3D,KAAI,aAAa,GAChB,QAAO;CAGR,MAAM,aAAa,SAAS,QAAQ,WAAW,IAAI,CAAC,QAAQ,OAAO,GAAG;AAEtE,KAAI,eAAe,GAClB,QAAO;AAGR,QAAO,WAAW,WAAW,IAAI,GAAG,aAAa,IAAI"}
|
package/dist/node-D-nlzpmG.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
//#region src/node/has-file-extension.ts
|
|
2
|
-
/**
|
|
3
|
-
* Checks whether a file path ends with the given extension.
|
|
4
|
-
*
|
|
5
|
-
* The leading dot on `extension` is optional — both `"ts"` and `".ts"` are
|
|
6
|
-
* accepted. The comparison is case-sensitive and is a plain `endsWith`
|
|
7
|
-
* check, so it does not validate that `filePath` is a well-formed path.
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```ts
|
|
11
|
-
* hasFileExtension("src/index.ts", ".ts"); // true
|
|
12
|
-
* hasFileExtension("package.json", "json"); // true
|
|
13
|
-
* hasFileExtension("README.md", "ts"); // false
|
|
14
|
-
* ```
|
|
15
|
-
*/
|
|
16
|
-
function hasFileExtension(filePath, extension) {
|
|
17
|
-
const normalizedExtension = extension.startsWith(".") ? extension : `.${extension}`;
|
|
18
|
-
return filePath.endsWith(normalizedExtension);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
//#endregion
|
|
22
|
-
export { hasFileExtension as t };
|
|
23
|
-
//# sourceMappingURL=node-D-nlzpmG.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"node-D-nlzpmG.js","names":[],"sources":["../src/node/has-file-extension.ts"],"sourcesContent":["/**\n * Checks whether a file path ends with the given extension.\n *\n * The leading dot on `extension` is optional — both `\"ts\"` and `\".ts\"` are\n * accepted. The comparison is case-sensitive and is a plain `endsWith`\n * check, so it does not validate that `filePath` is a well-formed path.\n *\n * @example\n * ```ts\n * hasFileExtension(\"src/index.ts\", \".ts\"); // true\n * hasFileExtension(\"package.json\", \"json\"); // true\n * hasFileExtension(\"README.md\", \"ts\"); // false\n * ```\n */\nexport function hasFileExtension(filePath: string, extension: string): boolean {\n\tconst normalizedExtension = extension.startsWith(\".\")\n\t\t? extension\n\t\t: `.${extension}`;\n\n\treturn filePath.endsWith(normalizedExtension);\n}\n"],"mappings":";;;;;;;;;;;;;;;AAcA,SAAgB,iBAAiB,UAAkB,WAA4B;CAC9E,MAAM,sBAAsB,UAAU,WAAW,IAAI,GAClD,YACA,IAAI;AAEP,QAAO,SAAS,SAAS,oBAAoB"}
|
package/dist/react-BCidSnzT.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
//#region src/react/is-render-function.ts
|
|
2
|
-
/**
|
|
3
|
-
* Type guard for values that are callable in render-oriented code paths
|
|
4
|
-
* (e.g. `children` passed as a render prop).
|
|
5
|
-
*
|
|
6
|
-
* Matches any callable value, including async functions, generator
|
|
7
|
-
* functions, and class constructors — it does not distinguish between
|
|
8
|
-
* function kinds, only "is this safe to call as a function".
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```ts
|
|
12
|
-
* const children: unknown = () => "ready";
|
|
13
|
-
*
|
|
14
|
-
* if (isRenderFunction(children)) {
|
|
15
|
-
* children();
|
|
16
|
-
* }
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
function isRenderFunction(value) {
|
|
20
|
-
return typeof value === "function";
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
//#endregion
|
|
24
|
-
export { isRenderFunction as t };
|
|
25
|
-
//# sourceMappingURL=react-BCidSnzT.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"react-BCidSnzT.js","names":[],"sources":["../src/react/is-render-function.ts"],"sourcesContent":["/**\n * Type guard for values that are callable in render-oriented code paths\n * (e.g. `children` passed as a render prop).\n *\n * Matches any callable value, including async functions, generator\n * functions, and class constructors — it does not distinguish between\n * function kinds, only \"is this safe to call as a function\".\n *\n * @example\n * ```ts\n * const children: unknown = () => \"ready\";\n *\n * if (isRenderFunction(children)) {\n * children();\n * }\n * ```\n */\nexport function isRenderFunction(\n\tvalue: unknown,\n): value is (...args: readonly unknown[]) => unknown {\n\treturn typeof value === \"function\";\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAiBA,SAAgB,iBACf,OACoD;AACpD,QAAO,OAAO,UAAU"}
|