umsizi 0.3.0 → 0.4.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/dist/index.d.ts +1 -5
- package/dist/index.js +1 -5
- 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/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import { t as normalizePathname } from "./index-rZiv1o95.js";
|
|
2
|
-
import { t as hasFileExtension } from "./index-DtjbEW43.js";
|
|
3
|
-
import { t as isRenderFunction } from "./index-dktuz4mv.js";
|
|
4
|
-
|
|
5
1
|
//#region src/core/types.d.ts
|
|
6
2
|
type StringKeyOf<T extends object> = Extract<keyof T, string>;
|
|
7
3
|
type ObjectEntry<T extends object> = { [K in StringKeyOf<T>]: readonly [K, T[K]] }[StringKeyOf<T>];
|
|
@@ -198,5 +194,5 @@ declare function typedFromEntries<const T extends EntryTuples>(entries: T): Obje
|
|
|
198
194
|
*/
|
|
199
195
|
declare function typedKeys<T extends object>(object: T): Array<StringKeyOf<T>>;
|
|
200
196
|
//#endregion
|
|
201
|
-
export { compactObject, filterValues,
|
|
197
|
+
export { compactObject, filterValues, hasOwn, identity, isEmpty, mapValues, omit, pick, typedEntries, typedFromEntries, typedKeys };
|
|
202
198
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import { t as normalizePathname } from "./next-C3wp7UoQ.js";
|
|
2
|
-
import { t as hasFileExtension } from "./node-D-nlzpmG.js";
|
|
3
|
-
import { t as isRenderFunction } from "./react-BCidSnzT.js";
|
|
4
|
-
|
|
5
1
|
//#region src/core/typed-keys.ts
|
|
6
2
|
/**
|
|
7
3
|
* Returns the own enumerable string keys of an object with preserved key types.
|
|
@@ -193,5 +189,5 @@ function typedFromEntries(entries) {
|
|
|
193
189
|
}
|
|
194
190
|
|
|
195
191
|
//#endregion
|
|
196
|
-
export { compactObject, filterValues,
|
|
192
|
+
export { compactObject, filterValues, hasOwn, identity, isEmpty, mapValues, omit, pick, typedEntries, typedFromEntries, typedKeys };
|
|
197
193
|
//# 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":["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"}
|
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"}
|