yummies 5.11.0 → 5.11.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.
- package/async.cjs +1 -1
- package/async.cjs.map +1 -1
- package/async.js +38 -21
- package/async.js.map +1 -1
- package/common.cjs +1 -1
- package/common.cjs.map +1 -1
- package/common.js +9 -3
- package/common.js.map +1 -1
- package/complex.cjs +1 -1
- package/complex.cjs.map +1 -1
- package/complex.js +56 -33
- package/complex.js.map +1 -1
- package/cookie.cjs +1 -1
- package/cookie.cjs.map +1 -1
- package/cookie.js +7 -2
- package/cookie.js.map +1 -1
- package/css.cjs +1 -1
- package/css.cjs.map +1 -1
- package/css.js +41 -20
- package/css.js.map +1 -1
- package/data.cjs +1 -1
- package/data.cjs.map +1 -1
- package/data.js +35 -25
- package/data.js.map +1 -1
- package/date-time.cjs +1 -1
- package/date-time.cjs.map +1 -1
- package/date-time.d.ts.map +1 -1
- package/date-time.js +332 -250
- package/date-time.js.map +1 -1
- package/device.cjs +1 -1
- package/device.cjs.map +1 -1
- package/device.js +27 -18
- package/device.js.map +1 -1
- package/encodings.cjs +1 -1
- package/encodings.cjs.map +1 -1
- package/encodings.js +10 -10
- package/encodings.js.map +1 -1
- package/errors.cjs +1 -1
- package/errors.cjs.map +1 -1
- package/errors.d.ts.map +1 -1
- package/errors.js +21 -6
- package/errors.js.map +1 -1
- package/file.cjs +1 -1
- package/file.cjs.map +1 -1
- package/file.js +26 -17
- package/file.js.map +1 -1
- package/format/percent.d.ts +2 -2
- package/format/percent.d.ts.map +1 -1
- package/format.cjs +1 -1
- package/format.cjs.map +1 -1
- package/format.js +66 -42
- package/format.js.map +1 -1
- package/html.cjs +1 -1
- package/html.cjs.map +1 -1
- package/html.d.ts +1 -1
- package/html.d.ts.map +1 -1
- package/html.js +111 -68
- package/html.js.map +1 -1
- package/id.cjs +1 -2
- package/id.cjs.map +1 -1
- package/id.js +23 -13
- package/id.js.map +1 -1
- package/imports.cjs +1 -1
- package/imports.cjs.map +1 -1
- package/imports.js +27 -18
- package/imports.js.map +1 -1
- package/math.cjs +1 -1
- package/math.cjs.map +1 -1
- package/math.js +10 -8
- package/math.js.map +1 -1
- package/media.cjs +1 -1
- package/media.cjs.map +1 -1
- package/media.js +94 -49
- package/media.js.map +1 -1
- package/mobx/deep-observable-struct.d.ts.map +1 -1
- package/mobx.cjs +1 -1
- package/mobx.cjs.map +1 -1
- package/mobx.js +123 -68
- package/mobx.js.map +1 -1
- package/ms.cjs +1 -1
- package/ms.cjs.map +1 -1
- package/ms.js +9 -8
- package/ms.js.map +1 -1
- package/number.cjs +1 -1
- package/number.cjs.map +1 -1
- package/number.js +7 -6
- package/number.js.map +1 -1
- package/package.json +34 -33
- package/parser.cjs +1 -1
- package/parser.cjs.map +1 -1
- package/parser.js +64 -10
- package/parser.js.map +1 -1
- package/price.cjs +1 -1
- package/price.cjs.map +1 -1
- package/price.js +14 -7
- package/price.js.map +1 -1
- package/random.cjs +1 -1
- package/random.cjs.map +1 -1
- package/random.js +22 -9
- package/random.js.map +1 -1
- package/react.cjs +1 -1
- package/react.cjs.map +1 -1
- package/react.js +195 -130
- package/react.js.map +1 -1
- package/sound.cjs +1 -1
- package/sound.cjs.map +1 -1
- package/sound.js +8 -4
- package/sound.js.map +1 -1
- package/text.cjs +1 -1
- package/text.cjs.map +1 -1
- package/text.js +30 -14
- package/text.js.map +1 -1
- package/type-guard.cjs +1 -1
- package/type-guard.cjs.map +1 -1
- package/type-guard.js +93 -2
- package/type-guard.js.map +1 -1
- package/utility-types.d.ts +4 -0
- package/utils/types.d.ts +4 -0
- package/utils/types.d.ts.map +1 -1
- package/vibrate.cjs +1 -1
- package/vibrate.cjs.map +1 -1
- package/vibrate.js +5 -3
- package/vibrate.js.map +1 -1
- package/~constants-CFexlSUS.js +0 -7
- package/~constants-CFexlSUS.js.map +0 -1
- package/~constants-HmaulHpr.js +0 -2
- package/~constants-HmaulHpr.js.map +0 -1
- package/~index-C3wKHvHr.js +0 -80
- package/~index-C3wKHvHr.js.map +0 -1
- package/~index-PKNbSTT-.js +0 -2
- package/~index-PKNbSTT-.js.map +0 -1
- package/~number-B1MpW9GU.js +0 -2
- package/~number-B1MpW9GU.js.map +0 -1
- package/~number-EWff2XI6.js +0 -25
- package/~number-EWff2XI6.js.map +0 -1
package/mobx.js
CHANGED
|
@@ -1,89 +1,144 @@
|
|
|
1
|
-
import { makeObservable
|
|
2
|
-
import {
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import { makeObservable, createAtom, action, observable, $mobx, onBecomeObserved, onBecomeUnobserved } from "mobx";
|
|
2
|
+
import { typeGuard } from "yummies/type-guard";
|
|
3
|
+
const applyObservable = (context, annotationsArray, useDecorators) => {
|
|
4
|
+
if (useDecorators) {
|
|
5
|
+
annotationsArray.forEach(([field, annotation]) => {
|
|
6
|
+
annotation(context, field);
|
|
7
|
+
});
|
|
8
|
+
makeObservable(context);
|
|
9
|
+
} else {
|
|
10
|
+
makeObservable(context, Object.fromEntries(annotationsArray));
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
const createEnhancedAtom = (name, onBecomeObservedHandler, onBecomeUnobservedHandler, meta) => {
|
|
14
|
+
const atom = createAtom(
|
|
15
|
+
name,
|
|
16
|
+
onBecomeObservedHandler && (() => onBecomeObservedHandler(atom)),
|
|
17
|
+
onBecomeUnobservedHandler && (() => onBecomeUnobservedHandler(atom))
|
|
12
18
|
);
|
|
13
|
-
|
|
19
|
+
atom.meta = meta ?? {};
|
|
20
|
+
atom.reportChanged = atom.reportChanged.bind(atom);
|
|
21
|
+
atom.reportObserved = atom.reportObserved.bind(atom);
|
|
22
|
+
return atom;
|
|
14
23
|
};
|
|
15
|
-
class
|
|
24
|
+
class DeepObservableStruct {
|
|
16
25
|
data;
|
|
17
|
-
constructor(
|
|
18
|
-
this.data =
|
|
19
|
-
|
|
20
|
-
|
|
26
|
+
constructor(data) {
|
|
27
|
+
this.data = data;
|
|
28
|
+
makeObservable(this, {
|
|
29
|
+
data: observable.deep,
|
|
30
|
+
set: action
|
|
21
31
|
});
|
|
22
32
|
}
|
|
23
|
-
set(
|
|
24
|
-
const
|
|
25
|
-
|
|
33
|
+
set(newData) {
|
|
34
|
+
const stack = Object.keys(this.data).map((key) => [
|
|
35
|
+
key,
|
|
26
36
|
this.data,
|
|
27
|
-
|
|
37
|
+
newData
|
|
28
38
|
]);
|
|
29
|
-
let
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
let currentIndex = 0;
|
|
40
|
+
let stackLength = stack.length;
|
|
41
|
+
while (currentIndex < stackLength) {
|
|
42
|
+
const [key, currObservableData, newData2] = stack[currentIndex];
|
|
43
|
+
const newValue = newData2[key];
|
|
44
|
+
const currValue = currObservableData[key];
|
|
45
|
+
currentIndex++;
|
|
46
|
+
if (key in newData2) {
|
|
47
|
+
if (typeGuard.isObject(newValue) && typeGuard.isObject(currValue)) {
|
|
48
|
+
const newValueKeys = Object.keys(newValue);
|
|
49
|
+
Object.keys(currValue).forEach((childKey) => {
|
|
50
|
+
if (!(childKey in newValue)) {
|
|
51
|
+
delete currObservableData[key][childKey];
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
newValueKeys.forEach((childKey) => {
|
|
55
|
+
const length = stack.push([
|
|
56
|
+
childKey,
|
|
57
|
+
currObservableData[key],
|
|
58
|
+
newValue
|
|
42
59
|
]);
|
|
60
|
+
stackLength = length;
|
|
43
61
|
});
|
|
44
|
-
} else
|
|
45
|
-
|
|
46
|
-
|
|
62
|
+
} else if (newValue !== currValue) {
|
|
63
|
+
currObservableData[key] = newValue;
|
|
64
|
+
}
|
|
65
|
+
} else {
|
|
66
|
+
delete currObservableData[key];
|
|
67
|
+
}
|
|
47
68
|
}
|
|
48
|
-
Object.keys(
|
|
49
|
-
|
|
69
|
+
Object.keys(newData).forEach((newDataKey) => {
|
|
70
|
+
if (!this.data[newDataKey]) {
|
|
71
|
+
this.data[newDataKey] = newData[newDataKey];
|
|
72
|
+
}
|
|
50
73
|
});
|
|
51
74
|
}
|
|
52
75
|
}
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
76
|
+
const getMobxAdministration = (context) => context[$mobx];
|
|
77
|
+
const lazyObserve = ({
|
|
78
|
+
context,
|
|
79
|
+
property,
|
|
80
|
+
onStart,
|
|
81
|
+
onEnd,
|
|
82
|
+
endDelay = false
|
|
59
83
|
}) => {
|
|
60
|
-
let
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
84
|
+
let timeoutId;
|
|
85
|
+
let metaData;
|
|
86
|
+
const observingProps = /* @__PURE__ */ new Set();
|
|
87
|
+
const properties = Array.isArray(property) ? property : [property];
|
|
88
|
+
const cleanup = () => {
|
|
89
|
+
observingProps.clear();
|
|
90
|
+
if (endDelay === false) {
|
|
91
|
+
onEnd?.(metaData, cleanup);
|
|
92
|
+
metaData = void 0;
|
|
64
93
|
return;
|
|
65
94
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
const g = n.size > 0;
|
|
76
|
-
h || g || b();
|
|
95
|
+
if (timeoutId) {
|
|
96
|
+
clearTimeout(timeoutId);
|
|
97
|
+
timeoutId = void 0;
|
|
98
|
+
}
|
|
99
|
+
timeoutId = setTimeout(() => {
|
|
100
|
+
onEnd?.(metaData, cleanup);
|
|
101
|
+
timeoutId = void 0;
|
|
102
|
+
metaData = void 0;
|
|
103
|
+
}, endDelay);
|
|
77
104
|
};
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
105
|
+
const start = (property2) => {
|
|
106
|
+
const isAlreadyObserving = observingProps.size > 0;
|
|
107
|
+
observingProps.add(property2);
|
|
108
|
+
if (isAlreadyObserving) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
if (timeoutId) {
|
|
112
|
+
clearTimeout(timeoutId);
|
|
113
|
+
timeoutId = void 0;
|
|
114
|
+
}
|
|
115
|
+
metaData = onStart?.();
|
|
116
|
+
};
|
|
117
|
+
const stop = (property2) => {
|
|
118
|
+
const isAlreadyNotObserving = !observingProps.size;
|
|
119
|
+
observingProps.delete(property2);
|
|
120
|
+
const isObserving = observingProps.size > 0;
|
|
121
|
+
if (isAlreadyNotObserving || isObserving) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
cleanup();
|
|
125
|
+
};
|
|
126
|
+
properties.forEach((property2) => {
|
|
127
|
+
if (context) {
|
|
128
|
+
onBecomeObserved(context, property2, () => start(property2));
|
|
129
|
+
onBecomeUnobserved(context, property2, () => stop(property2));
|
|
130
|
+
} else {
|
|
131
|
+
onBecomeObserved(property2, () => start(property2));
|
|
132
|
+
onBecomeUnobserved(property2, () => stop(property2));
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
return cleanup;
|
|
81
136
|
};
|
|
82
137
|
export {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
138
|
+
DeepObservableStruct,
|
|
139
|
+
applyObservable,
|
|
140
|
+
createEnhancedAtom,
|
|
141
|
+
getMobxAdministration,
|
|
142
|
+
lazyObserve
|
|
88
143
|
};
|
|
89
144
|
//# sourceMappingURL=mobx.js.map
|
package/mobx.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mobx.js","sources":["../src/mobx/apply-observable.ts","../src/mobx/create-enhanced-atom.ts","../src/mobx/deep-observable-struct.ts","../src/mobx/get-mobx-administration.ts","../src/mobx/lazy-observe.ts"],"sourcesContent":["import { makeObservable } from 'mobx';\nimport type { AnyObject } from 'yummies/utils/types';\n\nexport type ObservableAnnotationsArray = [string, any][];\n\nexport const applyObservable = (\n context: AnyObject,\n annotationsArray: ObservableAnnotationsArray,\n useDecorators?: boolean,\n) => {\n if (useDecorators) {\n annotationsArray.forEach(([field, annotation]) => {\n annotation(context, field);\n });\n\n makeObservable(context);\n } else {\n makeObservable(context, Object.fromEntries(annotationsArray));\n }\n};\n","import { createAtom, type IAtom } from 'mobx';\nimport type { AnyObject } from 'yummies/utils/types';\n\nexport interface IEnhancedAtom<TMeta extends AnyObject = AnyObject>\n extends IAtom {\n meta: TMeta;\n}\n\n/**\n * Creates an enhanced atom with meta data\n * And bind `reportChanged` and `reportObserved` method to the atom\n */\nexport const createEnhancedAtom = <TMeta extends AnyObject>(\n name: string,\n onBecomeObservedHandler?: (atom: IEnhancedAtom<TMeta>) => void,\n onBecomeUnobservedHandler?: (atom: IEnhancedAtom<TMeta>) => void,\n meta?: TMeta,\n): IEnhancedAtom<TMeta> => {\n const atom = createAtom(\n name,\n onBecomeObservedHandler && (() => onBecomeObservedHandler(atom)),\n onBecomeUnobservedHandler && (() => onBecomeUnobservedHandler(atom)),\n ) as IEnhancedAtom<TMeta>;\n atom.meta = meta ?? ({} as TMeta);\n atom.reportChanged = atom.reportChanged.bind(atom);\n atom.reportObserved = atom.reportObserved.bind(atom);\n return atom;\n};\n","import { action, makeObservable, observable } from 'mobx';\nimport
|
|
1
|
+
{"version":3,"file":"mobx.js","sources":["../src/mobx/apply-observable.ts","../src/mobx/create-enhanced-atom.ts","../src/mobx/deep-observable-struct.ts","../src/mobx/get-mobx-administration.ts","../src/mobx/lazy-observe.ts"],"sourcesContent":["import { makeObservable } from 'mobx';\nimport type { AnyObject } from 'yummies/utils/types';\n\nexport type ObservableAnnotationsArray = [string, any][];\n\nexport const applyObservable = (\n context: AnyObject,\n annotationsArray: ObservableAnnotationsArray,\n useDecorators?: boolean,\n) => {\n if (useDecorators) {\n annotationsArray.forEach(([field, annotation]) => {\n annotation(context, field);\n });\n\n makeObservable(context);\n } else {\n makeObservable(context, Object.fromEntries(annotationsArray));\n }\n};\n","import { createAtom, type IAtom } from 'mobx';\nimport type { AnyObject } from 'yummies/utils/types';\n\nexport interface IEnhancedAtom<TMeta extends AnyObject = AnyObject>\n extends IAtom {\n meta: TMeta;\n}\n\n/**\n * Creates an enhanced atom with meta data\n * And bind `reportChanged` and `reportObserved` method to the atom\n */\nexport const createEnhancedAtom = <TMeta extends AnyObject>(\n name: string,\n onBecomeObservedHandler?: (atom: IEnhancedAtom<TMeta>) => void,\n onBecomeUnobservedHandler?: (atom: IEnhancedAtom<TMeta>) => void,\n meta?: TMeta,\n): IEnhancedAtom<TMeta> => {\n const atom = createAtom(\n name,\n onBecomeObservedHandler && (() => onBecomeObservedHandler(atom)),\n onBecomeUnobservedHandler && (() => onBecomeUnobservedHandler(atom)),\n ) as IEnhancedAtom<TMeta>;\n atom.meta = meta ?? ({} as TMeta);\n atom.reportChanged = atom.reportChanged.bind(atom);\n atom.reportObserved = atom.reportObserved.bind(atom);\n return atom;\n};\n","import { action, makeObservable, observable } from 'mobx';\nimport { typeGuard } from 'yummies/type-guard';\nimport type { AnyObject } from 'yummies/utils/types';\n\nexport class DeepObservableStruct<TData extends AnyObject> {\n data: TData;\n\n constructor(data: TData) {\n this.data = data;\n\n makeObservable(this, {\n data: observable.deep,\n set: action,\n });\n }\n\n set(newData: Partial<TData>) {\n type StackItem = [key: string, currObservable: AnyObject, new: AnyObject];\n\n const stack: StackItem[] = Object.keys(this.data).map((key) => [\n key,\n this.data,\n newData,\n ]);\n\n let currentIndex = 0;\n let stackLength = stack.length;\n\n while (currentIndex < stackLength) {\n const [key, currObservableData, newData] = stack[currentIndex];\n const newValue = newData[key];\n const currValue = currObservableData[key];\n\n currentIndex++;\n\n if (key in newData) {\n if (typeGuard.isObject(newValue) && typeGuard.isObject(currValue)) {\n const newValueKeys = Object.keys(newValue);\n\n Object.keys(currValue).forEach((childKey) => {\n if (!(childKey in newValue)) {\n delete currObservableData[key][childKey];\n }\n });\n\n newValueKeys.forEach((childKey) => {\n const length = stack.push([\n childKey,\n currObservableData[key],\n newValue,\n ]);\n stackLength = length;\n });\n } else if (newValue !== currValue) {\n currObservableData[key] = newValue;\n }\n } else {\n delete currObservableData[key];\n }\n }\n\n Object.keys(newData).forEach((newDataKey) => {\n if (!this.data[newDataKey]) {\n // @ts-expect-error\n this.data[newDataKey] = newData[newDataKey];\n }\n });\n }\n}\n","import { $mobx, type AnnotationMapEntry } from 'mobx';\nimport type { AnyObject } from 'yummies/utils/types';\n\ntype ObservableObjectAdministration = Parameters<\n Exclude<AnnotationMapEntry, boolean>['make_']\n>[0];\n\nexport const getMobxAdministration = (\n context: AnyObject,\n): ObservableObjectAdministration => context[$mobx];\n","import { onBecomeObserved, onBecomeUnobserved } from 'mobx';\n\n/**\n * When ONE OF the properties is becomes observed then `onStart` function is called.\n * WHen ALL properties are unobserved then `onEnd` function is called with the `metaData` that was returned by `onStart`.\n *\n * It uses `onBecomeObserved` and `onBecomeUnobserved` mobx hooks to perform lazy observation.\n */\nexport const lazyObserve = <TMetaData = void>({\n context,\n property,\n onStart,\n onEnd,\n endDelay = false,\n}: {\n context?: any;\n property: any | any[];\n onStart?: () => TMetaData;\n onEnd?: (metaData: TMetaData, cleanupFn: VoidFunction) => void;\n endDelay?: number | false;\n}) => {\n let timeoutId: ReturnType<typeof setTimeout> | undefined;\n let metaData: TMetaData | undefined;\n const observingProps = new Set<string>();\n const properties = Array.isArray(property) ? property : [property];\n\n const cleanup = () => {\n observingProps.clear();\n\n if (endDelay === false) {\n onEnd?.(metaData!, cleanup);\n metaData = undefined;\n return;\n }\n\n if (timeoutId) {\n clearTimeout(timeoutId);\n timeoutId = undefined;\n }\n\n timeoutId = setTimeout(() => {\n onEnd?.(metaData!, cleanup);\n timeoutId = undefined;\n metaData = undefined;\n }, endDelay);\n };\n\n const start = (property: string) => {\n const isAlreadyObserving = observingProps.size > 0;\n observingProps.add(property);\n\n if (isAlreadyObserving) {\n return;\n }\n\n if (timeoutId) {\n clearTimeout(timeoutId);\n timeoutId = undefined;\n }\n\n metaData = onStart?.();\n };\n\n const stop = (property: string) => {\n const isAlreadyNotObserving = !observingProps.size;\n\n observingProps.delete(property);\n\n const isObserving = observingProps.size > 0;\n\n if (isAlreadyNotObserving || isObserving) {\n return;\n }\n\n cleanup();\n };\n\n properties.forEach((property) => {\n if (context) {\n onBecomeObserved(context, property, () => start(property));\n onBecomeUnobserved(context, property, () => stop(property));\n } else {\n onBecomeObserved(property, () => start(property));\n onBecomeUnobserved(property, () => stop(property));\n }\n });\n\n return cleanup;\n};\n"],"names":["newData","property"],"mappings":"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"}
|
package/ms.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e={ms:1,sec:1e3,min:
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e={ms:1,sec:1e3,min:6e4,hour:36e5,day:864e5,week:6048e5};exports.ms=(s,t="ms")=>s*e[t],exports.unitsToMs=e;
|
|
2
2
|
//# sourceMappingURL=ms.cjs.map
|
package/ms.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ms.cjs","sources":["../src/ms.ts"],"sourcesContent":["export const unitsToMs = {\n ms: 1,\n sec: 1000,\n min: 1000 * 60,\n hour: 1000 * 60 * 60,\n day: 1000 * 60 * 60 * 24,\n week: 1000 * 60 * 60 * 24 * 7,\n} as const;\n\n/**\n * Переводит значение в юнитах в миллисекунды\n *\n * @example\n * ```ts\n * ms(1, 'min') // 60_000\n * ms(30, 'sec') // 30_000\n * ```\n */\nexport const ms = (value: number, unit: keyof typeof unitsToMs = 'ms') =>\n value * unitsToMs[unit];\n"],"names":["unitsToMs","ms","value","unit"],"mappings":"gFAAO,MAAMA,EAAY,
|
|
1
|
+
{"version":3,"file":"ms.cjs","sources":["../src/ms.ts"],"sourcesContent":["export const unitsToMs = {\n ms: 1,\n sec: 1000,\n min: 1000 * 60,\n hour: 1000 * 60 * 60,\n day: 1000 * 60 * 60 * 24,\n week: 1000 * 60 * 60 * 24 * 7,\n} as const;\n\n/**\n * Переводит значение в юнитах в миллисекунды\n *\n * @example\n * ```ts\n * ms(1, 'min') // 60_000\n * ms(30, 'sec') // 30_000\n * ```\n */\nexport const ms = (value: number, unit: keyof typeof unitsToMs = 'ms') =>\n value * unitsToMs[unit];\n"],"names":["unitsToMs","ms","sec","min","hour","day","week","value","unit"],"mappings":"gFAAO,MAAMA,EAAY,CACvBC,GAAI,EACJC,IAAK,IACLC,IAAK,IACLC,KAAM,KACNC,IAAK,MACLC,KAAM,mBAYU,CAACC,EAAeC,EAA+B,OAC/DD,EAAQP,EAAUQ"}
|
package/ms.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
const
|
|
1
|
+
const unitsToMs = {
|
|
2
2
|
ms: 1,
|
|
3
3
|
sec: 1e3,
|
|
4
|
-
min:
|
|
5
|
-
hour:
|
|
6
|
-
day:
|
|
7
|
-
week:
|
|
8
|
-
}
|
|
4
|
+
min: 1e3 * 60,
|
|
5
|
+
hour: 1e3 * 60 * 60,
|
|
6
|
+
day: 1e3 * 60 * 60 * 24,
|
|
7
|
+
week: 1e3 * 60 * 60 * 24 * 7
|
|
8
|
+
};
|
|
9
|
+
const ms = (value, unit = "ms") => value * unitsToMs[unit];
|
|
9
10
|
export {
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
ms,
|
|
12
|
+
unitsToMs
|
|
12
13
|
};
|
|
13
14
|
//# sourceMappingURL=ms.js.map
|
package/ms.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ms.js","sources":["../src/ms.ts"],"sourcesContent":["export const unitsToMs = {\n ms: 1,\n sec: 1000,\n min: 1000 * 60,\n hour: 1000 * 60 * 60,\n day: 1000 * 60 * 60 * 24,\n week: 1000 * 60 * 60 * 24 * 7,\n} as const;\n\n/**\n * Переводит значение в юнитах в миллисекунды\n *\n * @example\n * ```ts\n * ms(1, 'min') // 60_000\n * ms(30, 'sec') // 30_000\n * ```\n */\nexport const ms = (value: number, unit: keyof typeof unitsToMs = 'ms') =>\n value * unitsToMs[unit];\n"],"names":[
|
|
1
|
+
{"version":3,"file":"ms.js","sources":["../src/ms.ts"],"sourcesContent":["export const unitsToMs = {\n ms: 1,\n sec: 1000,\n min: 1000 * 60,\n hour: 1000 * 60 * 60,\n day: 1000 * 60 * 60 * 24,\n week: 1000 * 60 * 60 * 24 * 7,\n} as const;\n\n/**\n * Переводит значение в юнитах в миллисекунды\n *\n * @example\n * ```ts\n * ms(1, 'min') // 60_000\n * ms(30, 'sec') // 30_000\n * ```\n */\nexport const ms = (value: number, unit: keyof typeof unitsToMs = 'ms') =>\n value * unitsToMs[unit];\n"],"names":[],"mappings":"AAAO,MAAM,YAAY;AAAA,EACvB,IAAI;AAAA,EACJ,KAAK;AAAA,EACL,KAAK,MAAO;AAAA,EACZ,MAAM,MAAO,KAAK;AAAA,EAClB,KAAK,MAAO,KAAK,KAAK;AAAA,EACtB,MAAM,MAAO,KAAK,KAAK,KAAK;AAC9B;AAWO,MAAM,KAAK,CAAC,OAAe,OAA+B,SAC/D,QAAQ,UAAU,IAAI;"}
|
package/number.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"})
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"}),exports.round=function(t,r=0){if(!r)return Math.round(t);const e=10**r;return Math.round(t*e)/e};
|
|
2
2
|
//# sourceMappingURL=number.cjs.map
|
package/number.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number.cjs","sources":["../src/number.ts"],"sourcesContent":["/**\n * Works like `parseFloat(number.toFixed(4))` but performance better\n *\n * @example\n * round(191.212999999999999999999999, 4) // 191.213\n */\nexport function round(value: number, decimalPlaces: number = 0): number {\n if (!decimalPlaces) {\n return Math.round(value);\n }\n\n const factor = 10 ** decimalPlaces;\n return Math.round(value * factor) / factor;\n}\n"],"names":["
|
|
1
|
+
{"version":3,"file":"number.cjs","sources":["../src/number.ts"],"sourcesContent":["/**\n * Works like `parseFloat(number.toFixed(4))` but performance better\n *\n * @example\n * round(191.212999999999999999999999, 4) // 191.213\n */\nexport function round(value: number, decimalPlaces: number = 0): number {\n if (!decimalPlaces) {\n return Math.round(value);\n }\n\n const factor = 10 ** decimalPlaces;\n return Math.round(value * factor) / factor;\n}\n"],"names":["value","decimalPlaces","Math","round","factor"],"mappings":"8FAMO,SAAeA,EAAeC,EAAwB,GAC3D,IAAKA,EACH,OAAOC,KAAKC,MAAMH,GAGpB,MAAMI,EAAS,IAAMH,EACrB,OAAOC,KAAKC,MAAMH,EAAQI,GAAUA,CACtC"}
|
package/number.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
function
|
|
2
|
-
if (!
|
|
3
|
-
return Math.round(
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
function round(value, decimalPlaces = 0) {
|
|
2
|
+
if (!decimalPlaces) {
|
|
3
|
+
return Math.round(value);
|
|
4
|
+
}
|
|
5
|
+
const factor = 10 ** decimalPlaces;
|
|
6
|
+
return Math.round(value * factor) / factor;
|
|
6
7
|
}
|
|
7
8
|
export {
|
|
8
|
-
|
|
9
|
+
round
|
|
9
10
|
};
|
|
10
11
|
//# sourceMappingURL=number.js.map
|
package/number.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number.js","sources":["../src/number.ts"],"sourcesContent":["/**\n * Works like `parseFloat(number.toFixed(4))` but performance better\n *\n * @example\n * round(191.212999999999999999999999, 4) // 191.213\n */\nexport function round(value: number, decimalPlaces: number = 0): number {\n if (!decimalPlaces) {\n return Math.round(value);\n }\n\n const factor = 10 ** decimalPlaces;\n return Math.round(value * factor) / factor;\n}\n"],"names":[
|
|
1
|
+
{"version":3,"file":"number.js","sources":["../src/number.ts"],"sourcesContent":["/**\n * Works like `parseFloat(number.toFixed(4))` but performance better\n *\n * @example\n * round(191.212999999999999999999999, 4) // 191.213\n */\nexport function round(value: number, decimalPlaces: number = 0): number {\n if (!decimalPlaces) {\n return Math.round(value);\n }\n\n const factor = 10 ** decimalPlaces;\n return Math.round(value * factor) / factor;\n}\n"],"names":[],"mappings":"AAMO,SAAS,MAAM,OAAe,gBAAwB,GAAW;AACtE,MAAI,CAAC,eAAe;AAClB,WAAO,KAAK,MAAM,KAAK;AAAA,EACzB;AAEA,QAAM,SAAS,MAAM;AACrB,SAAO,KAAK,MAAM,QAAQ,MAAM,IAAI;AACtC;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yummies",
|
|
3
|
-
"version": "5.11.
|
|
3
|
+
"version": "5.11.2",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"javascript",
|
|
6
6
|
"typescript",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"lefthook": "^1.11.16",
|
|
53
53
|
"nodemon": "^3.1.9",
|
|
54
54
|
"rimraf": "^6.0.1",
|
|
55
|
-
"sborshik": "^1.0.
|
|
55
|
+
"sborshik": "^1.0.33",
|
|
56
56
|
"tsx": "^4.20.5",
|
|
57
57
|
"typescript": "^5.8.3",
|
|
58
58
|
"vite": "^7.1.9",
|
|
@@ -67,181 +67,182 @@
|
|
|
67
67
|
"./async": {
|
|
68
68
|
"import": "./async.js",
|
|
69
69
|
"default": "./async.js",
|
|
70
|
-
"types": "./async.d.ts",
|
|
70
|
+
"types": "./async/index.d.ts",
|
|
71
71
|
"require": "./async.cjs"
|
|
72
72
|
},
|
|
73
73
|
"./common": {
|
|
74
74
|
"import": "./common.js",
|
|
75
75
|
"default": "./common.js",
|
|
76
|
-
"types": "./common.d.ts",
|
|
76
|
+
"types": "./common/index.d.ts",
|
|
77
77
|
"require": "./common.cjs"
|
|
78
78
|
},
|
|
79
79
|
"./complex": {
|
|
80
80
|
"import": "./complex.js",
|
|
81
81
|
"default": "./complex.js",
|
|
82
|
-
"types": "./complex.d.ts",
|
|
82
|
+
"types": "./complex/index.d.ts",
|
|
83
83
|
"require": "./complex.cjs"
|
|
84
84
|
},
|
|
85
85
|
"./cookie": {
|
|
86
86
|
"import": "./cookie.js",
|
|
87
87
|
"default": "./cookie.js",
|
|
88
|
-
"types": "./cookie.d.ts",
|
|
88
|
+
"types": "./cookie/index.d.ts",
|
|
89
89
|
"require": "./cookie.cjs"
|
|
90
90
|
},
|
|
91
91
|
"./css": {
|
|
92
92
|
"import": "./css.js",
|
|
93
93
|
"default": "./css.js",
|
|
94
|
-
"types": "./css.d.ts",
|
|
94
|
+
"types": "./css/index.d.ts",
|
|
95
95
|
"require": "./css.cjs"
|
|
96
96
|
},
|
|
97
97
|
"./data": {
|
|
98
98
|
"import": "./data.js",
|
|
99
99
|
"default": "./data.js",
|
|
100
|
-
"types": "./data.d.ts",
|
|
100
|
+
"types": "./data/index.d.ts",
|
|
101
101
|
"require": "./data.cjs"
|
|
102
102
|
},
|
|
103
103
|
"./date-time": {
|
|
104
104
|
"import": "./date-time.js",
|
|
105
105
|
"default": "./date-time.js",
|
|
106
|
-
"types": "./date-time.d.ts",
|
|
106
|
+
"types": "./date-time/index.d.ts",
|
|
107
107
|
"require": "./date-time.cjs"
|
|
108
108
|
},
|
|
109
109
|
"./device": {
|
|
110
110
|
"import": "./device.js",
|
|
111
111
|
"default": "./device.js",
|
|
112
|
-
"types": "./device.d.ts",
|
|
112
|
+
"types": "./device/index.d.ts",
|
|
113
113
|
"require": "./device.cjs"
|
|
114
114
|
},
|
|
115
115
|
"./encodings": {
|
|
116
116
|
"import": "./encodings.js",
|
|
117
117
|
"default": "./encodings.js",
|
|
118
|
-
"types": "./encodings.d.ts",
|
|
118
|
+
"types": "./encodings/index.d.ts",
|
|
119
119
|
"require": "./encodings.cjs"
|
|
120
120
|
},
|
|
121
121
|
"./errors": {
|
|
122
122
|
"import": "./errors.js",
|
|
123
123
|
"default": "./errors.js",
|
|
124
|
-
"types": "./errors.d.ts",
|
|
124
|
+
"types": "./errors/index.d.ts",
|
|
125
125
|
"require": "./errors.cjs"
|
|
126
126
|
},
|
|
127
127
|
"./file": {
|
|
128
128
|
"import": "./file.js",
|
|
129
129
|
"default": "./file.js",
|
|
130
|
-
"types": "./file.d.ts",
|
|
130
|
+
"types": "./file/index.d.ts",
|
|
131
131
|
"require": "./file.cjs"
|
|
132
132
|
},
|
|
133
133
|
"./format": {
|
|
134
134
|
"import": "./format.js",
|
|
135
135
|
"default": "./format.js",
|
|
136
|
-
"types": "./format.d.ts",
|
|
136
|
+
"types": "./format/index.d.ts",
|
|
137
137
|
"require": "./format.cjs"
|
|
138
138
|
},
|
|
139
139
|
"./html": {
|
|
140
140
|
"import": "./html.js",
|
|
141
141
|
"default": "./html.js",
|
|
142
|
-
"types": "./html.d.ts",
|
|
142
|
+
"types": "./html/index.d.ts",
|
|
143
143
|
"require": "./html.cjs"
|
|
144
144
|
},
|
|
145
145
|
"./id": {
|
|
146
146
|
"import": "./id.js",
|
|
147
147
|
"default": "./id.js",
|
|
148
|
-
"types": "./id.d.ts",
|
|
148
|
+
"types": "./id/index.d.ts",
|
|
149
149
|
"require": "./id.cjs"
|
|
150
150
|
},
|
|
151
151
|
"./imports": {
|
|
152
152
|
"import": "./imports.js",
|
|
153
153
|
"default": "./imports.js",
|
|
154
|
-
"types": "./imports.d.ts",
|
|
154
|
+
"types": "./imports/index.d.ts",
|
|
155
155
|
"require": "./imports.cjs"
|
|
156
156
|
},
|
|
157
157
|
"./math": {
|
|
158
158
|
"import": "./math.js",
|
|
159
159
|
"default": "./math.js",
|
|
160
|
-
"types": "./math.d.ts",
|
|
160
|
+
"types": "./math/index.d.ts",
|
|
161
161
|
"require": "./math.cjs"
|
|
162
162
|
},
|
|
163
163
|
"./media": {
|
|
164
164
|
"import": "./media.js",
|
|
165
165
|
"default": "./media.js",
|
|
166
|
-
"types": "./media.d.ts",
|
|
166
|
+
"types": "./media/index.d.ts",
|
|
167
167
|
"require": "./media.cjs"
|
|
168
168
|
},
|
|
169
169
|
"./mobx": {
|
|
170
170
|
"import": "./mobx.js",
|
|
171
171
|
"default": "./mobx.js",
|
|
172
|
-
"types": "./mobx.d.ts",
|
|
172
|
+
"types": "./mobx/index.d.ts",
|
|
173
173
|
"require": "./mobx.cjs"
|
|
174
174
|
},
|
|
175
175
|
"./ms": {
|
|
176
176
|
"import": "./ms.js",
|
|
177
177
|
"default": "./ms.js",
|
|
178
|
-
"types": "./ms.d.ts",
|
|
178
|
+
"types": "./ms/index.d.ts",
|
|
179
179
|
"require": "./ms.cjs"
|
|
180
180
|
},
|
|
181
181
|
"./number": {
|
|
182
182
|
"import": "./number.js",
|
|
183
183
|
"default": "./number.js",
|
|
184
|
-
"types": "./number.d.ts",
|
|
184
|
+
"types": "./number/index.d.ts",
|
|
185
185
|
"require": "./number.cjs"
|
|
186
186
|
},
|
|
187
|
+
"./package": "./package.json",
|
|
187
188
|
"./parser": {
|
|
188
189
|
"import": "./parser.js",
|
|
189
190
|
"default": "./parser.js",
|
|
190
|
-
"types": "./parser.d.ts",
|
|
191
|
+
"types": "./parser/index.d.ts",
|
|
191
192
|
"require": "./parser.cjs"
|
|
192
193
|
},
|
|
193
194
|
"./price": {
|
|
194
195
|
"import": "./price.js",
|
|
195
196
|
"default": "./price.js",
|
|
196
|
-
"types": "./price.d.ts",
|
|
197
|
+
"types": "./price/index.d.ts",
|
|
197
198
|
"require": "./price.cjs"
|
|
198
199
|
},
|
|
199
200
|
"./random": {
|
|
200
201
|
"import": "./random.js",
|
|
201
202
|
"default": "./random.js",
|
|
202
|
-
"types": "./random.d.ts",
|
|
203
|
+
"types": "./random/index.d.ts",
|
|
203
204
|
"require": "./random.cjs"
|
|
204
205
|
},
|
|
205
206
|
"./react": {
|
|
206
207
|
"import": "./react.js",
|
|
207
208
|
"default": "./react.js",
|
|
208
|
-
"types": "./react.d.ts",
|
|
209
|
+
"types": "./react/index.d.ts",
|
|
209
210
|
"require": "./react.cjs"
|
|
210
211
|
},
|
|
211
212
|
"./sound": {
|
|
212
213
|
"import": "./sound.js",
|
|
213
214
|
"default": "./sound.js",
|
|
214
|
-
"types": "./sound.d.ts",
|
|
215
|
+
"types": "./sound/index.d.ts",
|
|
215
216
|
"require": "./sound.cjs"
|
|
216
217
|
},
|
|
217
218
|
"./text": {
|
|
218
219
|
"import": "./text.js",
|
|
219
220
|
"default": "./text.js",
|
|
220
|
-
"types": "./text.d.ts",
|
|
221
|
+
"types": "./text/index.d.ts",
|
|
221
222
|
"require": "./text.cjs"
|
|
222
223
|
},
|
|
223
224
|
"./type-guard": {
|
|
224
225
|
"import": "./type-guard.js",
|
|
225
226
|
"default": "./type-guard.js",
|
|
226
|
-
"types": "./type-guard.d.ts",
|
|
227
|
+
"types": "./type-guard/index.d.ts",
|
|
227
228
|
"require": "./type-guard.cjs"
|
|
228
229
|
},
|
|
229
230
|
"./utility-types": {
|
|
230
231
|
"import": "./utility-types.js",
|
|
231
232
|
"default": "./utility-types.js",
|
|
232
|
-
"types": "./utility-types.d.ts",
|
|
233
|
+
"types": "./utility-types/index.d.ts",
|
|
233
234
|
"require": "./utility-types.cjs"
|
|
234
235
|
},
|
|
235
236
|
"./utils/types": {
|
|
236
237
|
"import": "./utils/types.js",
|
|
237
238
|
"default": "./utils/types.js",
|
|
238
|
-
"types": "./utils/types.d.ts",
|
|
239
|
+
"types": "./utils/types/index.d.ts",
|
|
239
240
|
"require": "./utils/types.cjs"
|
|
240
241
|
},
|
|
241
242
|
"./vibrate": {
|
|
242
243
|
"import": "./vibrate.js",
|
|
243
244
|
"default": "./vibrate.js",
|
|
244
|
-
"types": "./vibrate.d.ts",
|
|
245
|
+
"types": "./vibrate/index.d.ts",
|
|
245
246
|
"require": "./vibrate.cjs"
|
|
246
247
|
},
|
|
247
248
|
"./package.json": "./package.json"
|
|
@@ -256,7 +257,7 @@
|
|
|
256
257
|
"check": "npm run lint:check && npm run ts:check",
|
|
257
258
|
"prebuild": "npm run clean && npm run check",
|
|
258
259
|
"build:watch": "pnpm build && nodemon --watch src --ext ts --exec \"pnpm build\"",
|
|
259
|
-
"build": "vite build && tsx scripts/
|
|
260
|
+
"build": "vite build && tsx scripts/generate-utility-types-file",
|
|
260
261
|
"pub": "pnpm build && sborshik publish --useDistDir",
|
|
261
262
|
"pub:patch": "PUBLISH_VERSION=patch pnpm pub",
|
|
262
263
|
"pub:minor": "PUBLISH_VERSION=minor pnpm pub",
|
package/parser.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("yummies/format"),t=require("yummies/type-guard"),r=(l,i)=>{const u={...r.defaultSettings,...i},a=u?.fallback??0;let n;if(t.typeGuard.isNumber(l))n=l;else if(t.typeGuard.isString(l)){const t=e.format.skipSpaces(l).replace(",",".");n=""===t?a:Number(t)}else n=a;return t.typeGuard.isNumber(n)?(null!=u?.clamped&&(n=Math.max(u.clamped[0]??-1/0,Math.min(n,u.clamped[1]??1/0))),null!=u?.ceil&&(n=Math.ceil(n)),null!=u?.floor&&(n=Math.floor(n)),null!=u?.digits&&(n=+n.toFixed(u.digits)),n):a};r.defaultSettings={};const l=Object.freeze(Object.defineProperty({__proto__:null,number:r,percent:(e,t,l)=>r(Number(e)/Number(t)*100,l),string:(e,r)=>{const l=r&&"fallback"in r?r.fallback:"";return null==e?l:t.typeGuard.isObject(e)?r?.prettyJson?JSON.stringify(e,null,2):JSON.stringify(e):String(e)}},Symbol.toStringTag,{value:"Module"}));exports.parser=l;
|
|
2
2
|
//# sourceMappingURL=parser.cjs.map
|
package/parser.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.cjs","sources":["../src/parser/percent.ts","../src/parser/string.ts"],"sourcesContent":["import type { Maybe } from 'yummies/utils/types';\n\nimport { type NumberParserSettings, number } from './number.js';\n\nexport const percent = <TFallback = number>(\n value: Maybe<string | number>,\n maxValue?: Maybe<string | number>,\n settings?: Maybe<NumberParserSettings<TFallback>>,\n) => {\n return number<TFallback>((Number(value) / Number(maxValue)) * 100, settings);\n};\n","import { typeGuard } from 'yummies/type-guard';\nimport type { Maybe } from 'yummies/utils/types';\n\nexport interface StringParserSettings<TFallback = string> {\n fallback?: TFallback;\n prettyJson?: boolean;\n}\n\nexport const string = <TFallback = string>(\n input: Maybe<unknown>,\n settings?: Maybe<StringParserSettings<TFallback>>,\n): string | TFallback => {\n const fallback =\n settings && 'fallback' in settings ? (settings.fallback as TFallback) : '';\n\n if (input == null) {\n return fallback;\n }\n\n if (typeGuard.isObject(input)) {\n if (settings?.prettyJson) {\n return JSON.stringify(input, null, 2);\n }\n\n return JSON.stringify(input);\n }\n\n return String(input);\n};\n"],"names":["
|
|
1
|
+
{"version":3,"file":"parser.cjs","sources":["../src/parser/number.ts","../src/parser/percent.ts","../src/parser/string.ts"],"sourcesContent":["import { format } from 'yummies/format';\nimport { typeGuard } from 'yummies/type-guard';\nimport type { Maybe } from 'yummies/utils/types';\n\nexport interface NumberParserSettings<TFallback = number> {\n digits?: number;\n fallback?: TFallback;\n /**\n * Round to upper boundary\n * 5.1 -> 6\n */\n ceil?: boolean;\n /**\n * Round to bottom boundary\n * 5.9 -> 5\n */\n floor?: boolean;\n clamped?: [min?: Maybe<number>, max?: Maybe<number>];\n}\n\nexport const number = <TFallback = number>(\n input: Maybe<unknown>,\n userSettings?: Maybe<NumberParserSettings<TFallback>>,\n): number | TFallback => {\n const settings = {\n ...number.defaultSettings,\n ...userSettings,\n };\n\n const fallback = settings?.fallback ?? 0;\n\n let result: number;\n\n if (typeGuard.isNumber(input)) {\n result = input;\n } else if (typeGuard.isString(input)) {\n const formattedInput = format.skipSpaces(input).replace(',', '.');\n if (formattedInput === '') {\n result = fallback as any;\n } else {\n result = Number(formattedInput);\n }\n } else {\n result = fallback as any;\n }\n\n if (typeGuard.isNumber(result)) {\n if (settings?.clamped != null) {\n result = Math.max(\n settings.clamped[0] ?? -Infinity,\n Math.min(result, settings.clamped[1] ?? Infinity),\n );\n }\n\n if (settings?.ceil != null) {\n result = Math.ceil(result);\n }\n\n if (settings?.floor != null) {\n result = Math.floor(result);\n }\n\n if (settings?.digits != null) {\n result = +result.toFixed(settings.digits);\n }\n\n return result;\n } else {\n return fallback;\n }\n};\n\nnumber.defaultSettings = {} as NumberParserSettings;\n","import type { Maybe } from 'yummies/utils/types';\n\nimport { type NumberParserSettings, number } from './number.js';\n\nexport const percent = <TFallback = number>(\n value: Maybe<string | number>,\n maxValue?: Maybe<string | number>,\n settings?: Maybe<NumberParserSettings<TFallback>>,\n) => {\n return number<TFallback>((Number(value) / Number(maxValue)) * 100, settings);\n};\n","import { typeGuard } from 'yummies/type-guard';\nimport type { Maybe } from 'yummies/utils/types';\n\nexport interface StringParserSettings<TFallback = string> {\n fallback?: TFallback;\n prettyJson?: boolean;\n}\n\nexport const string = <TFallback = string>(\n input: Maybe<unknown>,\n settings?: Maybe<StringParserSettings<TFallback>>,\n): string | TFallback => {\n const fallback =\n settings && 'fallback' in settings ? (settings.fallback as TFallback) : '';\n\n if (input == null) {\n return fallback;\n }\n\n if (typeGuard.isObject(input)) {\n if (settings?.prettyJson) {\n return JSON.stringify(input, null, 2);\n }\n\n return JSON.stringify(input);\n }\n\n return String(input);\n};\n"],"names":["number","input","userSettings","settings","defaultSettings","fallback","result","typeGuard","isNumber","isString","formattedInput","format","skipSpaces","replace","Number","clamped","Math","max","Infinity","min","ceil","floor","digits","toFixed","value","maxValue","isObject","prettyJson","JSON","stringify","String"],"mappings":"kJAoBaA,EAAS,CACpBC,EACAC,KAEA,MAAMC,EAAW,IACZH,EAAOI,mBACPF,GAGCG,EAAWF,GAAUE,UAAY,EAEvC,IAAIC,EAEJ,GAAIC,EAAAA,UAAUC,SAASP,GACrBK,EAASL,OACX,GAAWM,EAAAA,UAAUE,SAASR,GAAQ,CACpC,MAAMS,EAAiBC,EAAAA,OAAOC,WAAWX,GAAOY,QAAQ,IAAK,KAE3DP,EADqB,KAAnBI,EACOL,EAEAS,OAAOJ,EAEpB,MACEJ,EAASD,EAGX,OAAIE,EAAAA,UAAUC,SAASF,IACI,MAArBH,GAAUY,UACZT,EAASU,KAAKC,IACZd,EAASY,QAAQ,KAAMG,IACvBF,KAAKG,IAAIb,EAAQH,EAASY,QAAQ,IAAMG,OAItB,MAAlBf,GAAUiB,OACZd,EAASU,KAAKI,KAAKd,IAGE,MAAnBH,GAAUkB,QACZf,EAASU,KAAKK,MAAMf,IAGE,MAApBH,GAAUmB,SACZhB,GAAUA,EAAOiB,QAAQpB,EAASmB,SAG7BhB,GAEAD,GAIXL,EAAOI,gBAAkB,CAAA,ECpElB,6EAAgB,CACrBoB,EACAC,EACAtB,IAEOH,EAAmBc,OAAOU,GAASV,OAAOW,GAAa,IAAKtB,UCD/C,CACpBF,EACAE,KAEA,MAAME,EACJF,GAAY,aAAcA,EAAYA,EAASE,SAAyB,GAE1E,OAAa,MAATJ,EACKI,EAGLE,EAAAA,UAAUmB,SAASzB,GACjBE,GAAUwB,WACLC,KAAKC,UAAU5B,EAAO,KAAM,GAG9B2B,KAAKC,UAAU5B,GAGjB6B,OAAO7B"}
|