yummies 7.11.0 → 7.12.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/async.cjs +162 -48
- package/async.cjs.map +1 -1
- package/async.d.ts +108 -7
- package/async.js +163 -54
- package/async.js.map +1 -1
- package/chunk-CVq3Gv4J.cjs +50 -0
- package/chunk-YKewjYmz.js +37 -0
- package/common.cjs +48 -8
- package/common.cjs.map +1 -1
- package/common.d.ts +35 -2
- package/common.js +49 -11
- package/common.js.map +1 -1
- package/complex.cjs +275 -128
- package/complex.cjs.map +1 -1
- package/complex.js +275 -133
- package/complex.js.map +1 -1
- package/cookie.cjs +17 -7
- package/cookie.cjs.map +1 -1
- package/cookie.d.ts +8 -0
- package/cookie.js +18 -9
- package/cookie.js.map +1 -1
- package/css.cjs +147 -39
- package/css.cjs.map +1 -1
- package/css.d.ts +98 -6
- package/css.js +143 -41
- package/css.js.map +1 -1
- package/data.cjs +90 -55
- package/data.cjs.map +1 -1
- package/data.d.ts +32 -0
- package/data.js +91 -61
- package/data.js.map +1 -1
- package/date-time.cjs +578 -412
- package/date-time.cjs.map +1 -1
- package/date-time.d.ts +88 -0
- package/date-time.js +575 -421
- package/date-time.js.map +1 -1
- package/device.cjs +48 -23
- package/device.cjs.map +1 -1
- package/device.d.ts +32 -0
- package/device.js +49 -31
- package/device.js.map +1 -1
- package/encodings.cjs +275 -266
- package/encodings.cjs.map +1 -1
- package/encodings.d.ts +8 -0
- package/encodings.js +276 -268
- package/encodings.js.map +1 -1
- package/errors.cjs +20 -18
- package/errors.cjs.map +1 -1
- package/errors.js +19 -19
- package/errors.js.map +1 -1
- package/file.cjs +42 -24
- package/file.cjs.map +1 -1
- package/file.d.ts +16 -0
- package/file.js +43 -27
- package/file.js.map +1 -1
- package/format.cjs +125 -83
- package/format.cjs.map +1 -1
- package/format.js +118 -82
- package/format.js.map +1 -1
- package/html.cjs +226 -137
- package/html.cjs.map +1 -1
- package/html.d.ts +64 -0
- package/html.js +223 -150
- package/html.js.map +1 -1
- package/id.cjs +74 -17
- package/id.cjs.map +1 -1
- package/id.js +73 -24
- package/id.js.map +1 -1
- package/imports.cjs +41 -29
- package/imports.cjs.map +1 -1
- package/imports.d.ts +8 -0
- package/imports.js +40 -31
- package/imports.js.map +1 -1
- package/math.cjs +32 -6
- package/math.cjs.map +1 -1
- package/math.d.ts +16 -0
- package/math.js +33 -10
- package/math.js.map +1 -1
- package/media.cjs +275 -84
- package/media.cjs.map +1 -1
- package/media.d.ts +188 -2
- package/media.js +274 -93
- package/media.js.map +1 -1
- package/mobx.cjs +353 -193
- package/mobx.cjs.map +1 -1
- package/mobx.d.ts +7 -0
- package/mobx.js +351 -200
- package/mobx.js.map +1 -1
- package/ms.cjs +21 -10
- package/ms.cjs.map +1 -1
- package/ms.js +22 -13
- package/ms.js.map +1 -1
- package/number.cjs +13 -7
- package/number.cjs.map +1 -1
- package/number.js +14 -9
- package/number.js.map +1 -1
- package/package.json +10 -2
- package/parser.cjs +117 -64
- package/parser.cjs.map +1 -1
- package/parser.js +111 -64
- package/parser.js.map +1 -1
- package/price.cjs +24 -18
- package/price.cjs.map +1 -1
- package/price.d.ts +8 -0
- package/price.js +25 -20
- package/price.js.map +1 -1
- package/random.cjs +79 -13
- package/random.cjs.map +1 -1
- package/random.d.ts +64 -0
- package/random.js +80 -22
- package/random.js.map +1 -1
- package/react.cjs +673 -214
- package/react.cjs.map +1 -1
- package/react.d.ts +21 -0
- package/react.js +674 -239
- package/react.js.map +1 -1
- package/sound.cjs +14 -9
- package/sound.cjs.map +1 -1
- package/sound.js +15 -11
- package/sound.js.map +1 -1
- package/storage.cjs +49 -50
- package/storage.cjs.map +1 -1
- package/storage.d.ts +8 -0
- package/storage.js +50 -53
- package/storage.js.map +1 -1
- package/text.cjs +51 -34
- package/text.cjs.map +1 -1
- package/text.js +52 -37
- package/text.js.map +1 -1
- package/type-guard.cjs +292 -72
- package/type-guard.cjs.map +1 -1
- package/type-guard.js +288 -73
- package/type-guard.js.map +1 -1
- package/types.cjs +0 -2
- package/types.global.cjs +0 -2
- package/types.global.js +0 -2
- package/types.js +0 -2
- package/vibrate.cjs +31 -6
- package/vibrate.cjs.map +1 -1
- package/vibrate.d.ts +23 -1
- package/vibrate.js +32 -8
- package/vibrate.js.map +1 -1
- package/types.cjs.map +0 -1
- package/types.global.cjs.map +0 -1
- package/types.global.js.map +0 -1
- package/types.js.map +0 -1
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
9
|
+
var __exportAll = (all, no_symbols) => {
|
|
10
|
+
let target = {};
|
|
11
|
+
for (var name in all) __defProp(target, name, {
|
|
12
|
+
get: all[name],
|
|
13
|
+
enumerable: true
|
|
14
|
+
});
|
|
15
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
16
|
+
return target;
|
|
17
|
+
};
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
20
|
+
key = keys[i];
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
22
|
+
get: ((k) => from[k]).bind(null, key),
|
|
23
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
return to;
|
|
27
|
+
};
|
|
28
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
29
|
+
value: mod,
|
|
30
|
+
enumerable: true
|
|
31
|
+
}) : target, mod));
|
|
32
|
+
//#endregion
|
|
33
|
+
Object.defineProperty(exports, "__commonJSMin", {
|
|
34
|
+
enumerable: true,
|
|
35
|
+
get: function() {
|
|
36
|
+
return __commonJSMin;
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
Object.defineProperty(exports, "__exportAll", {
|
|
40
|
+
enumerable: true,
|
|
41
|
+
get: function() {
|
|
42
|
+
return __exportAll;
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
Object.defineProperty(exports, "__toESM", {
|
|
46
|
+
enumerable: true,
|
|
47
|
+
get: function() {
|
|
48
|
+
return __toESM;
|
|
49
|
+
}
|
|
50
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
9
|
+
var __exportAll = (all, no_symbols) => {
|
|
10
|
+
let target = {};
|
|
11
|
+
for (var name in all) __defProp(target, name, {
|
|
12
|
+
get: all[name],
|
|
13
|
+
enumerable: true
|
|
14
|
+
});
|
|
15
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
16
|
+
return target;
|
|
17
|
+
};
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
20
|
+
key = keys[i];
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
22
|
+
get: ((k) => from[k]).bind(null, key),
|
|
23
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
return to;
|
|
27
|
+
};
|
|
28
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
29
|
+
value: mod,
|
|
30
|
+
enumerable: true
|
|
31
|
+
}) : target, mod));
|
|
32
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, { get: (a, b) => (typeof require !== "undefined" ? require : a)[b] }) : x)(function(x) {
|
|
33
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
34
|
+
throw Error("Calling `require` for \"" + x + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
|
|
35
|
+
});
|
|
36
|
+
//#endregion
|
|
37
|
+
export { __toESM as i, __exportAll as n, __require as r, __commonJSMin as t };
|
package/common.cjs
CHANGED
|
@@ -1,12 +1,52 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
//#region src/common.ts
|
|
3
|
+
/**
|
|
4
|
+
* Normalizes a {@link MaybeFn} — a value that may be either a plain `TValue` or a function
|
|
5
|
+
* `(...args: TArgs) => TValue`. If `fn` is callable, it is invoked with `args` and the return
|
|
6
|
+
* value is returned; otherwise `fn` is returned as-is (treated as the resolved value).
|
|
7
|
+
*
|
|
8
|
+
* Typical uses: config fields that accept a static value or a lazy/computed factory, theme
|
|
9
|
+
* tokens, labels, or callbacks where the caller should not branch on `typeof fn` themselves.
|
|
10
|
+
*
|
|
11
|
+
* @template TValue - Result type when `fn` is not a function, or return type when it is.
|
|
12
|
+
* @template TArgs - Tuple of argument types passed through when `fn` is invoked.
|
|
13
|
+
*
|
|
14
|
+
* @param fn - Either a `TValue` or a function producing `TValue` from `args`.
|
|
15
|
+
* @param args - Arguments forwarded to `fn` only when `fn` is a function.
|
|
16
|
+
* @returns The resolved `TValue`.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* Plain value — returned unchanged (no call):
|
|
20
|
+
* ```ts
|
|
21
|
+
* const n = callFunction(42); // 42
|
|
22
|
+
* const label = callFunction('Hello'); // 'Hello'
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* Function — called with the given arguments:
|
|
27
|
+
* ```ts
|
|
28
|
+
* const sum = callFunction((a: number, b: number) => a + b, 2, 3); // 5
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* Same API for “static or factory” props:
|
|
33
|
+
* ```ts
|
|
34
|
+
* type Title = MaybeFn<string, [locale: string]>;
|
|
35
|
+
* const title: Title = (loc) => (loc === 'ru' ? 'Привет' : 'Hi');
|
|
36
|
+
* const text = callFunction(title, 'ru'); // 'Привет'
|
|
37
|
+
* const fixed = callFunction('Hi', 'ru'); // 'Hi' — args ignored
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
var callFunction = (fn, ...args) => {
|
|
41
|
+
if (typeof fn === "function") return fn(...args);
|
|
42
|
+
return fn;
|
|
8
43
|
};
|
|
9
|
-
|
|
44
|
+
/**
|
|
45
|
+
* @deprecated use {callFunction}
|
|
46
|
+
*/
|
|
47
|
+
var resolveFnValue = callFunction;
|
|
48
|
+
//#endregion
|
|
10
49
|
exports.callFunction = callFunction;
|
|
11
50
|
exports.resolveFnValue = resolveFnValue;
|
|
12
|
-
|
|
51
|
+
|
|
52
|
+
//# sourceMappingURL=common.cjs.map
|
package/common.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.cjs","sources":["../src/common.ts"],"sourcesContent":["import type { MaybeFn } from 'yummies/types';\n\n/**\n * @deprecated use {MaybeFn} type\n */\nexport type FnValue<TValue, TArgs extends any[] = []> = MaybeFn<TValue, TArgs>;\n\n/**\n *
|
|
1
|
+
{"version":3,"file":"common.cjs","names":[],"sources":["../src/common.ts"],"sourcesContent":["import type { MaybeFn } from 'yummies/types';\n\n/**\n * @deprecated use {MaybeFn} type\n */\nexport type FnValue<TValue, TArgs extends any[] = []> = MaybeFn<TValue, TArgs>;\n\n/**\n * Normalizes a {@link MaybeFn} — a value that may be either a plain `TValue` or a function\n * `(...args: TArgs) => TValue`. If `fn` is callable, it is invoked with `args` and the return\n * value is returned; otherwise `fn` is returned as-is (treated as the resolved value).\n *\n * Typical uses: config fields that accept a static value or a lazy/computed factory, theme\n * tokens, labels, or callbacks where the caller should not branch on `typeof fn` themselves.\n *\n * @template TValue - Result type when `fn` is not a function, or return type when it is.\n * @template TArgs - Tuple of argument types passed through when `fn` is invoked.\n *\n * @param fn - Either a `TValue` or a function producing `TValue` from `args`.\n * @param args - Arguments forwarded to `fn` only when `fn` is a function.\n * @returns The resolved `TValue`.\n *\n * @example\n * Plain value — returned unchanged (no call):\n * ```ts\n * const n = callFunction(42); // 42\n * const label = callFunction('Hello'); // 'Hello'\n * ```\n *\n * @example\n * Function — called with the given arguments:\n * ```ts\n * const sum = callFunction((a: number, b: number) => a + b, 2, 3); // 5\n * ```\n *\n * @example\n * Same API for “static or factory” props:\n * ```ts\n * type Title = MaybeFn<string, [locale: string]>;\n * const title: Title = (loc) => (loc === 'ru' ? 'Привет' : 'Hi');\n * const text = callFunction(title, 'ru'); // 'Привет'\n * const fixed = callFunction('Hi', 'ru'); // 'Hi' — args ignored\n * ```\n */\nexport const callFunction = <TValue, TArgs extends any[] = []>(\n fn: MaybeFn<TValue, TArgs>,\n ...args: TArgs\n) => {\n if (typeof fn === 'function') {\n return (fn as any)(...args) as TValue;\n }\n\n return fn;\n};\n\n/**\n * @deprecated use {callFunction}\n */\nexport const resolveFnValue = callFunction;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,IAAa,gBACX,IACA,GAAG,SACA;AACH,KAAI,OAAO,OAAO,WAChB,QAAQ,GAAW,GAAG,KAAK;AAG7B,QAAO;;;;;AAMT,IAAa,iBAAiB"}
|
package/common.d.ts
CHANGED
|
@@ -5,8 +5,41 @@ import { MaybeFn } from 'yummies/types';
|
|
|
5
5
|
*/
|
|
6
6
|
type FnValue<TValue, TArgs extends any[] = []> = MaybeFn<TValue, TArgs>;
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
8
|
+
* Normalizes a {@link MaybeFn} — a value that may be either a plain `TValue` or a function
|
|
9
|
+
* `(...args: TArgs) => TValue`. If `fn` is callable, it is invoked with `args` and the return
|
|
10
|
+
* value is returned; otherwise `fn` is returned as-is (treated as the resolved value).
|
|
11
|
+
*
|
|
12
|
+
* Typical uses: config fields that accept a static value or a lazy/computed factory, theme
|
|
13
|
+
* tokens, labels, or callbacks where the caller should not branch on `typeof fn` themselves.
|
|
14
|
+
*
|
|
15
|
+
* @template TValue - Result type when `fn` is not a function, or return type when it is.
|
|
16
|
+
* @template TArgs - Tuple of argument types passed through when `fn` is invoked.
|
|
17
|
+
*
|
|
18
|
+
* @param fn - Either a `TValue` or a function producing `TValue` from `args`.
|
|
19
|
+
* @param args - Arguments forwarded to `fn` only when `fn` is a function.
|
|
20
|
+
* @returns The resolved `TValue`.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* Plain value — returned unchanged (no call):
|
|
24
|
+
* ```ts
|
|
25
|
+
* const n = callFunction(42); // 42
|
|
26
|
+
* const label = callFunction('Hello'); // 'Hello'
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* Function — called with the given arguments:
|
|
31
|
+
* ```ts
|
|
32
|
+
* const sum = callFunction((a: number, b: number) => a + b, 2, 3); // 5
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* Same API for “static or factory” props:
|
|
37
|
+
* ```ts
|
|
38
|
+
* type Title = MaybeFn<string, [locale: string]>;
|
|
39
|
+
* const title: Title = (loc) => (loc === 'ru' ? 'Привет' : 'Hi');
|
|
40
|
+
* const text = callFunction(title, 'ru'); // 'Привет'
|
|
41
|
+
* const fixed = callFunction('Hi', 'ru'); // 'Hi' — args ignored
|
|
42
|
+
* ```
|
|
10
43
|
*/
|
|
11
44
|
declare const callFunction: <TValue, TArgs extends any[] = []>(fn: MaybeFn<TValue, TArgs>, ...args: TArgs) => TValue;
|
|
12
45
|
/**
|
package/common.js
CHANGED
|
@@ -1,12 +1,50 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
//#region src/common.ts
|
|
2
|
+
/**
|
|
3
|
+
* Normalizes a {@link MaybeFn} — a value that may be either a plain `TValue` or a function
|
|
4
|
+
* `(...args: TArgs) => TValue`. If `fn` is callable, it is invoked with `args` and the return
|
|
5
|
+
* value is returned; otherwise `fn` is returned as-is (treated as the resolved value).
|
|
6
|
+
*
|
|
7
|
+
* Typical uses: config fields that accept a static value or a lazy/computed factory, theme
|
|
8
|
+
* tokens, labels, or callbacks where the caller should not branch on `typeof fn` themselves.
|
|
9
|
+
*
|
|
10
|
+
* @template TValue - Result type when `fn` is not a function, or return type when it is.
|
|
11
|
+
* @template TArgs - Tuple of argument types passed through when `fn` is invoked.
|
|
12
|
+
*
|
|
13
|
+
* @param fn - Either a `TValue` or a function producing `TValue` from `args`.
|
|
14
|
+
* @param args - Arguments forwarded to `fn` only when `fn` is a function.
|
|
15
|
+
* @returns The resolved `TValue`.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* Plain value — returned unchanged (no call):
|
|
19
|
+
* ```ts
|
|
20
|
+
* const n = callFunction(42); // 42
|
|
21
|
+
* const label = callFunction('Hello'); // 'Hello'
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* Function — called with the given arguments:
|
|
26
|
+
* ```ts
|
|
27
|
+
* const sum = callFunction((a: number, b: number) => a + b, 2, 3); // 5
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* Same API for “static or factory” props:
|
|
32
|
+
* ```ts
|
|
33
|
+
* type Title = MaybeFn<string, [locale: string]>;
|
|
34
|
+
* const title: Title = (loc) => (loc === 'ru' ? 'Привет' : 'Hi');
|
|
35
|
+
* const text = callFunction(title, 'ru'); // 'Привет'
|
|
36
|
+
* const fixed = callFunction('Hi', 'ru'); // 'Hi' — args ignored
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
var callFunction = (fn, ...args) => {
|
|
40
|
+
if (typeof fn === "function") return fn(...args);
|
|
41
|
+
return fn;
|
|
6
42
|
};
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
43
|
+
/**
|
|
44
|
+
* @deprecated use {callFunction}
|
|
45
|
+
*/
|
|
46
|
+
var resolveFnValue = callFunction;
|
|
47
|
+
//#endregion
|
|
48
|
+
export { callFunction, resolveFnValue };
|
|
49
|
+
|
|
50
|
+
//# sourceMappingURL=common.js.map
|
package/common.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.js","sources":["../src/common.ts"],"sourcesContent":["import type { MaybeFn } from 'yummies/types';\n\n/**\n * @deprecated use {MaybeFn} type\n */\nexport type FnValue<TValue, TArgs extends any[] = []> = MaybeFn<TValue, TArgs>;\n\n/**\n *
|
|
1
|
+
{"version":3,"file":"common.js","names":[],"sources":["../src/common.ts"],"sourcesContent":["import type { MaybeFn } from 'yummies/types';\n\n/**\n * @deprecated use {MaybeFn} type\n */\nexport type FnValue<TValue, TArgs extends any[] = []> = MaybeFn<TValue, TArgs>;\n\n/**\n * Normalizes a {@link MaybeFn} — a value that may be either a plain `TValue` or a function\n * `(...args: TArgs) => TValue`. If `fn` is callable, it is invoked with `args` and the return\n * value is returned; otherwise `fn` is returned as-is (treated as the resolved value).\n *\n * Typical uses: config fields that accept a static value or a lazy/computed factory, theme\n * tokens, labels, or callbacks where the caller should not branch on `typeof fn` themselves.\n *\n * @template TValue - Result type when `fn` is not a function, or return type when it is.\n * @template TArgs - Tuple of argument types passed through when `fn` is invoked.\n *\n * @param fn - Either a `TValue` or a function producing `TValue` from `args`.\n * @param args - Arguments forwarded to `fn` only when `fn` is a function.\n * @returns The resolved `TValue`.\n *\n * @example\n * Plain value — returned unchanged (no call):\n * ```ts\n * const n = callFunction(42); // 42\n * const label = callFunction('Hello'); // 'Hello'\n * ```\n *\n * @example\n * Function — called with the given arguments:\n * ```ts\n * const sum = callFunction((a: number, b: number) => a + b, 2, 3); // 5\n * ```\n *\n * @example\n * Same API for “static or factory” props:\n * ```ts\n * type Title = MaybeFn<string, [locale: string]>;\n * const title: Title = (loc) => (loc === 'ru' ? 'Привет' : 'Hi');\n * const text = callFunction(title, 'ru'); // 'Привет'\n * const fixed = callFunction('Hi', 'ru'); // 'Hi' — args ignored\n * ```\n */\nexport const callFunction = <TValue, TArgs extends any[] = []>(\n fn: MaybeFn<TValue, TArgs>,\n ...args: TArgs\n) => {\n if (typeof fn === 'function') {\n return (fn as any)(...args) as TValue;\n }\n\n return fn;\n};\n\n/**\n * @deprecated use {callFunction}\n */\nexport const resolveFnValue = callFunction;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,IAAa,gBACX,IACA,GAAG,SACA;AACH,KAAI,OAAO,OAAO,WAChB,QAAQ,GAAW,GAAG,KAAK;AAG7B,QAAO;;;;;AAMT,IAAa,iBAAiB"}
|