@neovici/cosmoz-utils 6.14.1 → 6.15.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.
@@ -6,7 +6,5 @@ export declare function constant(): () => undefined;
6
6
  export declare function constant<T>(v: T): () => T;
7
7
  export declare const constTrue: () => true, constUndefined: () => undefined, noop: () => undefined, identity: <T>(obj: T) => T, or: <A, F extends OrFn<A>>(...fns: F[]) => (...args: A[]) => boolean;
8
8
  export declare const once: <A extends Arr, R, F extends OnceFn<A, R> = OnceFn<A, R>>(fn: F, check?: OnceCheckFn<A>) => (...args: A) => any;
9
- export type InvokedType<T> = T extends (...args: any[]) => infer R ? R : T;
10
- export type InvokedParameters<F> = F extends (...args: infer A) => any ? A : never;
11
- export declare function invoke<F>(fn: F, ...args: InvokedParameters<F>): InvokedType<F>;
9
+ export declare const invoke: <T, A extends unknown[]>(fn: T | ((...args: A) => T), ...args: A) => T;
12
10
  export {};
package/dist/function.js CHANGED
@@ -6,6 +6,4 @@ export const once = (fn, check = constTrue) => {
6
6
  let result;
7
7
  return (...args) => (result ??= check(args) ? fn(...args) : undefined);
8
8
  };
9
- export function invoke(fn, ...args) {
10
- return typeof fn === 'function' ? fn(...args) : fn;
11
- }
9
+ export const invoke = (fn, ...args) => (typeof fn === 'function' ? fn(...args) : fn);
@@ -1 +1 @@
1
- export declare const hashUrl: () => URL, singleParse: (hashParam: string, codec?: <T>(obj: T) => T) => string | string[], multiParse: (hashParam: string, codec?: <T>(obj: T) => T) => any;
1
+ export declare const hashUrl: () => URL, singleParse: (hashParam: string, codec?: <T>(obj: T) => T) => string | string[] | undefined, multiParse: (hashParam: string, codec?: <T>(obj: T) => T) => any;
package/dist/location.js CHANGED
@@ -1,10 +1,14 @@
1
1
  import { identity } from './function';
2
2
  export const hashUrl = () => new URL(location.hash.replace(/^#!?/iu, '').replace('%23', '#'), location.origin), singleParse = (hashParam, codec = identity) => {
3
3
  const values = new URLSearchParams(hashUrl().hash.replace('#', '')).getAll(hashParam);
4
- if (Array.isArray(values)) {
5
- return values.length === 1 ? codec(values[0]) : values.map(codec);
4
+ switch (values.length) {
5
+ case 0:
6
+ return undefined;
7
+ case 1:
8
+ return codec(values[0]);
9
+ default:
10
+ return values.map(codec);
6
11
  }
7
- return codec(values);
8
12
  }, multiParse = (hashParam, codec = identity) => {
9
13
  const params = Array.from(new URLSearchParams(hashUrl().hash.replace('#', '')).entries())
10
14
  .filter(([param]) => param.startsWith(hashParam))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neovici/cosmoz-utils",
3
- "version": "6.14.1",
3
+ "version": "6.15.0",
4
4
  "description": "Date, money and template management functions commonly needed in Cosmoz views.",
5
5
  "keywords": [
6
6
  "polymer",