@configura/web-utilities 2.1.0-alpha.2 → 2.1.0-alpha.3

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.
Files changed (54) hide show
  1. package/.eslintrc.json +5 -5
  2. package/.gitattributes +3 -3
  3. package/LICENSE +201 -201
  4. package/README.md +1 -1
  5. package/__tests__/cmMips.test.ts +129 -129
  6. package/__tests__/convertLength.test.ts +37 -37
  7. package/__tests__/price.test.ts +21 -21
  8. package/dist/GenericCache.d.ts +14 -14
  9. package/dist/GenericCache.js +38 -38
  10. package/dist/Observable/AccumulatingObservable.d.ts +10 -10
  11. package/dist/Observable/AccumulatingObservable.js +25 -25
  12. package/dist/Observable/AggregatedLoadingObservable.d.ts +10 -10
  13. package/dist/Observable/AggregatedLoadingObservable.js +28 -28
  14. package/dist/Observable/LogObservable.d.ts +42 -42
  15. package/dist/Observable/LogObservable.js +104 -104
  16. package/dist/Observable/LogProducer.d.ts +5 -5
  17. package/dist/Observable/LogProducer.js +9 -9
  18. package/dist/Observable/Observable.d.ts +12 -12
  19. package/dist/Observable/Observable.js +33 -33
  20. package/dist/PromiseCache.d.ts +4 -4
  21. package/dist/PromiseCache.js +28 -28
  22. package/dist/assert.d.ts +12 -12
  23. package/dist/assert.js +20 -20
  24. package/dist/cmMips.d.ts +26 -26
  25. package/dist/cmMips.js +159 -159
  26. package/dist/compare.d.ts +6 -6
  27. package/dist/compare.js +29 -29
  28. package/dist/error.d.ts +7 -7
  29. package/dist/error.js +24 -24
  30. package/dist/event.d.ts +2 -2
  31. package/dist/event.js +1 -1
  32. package/dist/filter.d.ts +22 -22
  33. package/dist/filter.js +19 -19
  34. package/dist/index.d.ts +21 -21
  35. package/dist/index.js +21 -21
  36. package/dist/utilitiesArray.d.ts +4 -4
  37. package/dist/utilitiesArray.js +49 -49
  38. package/dist/utilitiesFile.d.ts +6 -6
  39. package/dist/utilitiesFile.js +33 -33
  40. package/dist/utilitiesImage.d.ts +1 -1
  41. package/dist/utilitiesImage.js +19 -19
  42. package/dist/utilitiesMath.d.ts +3 -3
  43. package/dist/utilitiesMath.js +9 -9
  44. package/dist/utilitiesPrice.d.ts +1 -1
  45. package/dist/utilitiesPrice.js +16 -16
  46. package/dist/utilitiesPromise.d.ts +1 -1
  47. package/dist/utilitiesPromise.js +12 -12
  48. package/dist/utilitiesString.d.ts +1 -1
  49. package/dist/utilitiesString.js +12 -12
  50. package/dist/utilitiesUnits.d.ts +16 -16
  51. package/dist/utilitiesUnits.js +72 -72
  52. package/dist/utilitiesWeb.d.ts +3 -3
  53. package/dist/utilitiesWeb.js +20 -20
  54. package/package.json +2 -2
package/dist/cmMips.js CHANGED
@@ -1,159 +1,159 @@
1
- /** The mime type (or media type) is only used internally, so using the "x." sub type is OK. */
2
- export const CMMIPS_MIMETYPE = "image/x.cmmips";
3
- const CMMIPS_MAGIC = 0xee77;
4
- /** Set to true to get verbose CmMips parsing info to the console. */
5
- const CMMIPS_VERBOSE = false;
6
- /**
7
- * Extracts the specified MIP level image data from the CmMips container.
8
- *
9
- * By default the highest quality MIP level is loaded. The optional maxResolution setting will
10
- * instead load the highest quality MIP level where BOTH width and height is < maxResolution, or
11
- * the lowest quality if none fulfill the requirement.
12
- *
13
- * Returns a filled in CmMips class with meta data as well as the byte array with the image data.
14
- * Returns undefined if there was an error
15
- *
16
- * @warning: For efficacy and maximum flexibility, the returned Uint8Array is only a new View into
17
- * the supplied bytes typed array. It is up to the caller to call slice() on it to create a copy of
18
- * the data if needed.
19
- */
20
- export function extractCmMips(bytes, logger, maxRes) {
21
- try {
22
- if (bytes === undefined || bytes.length < 6) {
23
- logger.error("(CmMips) Input array undefined or much too short", bytes === null || bytes === void 0 ? void 0 : bytes.length);
24
- return undefined;
25
- }
26
- const stream = new CmMipsStream(bytes);
27
- const magic = stream.readUint16();
28
- if (magic !== CMMIPS_MAGIC) {
29
- logger.error("(CmMips) Incorrect magic.", `Expected ${CMMIPS_MAGIC} got ${magic}`);
30
- return undefined;
31
- }
32
- const version = stream.readUint32();
33
- const suffix = stream.readString();
34
- const format = stream.readString();
35
- const averageR = stream.readUint8();
36
- const averageG = stream.readUint8();
37
- const averageB = stream.readUint8();
38
- const minWidth = stream.readUint32();
39
- const minHeight = stream.readUint32();
40
- const mipLevels = stream.readUint32();
41
- if (CMMIPS_VERBOSE) {
42
- logger.info("CmMips header data", `\nMagic: ${magic}`, `\nVersion: ${version}`, `\nSuffix: ${suffix}`, `\nFormat: ${format}`, `\nAverage color: (${averageR}, ${averageG}, ${averageB})`, `\nMip levels: ${mipLevels}`, `\nSmallest: (${minWidth}, ${minHeight})`, `\n---`, `\nLargest: (${minWidth << (mipLevels - 1)}, ${minHeight << (mipLevels - 1)})`, `\nMaxResolution: ${maxRes === undefined ? "None" : maxRes}`);
43
- }
44
- // Chunk start position. Byte offset into buffer, or -1 if external
45
- let pos = 0;
46
- let index = -1;
47
- let width = 0;
48
- let height = 0;
49
- for (let i = 0; i < mipLevels; i++) {
50
- const value = stream.readUint32();
51
- if (value === 0xffffffff) {
52
- // This Mip is external, skip
53
- continue;
54
- }
55
- const w = minWidth << i;
56
- const h = minHeight << i;
57
- if (index === -1 || maxRes === undefined || (w <= maxRes && h <= maxRes)) {
58
- // First internal Mip found, or Mip has OK dimensions
59
- pos = value;
60
- index = i;
61
- width = w;
62
- height = h;
63
- }
64
- }
65
- if (index === -1) {
66
- logger.warn("(CmMips) No internal Mip found");
67
- return undefined;
68
- }
69
- // Chunk size. Byte length of each chunk in the buffer
70
- let size = 0;
71
- let maxSize = 0;
72
- let totalSize = 0;
73
- for (let i = 0; i < mipLevels; i++) {
74
- const value = stream.readUint32();
75
- totalSize += value;
76
- maxSize = Math.max(maxSize, value);
77
- if (i === index) {
78
- size = value;
79
- }
80
- }
81
- // Chunk names (SHA-256)
82
- let name = "";
83
- for (let i = 0; i < mipLevels; i++) {
84
- if (i === index) {
85
- name = stream.readString();
86
- // No need to read further since this is last in the header
87
- break;
88
- }
89
- else {
90
- stream.skipString();
91
- }
92
- }
93
- if (name.length === 0 || size === 0 || pos === 0 || pos + size > bytes.length) {
94
- logger.error("(CmMips) Chunk meta data error.", `Name:"${name}", pos:${pos}, size:${size}, end:${bytes.length}`);
95
- return undefined;
96
- }
97
- if (CMMIPS_VERBOSE) {
98
- logger.info("(CmMips) Mip info", `\nLoaded: (${width}, ${height})`, `\nChunk name: ${name}`, `\nChunk size: ${size}`, `\nChunk pos: ${pos}`, `\n---`, `\nTotal size: ${totalSize >> 10} kb`, `\nMax size: ${maxSize >> 10} kb`, `\nOverhead: ${Math.round((100 * (totalSize - maxSize)) / totalSize)}%`);
99
- }
100
- // Using subarray(...) means that we simply return another view of underlying ArrayBuffer,
101
- // not actually copying any data. This is intentional.
102
- return new CmMip(name, suffix, width, height, bytes.subarray(pos, pos + size));
103
- }
104
- catch (e) {
105
- logger.error("(CmMips) Caught exception: " + e);
106
- return undefined;
107
- }
108
- }
109
- export class CmMip {
110
- constructor(name, suffix, width, height, data) {
111
- this.name = name;
112
- this.suffix = suffix;
113
- this.width = width;
114
- this.height = height;
115
- this.data = data;
116
- }
117
- }
118
- /**
119
- * Helper class for reading the serialized CmMips header.
120
- *
121
- * The string format is from CM / DEX (?) and called "TinyNanoCStr".
122
- * Numbers are stored in little endian.
123
- */
124
- class CmMipsStream {
125
- constructor(bytes) {
126
- this.pos = 0;
127
- this.bytes = bytes;
128
- this.view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
129
- }
130
- readUint8() {
131
- const value = this.view.getUint8(this.pos);
132
- this.pos += 1;
133
- return value;
134
- }
135
- readUint16() {
136
- const value = this.view.getUint16(this.pos, true);
137
- this.pos += 2;
138
- return value;
139
- }
140
- readUint32() {
141
- const value = this.view.getUint32(this.pos, true);
142
- this.pos += 4;
143
- return value;
144
- }
145
- skipString() {
146
- const length = this.view.getUint8(this.pos);
147
- this.pos += 1 + length;
148
- }
149
- readString() {
150
- if (this.textDecoder === undefined) {
151
- this.textDecoder = new TextDecoder("utf-8");
152
- }
153
- const length = this.view.getUint8(this.pos);
154
- this.pos += 1;
155
- const text = this.textDecoder.decode(this.bytes.subarray(this.pos, this.pos + length));
156
- this.pos += length;
157
- return text;
158
- }
159
- }
1
+ /** The mime type (or media type) is only used internally, so using the "x." sub type is OK. */
2
+ export const CMMIPS_MIMETYPE = "image/x.cmmips";
3
+ const CMMIPS_MAGIC = 0xee77;
4
+ /** Set to true to get verbose CmMips parsing info to the console. */
5
+ const CMMIPS_VERBOSE = false;
6
+ /**
7
+ * Extracts the specified MIP level image data from the CmMips container.
8
+ *
9
+ * By default the highest quality MIP level is loaded. The optional maxResolution setting will
10
+ * instead load the highest quality MIP level where BOTH width and height is < maxResolution, or
11
+ * the lowest quality if none fulfill the requirement.
12
+ *
13
+ * Returns a filled in CmMips class with meta data as well as the byte array with the image data.
14
+ * Returns undefined if there was an error
15
+ *
16
+ * @warning: For efficacy and maximum flexibility, the returned Uint8Array is only a new View into
17
+ * the supplied bytes typed array. It is up to the caller to call slice() on it to create a copy of
18
+ * the data if needed.
19
+ */
20
+ export function extractCmMips(bytes, logger, maxRes) {
21
+ try {
22
+ if (bytes === undefined || bytes.length < 6) {
23
+ logger.error("(CmMips) Input array undefined or much too short", bytes === null || bytes === void 0 ? void 0 : bytes.length);
24
+ return undefined;
25
+ }
26
+ const stream = new CmMipsStream(bytes);
27
+ const magic = stream.readUint16();
28
+ if (magic !== CMMIPS_MAGIC) {
29
+ logger.error("(CmMips) Incorrect magic.", `Expected ${CMMIPS_MAGIC} got ${magic}`);
30
+ return undefined;
31
+ }
32
+ const version = stream.readUint32();
33
+ const suffix = stream.readString();
34
+ const format = stream.readString();
35
+ const averageR = stream.readUint8();
36
+ const averageG = stream.readUint8();
37
+ const averageB = stream.readUint8();
38
+ const minWidth = stream.readUint32();
39
+ const minHeight = stream.readUint32();
40
+ const mipLevels = stream.readUint32();
41
+ if (CMMIPS_VERBOSE) {
42
+ logger.info("CmMips header data", `\nMagic: ${magic}`, `\nVersion: ${version}`, `\nSuffix: ${suffix}`, `\nFormat: ${format}`, `\nAverage color: (${averageR}, ${averageG}, ${averageB})`, `\nMip levels: ${mipLevels}`, `\nSmallest: (${minWidth}, ${minHeight})`, `\n---`, `\nLargest: (${minWidth << (mipLevels - 1)}, ${minHeight << (mipLevels - 1)})`, `\nMaxResolution: ${maxRes === undefined ? "None" : maxRes}`);
43
+ }
44
+ // Chunk start position. Byte offset into buffer, or -1 if external
45
+ let pos = 0;
46
+ let index = -1;
47
+ let width = 0;
48
+ let height = 0;
49
+ for (let i = 0; i < mipLevels; i++) {
50
+ const value = stream.readUint32();
51
+ if (value === 0xffffffff) {
52
+ // This Mip is external, skip
53
+ continue;
54
+ }
55
+ const w = minWidth << i;
56
+ const h = minHeight << i;
57
+ if (index === -1 || maxRes === undefined || (w <= maxRes && h <= maxRes)) {
58
+ // First internal Mip found, or Mip has OK dimensions
59
+ pos = value;
60
+ index = i;
61
+ width = w;
62
+ height = h;
63
+ }
64
+ }
65
+ if (index === -1) {
66
+ logger.warn("(CmMips) No internal Mip found");
67
+ return undefined;
68
+ }
69
+ // Chunk size. Byte length of each chunk in the buffer
70
+ let size = 0;
71
+ let maxSize = 0;
72
+ let totalSize = 0;
73
+ for (let i = 0; i < mipLevels; i++) {
74
+ const value = stream.readUint32();
75
+ totalSize += value;
76
+ maxSize = Math.max(maxSize, value);
77
+ if (i === index) {
78
+ size = value;
79
+ }
80
+ }
81
+ // Chunk names (SHA-256)
82
+ let name = "";
83
+ for (let i = 0; i < mipLevels; i++) {
84
+ if (i === index) {
85
+ name = stream.readString();
86
+ // No need to read further since this is last in the header
87
+ break;
88
+ }
89
+ else {
90
+ stream.skipString();
91
+ }
92
+ }
93
+ if (name.length === 0 || size === 0 || pos === 0 || pos + size > bytes.length) {
94
+ logger.error("(CmMips) Chunk meta data error.", `Name:"${name}", pos:${pos}, size:${size}, end:${bytes.length}`);
95
+ return undefined;
96
+ }
97
+ if (CMMIPS_VERBOSE) {
98
+ logger.info("(CmMips) Mip info", `\nLoaded: (${width}, ${height})`, `\nChunk name: ${name}`, `\nChunk size: ${size}`, `\nChunk pos: ${pos}`, `\n---`, `\nTotal size: ${totalSize >> 10} kb`, `\nMax size: ${maxSize >> 10} kb`, `\nOverhead: ${Math.round((100 * (totalSize - maxSize)) / totalSize)}%`);
99
+ }
100
+ // Using subarray(...) means that we simply return another view of underlying ArrayBuffer,
101
+ // not actually copying any data. This is intentional.
102
+ return new CmMip(name, suffix, width, height, bytes.subarray(pos, pos + size));
103
+ }
104
+ catch (e) {
105
+ logger.error("(CmMips) Caught exception: " + e);
106
+ return undefined;
107
+ }
108
+ }
109
+ export class CmMip {
110
+ constructor(name, suffix, width, height, data) {
111
+ this.name = name;
112
+ this.suffix = suffix;
113
+ this.width = width;
114
+ this.height = height;
115
+ this.data = data;
116
+ }
117
+ }
118
+ /**
119
+ * Helper class for reading the serialized CmMips header.
120
+ *
121
+ * The string format is from CM / DEX (?) and called "TinyNanoCStr".
122
+ * Numbers are stored in little endian.
123
+ */
124
+ class CmMipsStream {
125
+ constructor(bytes) {
126
+ this.pos = 0;
127
+ this.bytes = bytes;
128
+ this.view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
129
+ }
130
+ readUint8() {
131
+ const value = this.view.getUint8(this.pos);
132
+ this.pos += 1;
133
+ return value;
134
+ }
135
+ readUint16() {
136
+ const value = this.view.getUint16(this.pos, true);
137
+ this.pos += 2;
138
+ return value;
139
+ }
140
+ readUint32() {
141
+ const value = this.view.getUint32(this.pos, true);
142
+ this.pos += 4;
143
+ return value;
144
+ }
145
+ skipString() {
146
+ const length = this.view.getUint8(this.pos);
147
+ this.pos += 1 + length;
148
+ }
149
+ readString() {
150
+ if (this.textDecoder === undefined) {
151
+ this.textDecoder = new TextDecoder("utf-8");
152
+ }
153
+ const length = this.view.getUint8(this.pos);
154
+ this.pos += 1;
155
+ const text = this.textDecoder.decode(this.bytes.subarray(this.pos, this.pos + length));
156
+ this.pos += length;
157
+ return text;
158
+ }
159
+ }
package/dist/compare.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- export declare function compareMaps<T, S>(map1: Map<T, S>, map2: Map<T, S>): boolean;
2
- export declare function shallowCompareDictionaries<T>(jsObject1?: {
3
- [index: string]: T;
4
- }, jsObject2?: {
5
- [index: string]: T;
6
- }): boolean;
1
+ export declare function compareMaps<T, S>(map1: Map<T, S>, map2: Map<T, S>): boolean;
2
+ export declare function shallowCompareDictionaries<T>(jsObject1?: {
3
+ [index: string]: T;
4
+ }, jsObject2?: {
5
+ [index: string]: T;
6
+ }): boolean;
7
7
  //# sourceMappingURL=compare.d.ts.map
package/dist/compare.js CHANGED
@@ -1,29 +1,29 @@
1
- export function compareMaps(map1, map2) {
2
- if (map1.size !== map2.size) {
3
- return false;
4
- }
5
- for (const [key, val] of map1) {
6
- const testVal = map2.get(key);
7
- if (testVal !== val || (testVal === undefined && !map2.has(key))) {
8
- return false;
9
- }
10
- }
11
- return true;
12
- }
13
- export function shallowCompareDictionaries(jsObject1, jsObject2) {
14
- if (jsObject1 === undefined && jsObject2 === undefined) {
15
- return true;
16
- }
17
- else if (jsObject1 === undefined || jsObject2 === undefined) {
18
- return false;
19
- }
20
- if (Object.keys(jsObject1).length !== Object.keys(jsObject2).length) {
21
- return false;
22
- }
23
- for (const key in jsObject1) {
24
- if (jsObject1[key] !== jsObject2[key]) {
25
- return false;
26
- }
27
- }
28
- return true;
29
- }
1
+ export function compareMaps(map1, map2) {
2
+ if (map1.size !== map2.size) {
3
+ return false;
4
+ }
5
+ for (const [key, val] of map1) {
6
+ const testVal = map2.get(key);
7
+ if (testVal !== val || (testVal === undefined && !map2.has(key))) {
8
+ return false;
9
+ }
10
+ }
11
+ return true;
12
+ }
13
+ export function shallowCompareDictionaries(jsObject1, jsObject2) {
14
+ if (jsObject1 === undefined && jsObject2 === undefined) {
15
+ return true;
16
+ }
17
+ else if (jsObject1 === undefined || jsObject2 === undefined) {
18
+ return false;
19
+ }
20
+ if (Object.keys(jsObject1).length !== Object.keys(jsObject2).length) {
21
+ return false;
22
+ }
23
+ for (const key in jsObject1) {
24
+ if (jsObject1[key] !== jsObject2[key]) {
25
+ return false;
26
+ }
27
+ }
28
+ return true;
29
+ }
package/dist/error.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- export declare function toError(x: unknown): Error;
2
- export declare function getErrorMessage(x: unknown): string;
3
- export declare function augmentErrorMessage(e: unknown, message: string): unknown;
4
- export declare const abortErrorName = "AbortError";
5
- export declare function isAbortError(e: unknown): boolean;
6
- export declare function throwAbortError(): void;
7
- export declare function throwOnAbort(abortSignal: AbortSignal): void;
1
+ export declare function toError(x: unknown): Error;
2
+ export declare function getErrorMessage(x: unknown): string;
3
+ export declare function augmentErrorMessage(e: unknown, message: string): unknown;
4
+ export declare const abortErrorName = "AbortError";
5
+ export declare function isAbortError(e: unknown): boolean;
6
+ export declare function throwAbortError(): void;
7
+ export declare function throwOnAbort(abortSignal: AbortSignal): void;
8
8
  //# sourceMappingURL=error.d.ts.map
package/dist/error.js CHANGED
@@ -1,24 +1,24 @@
1
- export function toError(x) {
2
- return x instanceof Error ? x : Error(`${x}`);
3
- }
4
- export function getErrorMessage(x) {
5
- return x instanceof Error ? x.message : `${x}`;
6
- }
7
- export function augmentErrorMessage(e, message) {
8
- if (e instanceof Error) {
9
- e.message = `${message} (${e.message})`;
10
- }
11
- return e;
12
- }
13
- export const abortErrorName = "AbortError";
14
- export function isAbortError(e) {
15
- return e instanceof DOMException && e.name === abortErrorName;
16
- }
17
- export function throwAbortError() {
18
- throw new DOMException("", abortErrorName);
19
- }
20
- export function throwOnAbort(abortSignal) {
21
- if (abortSignal.aborted) {
22
- throwAbortError();
23
- }
24
- }
1
+ export function toError(x) {
2
+ return x instanceof Error ? x : Error(`${x}`);
3
+ }
4
+ export function getErrorMessage(x) {
5
+ return x instanceof Error ? x.message : `${x}`;
6
+ }
7
+ export function augmentErrorMessage(e, message) {
8
+ if (e instanceof Error) {
9
+ e.message = `${message} (${e.message})`;
10
+ }
11
+ return e;
12
+ }
13
+ export const abortErrorName = "AbortError";
14
+ export function isAbortError(e) {
15
+ return e instanceof DOMException && e.name === abortErrorName;
16
+ }
17
+ export function throwAbortError() {
18
+ throw new DOMException("", abortErrorName);
19
+ }
20
+ export function throwOnAbort(abortSignal) {
21
+ if (abortSignal.aborted) {
22
+ throwAbortError();
23
+ }
24
+ }
package/dist/event.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export declare type EventListener<T, K extends keyof T> = (v: T[K]) => void;
2
- export declare type SingleArgCallback<T> = (n: T) => void;
1
+ export declare type EventListener<T, K extends keyof T> = (v: T[K]) => void;
2
+ export declare type SingleArgCallback<T> = (n: T) => void;
3
3
  //# sourceMappingURL=event.d.ts.map
package/dist/event.js CHANGED
@@ -1 +1 @@
1
- export {};
1
+ export {};
package/dist/filter.d.ts CHANGED
@@ -1,23 +1,23 @@
1
- export declare type Matcher = {
2
- mode: "exact" | "all";
3
- value: string;
4
- };
5
- export declare type Picker = {
6
- mode: "random" | "first";
7
- value: number;
8
- };
9
- export declare type FilterMode = Matcher["mode"] | Picker["mode"];
10
- export declare type Filter = Matcher | Picker;
11
- export declare type Match<T> = {
12
- values: string[];
13
- matching: T[];
14
- };
15
- export declare type Filters<T> = {
16
- [K in keyof T]: Filter;
17
- };
18
- export declare type Matches<T> = {
19
- [K in keyof T]: Match<T>;
20
- };
21
- export declare function validateFilter(mode: string, value: string): Filter;
22
- export declare function notEmpty<TValue>(value: TValue | null | undefined): value is TValue;
1
+ export declare type Matcher = {
2
+ mode: "exact" | "all";
3
+ value: string;
4
+ };
5
+ export declare type Picker = {
6
+ mode: "random" | "first";
7
+ value: number;
8
+ };
9
+ export declare type FilterMode = Matcher["mode"] | Picker["mode"];
10
+ export declare type Filter = Matcher | Picker;
11
+ export declare type Match<T> = {
12
+ values: string[];
13
+ matching: T[];
14
+ };
15
+ export declare type Filters<T> = {
16
+ [K in keyof T]: Filter;
17
+ };
18
+ export declare type Matches<T> = {
19
+ [K in keyof T]: Match<T>;
20
+ };
21
+ export declare function validateFilter(mode: string, value: string): Filter;
22
+ export declare function notEmpty<TValue>(value: TValue | null | undefined): value is TValue;
23
23
  //# sourceMappingURL=filter.d.ts.map
package/dist/filter.js CHANGED
@@ -1,19 +1,19 @@
1
- export function validateFilter(mode, value) {
2
- if (mode === "all") {
3
- return { mode, value: "-" };
4
- }
5
- else if (mode === "exact") {
6
- return { mode, value };
7
- }
8
- else if (mode === "random" || mode === "first") {
9
- const parsed = parseInt(value, 10);
10
- return { mode, value: isNaN(parsed) ? 0 : parsed };
11
- }
12
- else {
13
- console.error("invalid mode!", mode);
14
- return { mode: "exact", value: "-" };
15
- }
16
- }
17
- export function notEmpty(value) {
18
- return value !== null && value !== undefined;
19
- }
1
+ export function validateFilter(mode, value) {
2
+ if (mode === "all") {
3
+ return { mode, value: "-" };
4
+ }
5
+ else if (mode === "exact") {
6
+ return { mode, value };
7
+ }
8
+ else if (mode === "random" || mode === "first") {
9
+ const parsed = parseInt(value, 10);
10
+ return { mode, value: isNaN(parsed) ? 0 : parsed };
11
+ }
12
+ else {
13
+ console.error("invalid mode!", mode);
14
+ return { mode: "exact", value: "-" };
15
+ }
16
+ }
17
+ export function notEmpty(value) {
18
+ return value !== null && value !== undefined;
19
+ }
package/dist/index.d.ts CHANGED
@@ -1,22 +1,22 @@
1
- export * from "./assert.js";
2
- export * from "./cmMips.js";
3
- export * from "./compare.js";
4
- export * from "./error.js";
5
- export * from "./event.js";
6
- export * from "./filter.js";
7
- export * from "./GenericCache.js";
8
- export * from "./Observable/AggregatedLoadingObservable.js";
9
- export * from "./Observable/LogObservable.js";
10
- export * from "./Observable/LogProducer.js";
11
- export * from "./Observable/Observable.js";
12
- export * from "./PromiseCache.js";
13
- export * from "./utilitiesArray.js";
14
- export * from "./utilitiesFile.js";
15
- export * from "./utilitiesImage.js";
16
- export * from "./utilitiesMath.js";
17
- export * from "./utilitiesPrice.js";
18
- export * from "./utilitiesPromise.js";
19
- export * from "./utilitiesString.js";
20
- export * from "./utilitiesUnits.js";
21
- export * from "./utilitiesWeb.js";
1
+ export * from "./assert.js";
2
+ export * from "./cmMips.js";
3
+ export * from "./compare.js";
4
+ export * from "./error.js";
5
+ export * from "./event.js";
6
+ export * from "./filter.js";
7
+ export * from "./GenericCache.js";
8
+ export * from "./Observable/AggregatedLoadingObservable.js";
9
+ export * from "./Observable/LogObservable.js";
10
+ export * from "./Observable/LogProducer.js";
11
+ export * from "./Observable/Observable.js";
12
+ export * from "./PromiseCache.js";
13
+ export * from "./utilitiesArray.js";
14
+ export * from "./utilitiesFile.js";
15
+ export * from "./utilitiesImage.js";
16
+ export * from "./utilitiesMath.js";
17
+ export * from "./utilitiesPrice.js";
18
+ export * from "./utilitiesPromise.js";
19
+ export * from "./utilitiesString.js";
20
+ export * from "./utilitiesUnits.js";
21
+ export * from "./utilitiesWeb.js";
22
22
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,21 +1,21 @@
1
- export * from "./assert.js";
2
- export * from "./cmMips.js";
3
- export * from "./compare.js";
4
- export * from "./error.js";
5
- export * from "./event.js";
6
- export * from "./filter.js";
7
- export * from "./GenericCache.js";
8
- export * from "./Observable/AggregatedLoadingObservable.js";
9
- export * from "./Observable/LogObservable.js";
10
- export * from "./Observable/LogProducer.js";
11
- export * from "./Observable/Observable.js";
12
- export * from "./PromiseCache.js";
13
- export * from "./utilitiesArray.js";
14
- export * from "./utilitiesFile.js";
15
- export * from "./utilitiesImage.js";
16
- export * from "./utilitiesMath.js";
17
- export * from "./utilitiesPrice.js";
18
- export * from "./utilitiesPromise.js";
19
- export * from "./utilitiesString.js";
20
- export * from "./utilitiesUnits.js";
21
- export * from "./utilitiesWeb.js";
1
+ export * from "./assert.js";
2
+ export * from "./cmMips.js";
3
+ export * from "./compare.js";
4
+ export * from "./error.js";
5
+ export * from "./event.js";
6
+ export * from "./filter.js";
7
+ export * from "./GenericCache.js";
8
+ export * from "./Observable/AggregatedLoadingObservable.js";
9
+ export * from "./Observable/LogObservable.js";
10
+ export * from "./Observable/LogProducer.js";
11
+ export * from "./Observable/Observable.js";
12
+ export * from "./PromiseCache.js";
13
+ export * from "./utilitiesArray.js";
14
+ export * from "./utilitiesFile.js";
15
+ export * from "./utilitiesImage.js";
16
+ export * from "./utilitiesMath.js";
17
+ export * from "./utilitiesPrice.js";
18
+ export * from "./utilitiesPromise.js";
19
+ export * from "./utilitiesString.js";
20
+ export * from "./utilitiesUnits.js";
21
+ export * from "./utilitiesWeb.js";
@@ -1,5 +1,5 @@
1
- export declare function shuffle<T>(items: T[]): T[];
2
- export declare function count<T>(items: T[], predicate: (item: T) => boolean): number;
3
- export declare function someMatch<T>(items: T[], predicate: (left: T, right: T) => boolean): boolean;
4
- export declare function compareArrays<T>(left: T[], right: T[], predicate?: (l: T, r: T) => boolean, strictOrder?: boolean): boolean;
1
+ export declare function shuffle<T>(items: T[]): T[];
2
+ export declare function count<T>(items: T[], predicate: (item: T) => boolean): number;
3
+ export declare function someMatch<T>(items: T[], predicate: (left: T, right: T) => boolean): boolean;
4
+ export declare function compareArrays<T>(left: T[], right: T[], predicate?: (l: T, r: T) => boolean, strictOrder?: boolean): boolean;
5
5
  //# sourceMappingURL=utilitiesArray.d.ts.map