@neovici/cosmoz-utils 6.14.1 → 6.14.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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.14.2",
4
4
  "description": "Date, money and template management functions commonly needed in Cosmoz views.",
5
5
  "keywords": [
6
6
  "polymer",