@fangzhongya/utils 0.0.60 → 0.0.61

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 (61) hide show
  1. package/dist/basic/index.cjs +22 -21
  2. package/dist/basic/index.d.cts +2 -1
  3. package/dist/basic/index.d.ts +2 -1
  4. package/dist/basic/index.js +21 -20
  5. package/dist/basic/object/index.cjs +9 -9
  6. package/dist/basic/object/index.js +10 -10
  7. package/dist/basic/string/index.cjs +22 -14
  8. package/dist/basic/string/index.d.cts +2 -1
  9. package/dist/basic/string/index.d.ts +2 -1
  10. package/dist/basic/string/index.js +26 -18
  11. package/dist/basic/string/toFunction.cjs +4 -2
  12. package/dist/basic/string/toFunction.d.cts +10 -3
  13. package/dist/basic/string/toFunction.d.ts +10 -3
  14. package/dist/basic/string/toFunction.js +3 -1
  15. package/dist/basic/string/toFunctionParam.cjs +10 -0
  16. package/dist/basic/string/toFunctionParam.d.cts +17 -0
  17. package/dist/basic/string/toFunctionParam.d.ts +17 -0
  18. package/dist/basic/string/toFunctionParam.js +10 -0
  19. package/dist/basic/string/toJson.cjs +3 -3
  20. package/dist/basic/string/toJson.js +2 -2
  21. package/dist/basic/string/toJsons.cjs +3 -3
  22. package/dist/basic/string/toJsons.js +2 -2
  23. package/dist/basic/string/toStringParse.cjs +3 -3
  24. package/dist/basic/string/toStringParse.js +2 -2
  25. package/dist/{chunk-MGK5PCGH.js → chunk-5SCROVEG.js} +1 -1
  26. package/dist/{chunk-Y6UWNHC6.js → chunk-66EQ5D5L.js} +4 -4
  27. package/dist/chunk-6LN4VV4U.cjs +132 -0
  28. package/dist/{chunk-U3PZBQ6G.js → chunk-AMVTUA4M.js} +1 -1
  29. package/dist/{chunk-XG44HG5N.cjs → chunk-AYJPZCJF.cjs} +2 -2
  30. package/dist/chunk-DWDFQC7A.js +132 -0
  31. package/dist/{chunk-JHV27P2Q.cjs → chunk-FQJK53WC.cjs} +2 -2
  32. package/dist/{chunk-SXTTMHYU.js → chunk-IWUJSVXJ.js} +3 -3
  33. package/dist/{chunk-HXG4I4YA.cjs → chunk-M7ZKHA6C.cjs} +4 -4
  34. package/dist/{chunk-3FQKILLZ.cjs → chunk-O5RJK4XR.cjs} +3 -3
  35. package/dist/{chunk-LMKPAAY6.cjs → chunk-OGYRG5XZ.cjs} +28 -20
  36. package/dist/{chunk-7O4MJOHM.js → chunk-OQMYUG4U.js} +35 -34
  37. package/dist/{chunk-BT2SXUJY.js → chunk-QCGLFO5B.js} +24 -16
  38. package/dist/{chunk-QXK4IUBI.cjs → chunk-TZSUAKSW.cjs} +35 -34
  39. package/dist/{index-DLnJJBhb.d.cts → index-BMhmeVcw.d.cts} +1 -1
  40. package/dist/{index-CxW0zCsG.d.cts → index-BmGaGt2M.d.cts} +7 -2
  41. package/dist/{index-CnVIRWwZ.d.ts → index-CGsG3tMc.d.ts} +1 -1
  42. package/dist/{index-zLctRwm9.d.ts → index-CRh3wZkY.d.ts} +7 -2
  43. package/dist/index.cjs +40 -39
  44. package/dist/index.d.cts +3 -2
  45. package/dist/index.d.ts +3 -2
  46. package/dist/index.js +39 -38
  47. package/dist/tree/index.cjs +3 -3
  48. package/dist/tree/index.js +6 -6
  49. package/dist/urls/index.cjs +4 -4
  50. package/dist/urls/index.js +4 -4
  51. package/dist/window/index.cjs +4 -4
  52. package/dist/window/index.js +7 -7
  53. package/package.json +6 -1
  54. package/dist/{chunk-HQ6ASUBP.js → chunk-3DUFQKFF.js} +3 -3
  55. package/dist/{chunk-E74ZD4NG.cjs → chunk-72GMBSE6.cjs} +3 -3
  56. package/dist/{chunk-XARZ3OMM.cjs → chunk-7GCUYESU.cjs} +3 -3
  57. package/dist/{chunk-PFTTRHAB.js → chunk-7M7ORCKS.js} +9 -9
  58. package/dist/{chunk-PV2N6PF2.cjs → chunk-APRM3ELY.cjs} +2 -2
  59. package/dist/{chunk-FJ5PJYIY.cjs → chunk-KZCLX66D.cjs} +8 -8
  60. package/dist/{chunk-5WQXANBO.js → chunk-MZLWYQQH.js} +6 -6
  61. package/dist/{chunk-OVHYLUAS.js → chunk-QUIZWAFR.js} +5 -5
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  toStringParse
3
- } from "../../chunk-MGK5PCGH.js";
4
- import "../../chunk-7O4MJOHM.js";
3
+ } from "../../chunk-5SCROVEG.js";
4
+ import "../../chunk-OQMYUG4U.js";
5
5
  import "../../chunk-MLKGABMK.js";
6
6
  export {
7
7
  toStringParse
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  toFunction
3
- } from "./chunk-7O4MJOHM.js";
3
+ } from "./chunk-OQMYUG4U.js";
4
4
 
5
5
  // packages/basic/string/toStringParse.ts
6
6
  var arrayBufferUtils = {
@@ -1,9 +1,9 @@
1
- import {
2
- object_exports
3
- } from "./chunk-PFTTRHAB.js";
4
1
  import {
5
2
  string_exports
6
- } from "./chunk-BT2SXUJY.js";
3
+ } from "./chunk-QCGLFO5B.js";
4
+ import {
5
+ object_exports
6
+ } from "./chunk-7M7ORCKS.js";
7
7
  import {
8
8
  array_exports
9
9
  } from "./chunk-PVXQ2H5H.js";
@@ -0,0 +1,132 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
+
3
+
4
+ var _chunkTZSUAKSWcjs = require('./chunk-TZSUAKSW.cjs');
5
+
6
+ // packages/basic/string/toFunctionParam.ts
7
+ function buildFunctionString(obj) {
8
+ const { isAsync, isGenerator, param, body } = obj;
9
+ const funcName = obj.name || "";
10
+ const funcSignature = `${isAsync ? "async " : ""}${isGenerator ? "*" : ""}function${funcName ? ` ${funcName}` : ""}`;
11
+ return `${funcSignature}(${param}) { ${body} }`;
12
+ }
13
+ function createSimpleFunction(obj) {
14
+ return new Function(`return ${buildFunctionString(obj)}`)();
15
+ }
16
+ function createFunctionWithClosure(obj, externalParams) {
17
+ const externalKeys = Object.keys(externalParams);
18
+ if (externalKeys.length === 0) {
19
+ return createSimpleFunction(obj);
20
+ }
21
+ try {
22
+ const factory = new Function(
23
+ ...externalKeys,
24
+ `return ${buildFunctionString(obj)};`
25
+ );
26
+ return factory(...externalKeys.map((k) => externalParams[k]));
27
+ } catch (error) {
28
+ const { param, body } = obj;
29
+ const funcParams = param ? _chunkTZSUAKSWcjs.extractParams.call(void 0, param) : [];
30
+ const allParams = [...funcParams, ...externalKeys];
31
+ const closure = new Function(...allParams, body);
32
+ return function(...args) {
33
+ return closure(
34
+ ...args,
35
+ ...externalKeys.map((k) => externalParams[k])
36
+ );
37
+ };
38
+ }
39
+ }
40
+ function createFunctionWithoutClosure(obj, externalParams) {
41
+ const funcParams = obj.param ? _chunkTZSUAKSWcjs.extractParams.call(void 0, obj.param) : [];
42
+ const externalKeys = Object.keys(externalParams);
43
+ const baseFunc = createSimpleFunction(obj);
44
+ return function(...args) {
45
+ const context = {};
46
+ externalKeys.forEach((k) => {
47
+ context[k] = externalParams[k];
48
+ });
49
+ funcParams.forEach((paramName, index) => {
50
+ const cleanParam = paramName.split("=")[0].trim();
51
+ context[cleanParam] = args[index];
52
+ });
53
+ return baseFunc.call(context, ...args);
54
+ };
55
+ }
56
+ function toFunctionParam(str, key, externalParams) {
57
+ try {
58
+ const obj = _chunkTZSUAKSWcjs.getFunctionFormat.call(void 0, str);
59
+ if (!_optionalChain([obj, 'optionalAccess', _ => _.body])) return void 0;
60
+ if (key && !obj.name) {
61
+ obj.name = key;
62
+ }
63
+ if (obj.param) {
64
+ const paramCount = _chunkTZSUAKSWcjs.extractParams.call(void 0, obj.param).length;
65
+ if (paramCount > 1e3) {
66
+ console.warn("Too many parameters, limiting to 1000");
67
+ return void 0;
68
+ }
69
+ }
70
+ if (externalParams && Object.keys(externalParams).length > 0) {
71
+ return createFunctionWithClosure(obj, externalParams);
72
+ } else {
73
+ return createSimpleFunction(obj);
74
+ }
75
+ } catch (error) {
76
+ console.error("Function creation failed:", error);
77
+ return void 0;
78
+ }
79
+ }
80
+ function toFunctionParamOptions(str, key, externalParams, options) {
81
+ try {
82
+ const obj = _chunkTZSUAKSWcjs.getFunctionFormat.call(void 0, str);
83
+ if (!_optionalChain([obj, 'optionalAccess', _2 => _2.body])) return void 0;
84
+ const opts = {
85
+ useClosure: true,
86
+ // 默认使用闭包方式(性能更好)
87
+ strictMode: true,
88
+ context: {},
89
+ paramDefaults: {},
90
+ bindThis: false,
91
+ ...options
92
+ };
93
+ let functionBody = obj.body;
94
+ if (opts.paramDefaults && Object.keys(opts.paramDefaults).length > 0) {
95
+ const defaultsCode = Object.entries(opts.paramDefaults).map(
96
+ ([name, value]) => `if (${name} === undefined) ${name} = ${JSON.stringify(
97
+ value
98
+ )};`
99
+ ).join(" ");
100
+ functionBody = defaultsCode + " " + functionBody;
101
+ }
102
+ if (opts.strictMode) {
103
+ functionBody = `'use strict'; ${functionBody}`;
104
+ }
105
+ const funcObj = { ...obj, body: functionBody };
106
+ if (key && !funcObj.name) {
107
+ funcObj.name = key;
108
+ }
109
+ let result;
110
+ if (externalParams && Object.keys(externalParams).length > 0) {
111
+ if (opts.useClosure) {
112
+ result = createFunctionWithClosure(funcObj, externalParams);
113
+ } else {
114
+ result = createFunctionWithoutClosure(funcObj, externalParams);
115
+ }
116
+ } else {
117
+ result = createSimpleFunction(funcObj);
118
+ }
119
+ if (opts.bindThis && opts.context && Object.keys(opts.context).length > 0) {
120
+ return result.bind(opts.context);
121
+ }
122
+ return result;
123
+ } catch (error) {
124
+ console.error("Enhanced function creation failed:", error);
125
+ return void 0;
126
+ }
127
+ }
128
+
129
+
130
+
131
+
132
+ exports.toFunctionParam = toFunctionParam; exports.toFunctionParamOptions = toFunctionParamOptions;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  toFunction
3
- } from "./chunk-7O4MJOHM.js";
3
+ } from "./chunk-OQMYUG4U.js";
4
4
 
5
5
  // packages/basic/string/toJson.ts
6
6
  function toJSONStringify(obj, space) {
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkQXK4IUBIcjs = require('./chunk-QXK4IUBI.cjs');
3
+ var _chunkTZSUAKSWcjs = require('./chunk-TZSUAKSW.cjs');
4
4
 
5
5
  // packages/basic/string/toStringParse.ts
6
6
  var arrayBufferUtils = {
@@ -71,7 +71,7 @@ function toStringParse(str, type, split = ",") {
71
71
  case "boolean":
72
72
  return Boolean(str);
73
73
  case "function":
74
- return _chunkQXK4IUBIcjs.toFunction.call(void 0, str) || function() {
74
+ return _chunkTZSUAKSWcjs.toFunction.call(void 0, str) || function() {
75
75
  };
76
76
  case "undefined":
77
77
  return void 0;
@@ -0,0 +1,132 @@
1
+ import {
2
+ extractParams,
3
+ getFunctionFormat
4
+ } from "./chunk-OQMYUG4U.js";
5
+
6
+ // packages/basic/string/toFunctionParam.ts
7
+ function buildFunctionString(obj) {
8
+ const { isAsync, isGenerator, param, body } = obj;
9
+ const funcName = obj.name || "";
10
+ const funcSignature = `${isAsync ? "async " : ""}${isGenerator ? "*" : ""}function${funcName ? ` ${funcName}` : ""}`;
11
+ return `${funcSignature}(${param}) { ${body} }`;
12
+ }
13
+ function createSimpleFunction(obj) {
14
+ return new Function(`return ${buildFunctionString(obj)}`)();
15
+ }
16
+ function createFunctionWithClosure(obj, externalParams) {
17
+ const externalKeys = Object.keys(externalParams);
18
+ if (externalKeys.length === 0) {
19
+ return createSimpleFunction(obj);
20
+ }
21
+ try {
22
+ const factory = new Function(
23
+ ...externalKeys,
24
+ `return ${buildFunctionString(obj)};`
25
+ );
26
+ return factory(...externalKeys.map((k) => externalParams[k]));
27
+ } catch (error) {
28
+ const { param, body } = obj;
29
+ const funcParams = param ? extractParams(param) : [];
30
+ const allParams = [...funcParams, ...externalKeys];
31
+ const closure = new Function(...allParams, body);
32
+ return function(...args) {
33
+ return closure(
34
+ ...args,
35
+ ...externalKeys.map((k) => externalParams[k])
36
+ );
37
+ };
38
+ }
39
+ }
40
+ function createFunctionWithoutClosure(obj, externalParams) {
41
+ const funcParams = obj.param ? extractParams(obj.param) : [];
42
+ const externalKeys = Object.keys(externalParams);
43
+ const baseFunc = createSimpleFunction(obj);
44
+ return function(...args) {
45
+ const context = {};
46
+ externalKeys.forEach((k) => {
47
+ context[k] = externalParams[k];
48
+ });
49
+ funcParams.forEach((paramName, index) => {
50
+ const cleanParam = paramName.split("=")[0].trim();
51
+ context[cleanParam] = args[index];
52
+ });
53
+ return baseFunc.call(context, ...args);
54
+ };
55
+ }
56
+ function toFunctionParam(str, key, externalParams) {
57
+ try {
58
+ const obj = getFunctionFormat(str);
59
+ if (!obj?.body) return void 0;
60
+ if (key && !obj.name) {
61
+ obj.name = key;
62
+ }
63
+ if (obj.param) {
64
+ const paramCount = extractParams(obj.param).length;
65
+ if (paramCount > 1e3) {
66
+ console.warn("Too many parameters, limiting to 1000");
67
+ return void 0;
68
+ }
69
+ }
70
+ if (externalParams && Object.keys(externalParams).length > 0) {
71
+ return createFunctionWithClosure(obj, externalParams);
72
+ } else {
73
+ return createSimpleFunction(obj);
74
+ }
75
+ } catch (error) {
76
+ console.error("Function creation failed:", error);
77
+ return void 0;
78
+ }
79
+ }
80
+ function toFunctionParamOptions(str, key, externalParams, options) {
81
+ try {
82
+ const obj = getFunctionFormat(str);
83
+ if (!obj?.body) return void 0;
84
+ const opts = {
85
+ useClosure: true,
86
+ // 默认使用闭包方式(性能更好)
87
+ strictMode: true,
88
+ context: {},
89
+ paramDefaults: {},
90
+ bindThis: false,
91
+ ...options
92
+ };
93
+ let functionBody = obj.body;
94
+ if (opts.paramDefaults && Object.keys(opts.paramDefaults).length > 0) {
95
+ const defaultsCode = Object.entries(opts.paramDefaults).map(
96
+ ([name, value]) => `if (${name} === undefined) ${name} = ${JSON.stringify(
97
+ value
98
+ )};`
99
+ ).join(" ");
100
+ functionBody = defaultsCode + " " + functionBody;
101
+ }
102
+ if (opts.strictMode) {
103
+ functionBody = `'use strict'; ${functionBody}`;
104
+ }
105
+ const funcObj = { ...obj, body: functionBody };
106
+ if (key && !funcObj.name) {
107
+ funcObj.name = key;
108
+ }
109
+ let result;
110
+ if (externalParams && Object.keys(externalParams).length > 0) {
111
+ if (opts.useClosure) {
112
+ result = createFunctionWithClosure(funcObj, externalParams);
113
+ } else {
114
+ result = createFunctionWithoutClosure(funcObj, externalParams);
115
+ }
116
+ } else {
117
+ result = createSimpleFunction(funcObj);
118
+ }
119
+ if (opts.bindThis && opts.context && Object.keys(opts.context).length > 0) {
120
+ return result.bind(opts.context);
121
+ }
122
+ return result;
123
+ } catch (error) {
124
+ console.error("Enhanced function creation failed:", error);
125
+ return void 0;
126
+ }
127
+ }
128
+
129
+ export {
130
+ toFunctionParam,
131
+ toFunctionParamOptions
132
+ };
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkQXK4IUBIcjs = require('./chunk-QXK4IUBI.cjs');
3
+ var _chunkTZSUAKSWcjs = require('./chunk-TZSUAKSW.cjs');
4
4
 
5
5
  // packages/basic/string/toJson.ts
6
6
  function toJSONStringify(obj, space) {
@@ -33,7 +33,7 @@ function toJSONParse(str, reviver) {
33
33
  case "symbol":
34
34
  return Symbol(value.value);
35
35
  case "function":
36
- return _chunkQXK4IUBIcjs.toFunction.call(void 0, value.value) || value;
36
+ return _chunkTZSUAKSWcjs.toFunction.call(void 0, value.value) || value;
37
37
  case "undefined":
38
38
  return void 0;
39
39
  case "Date":
@@ -1,9 +1,9 @@
1
+ import {
2
+ toFunction
3
+ } from "./chunk-OQMYUG4U.js";
1
4
  import {
2
5
  getObjValue
3
6
  } from "./chunk-SHNH5OEU.js";
4
- import {
5
- toFunction
6
- } from "./chunk-7O4MJOHM.js";
7
7
 
8
8
  // packages/basic/string/toJsons.ts
9
9
  var TYPE_MARKERS = {
@@ -1,9 +1,9 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkFJ5PJYIYcjs = require('./chunk-FJ5PJYIY.cjs');
3
+ var _chunkOGYRG5XZcjs = require('./chunk-OGYRG5XZ.cjs');
4
4
 
5
5
 
6
- var _chunkLMKPAAY6cjs = require('./chunk-LMKPAAY6.cjs');
6
+ var _chunkKZCLX66Dcjs = require('./chunk-KZCLX66D.cjs');
7
7
 
8
8
 
9
9
  var _chunk65O7KWP4cjs = require('./chunk-65O7KWP4.cjs');
@@ -15,8 +15,8 @@ var _chunk75ZPJI57cjs = require('./chunk-75ZPJI57.cjs');
15
15
  var basic_exports = {};
16
16
  _chunk75ZPJI57cjs.__export.call(void 0, basic_exports, {
17
17
  array: () => _chunk65O7KWP4cjs.array_exports,
18
- object: () => _chunkFJ5PJYIYcjs.object_exports,
19
- string: () => _chunkLMKPAAY6cjs.string_exports
18
+ object: () => _chunkKZCLX66Dcjs.object_exports,
19
+ string: () => _chunkOGYRG5XZcjs.string_exports
20
20
  });
21
21
 
22
22
 
@@ -1,9 +1,9 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
2
2
 
3
- var _chunkA5UJF6LPcjs = require('./chunk-A5UJF6LP.cjs');
3
+ var _chunkTZSUAKSWcjs = require('./chunk-TZSUAKSW.cjs');
4
4
 
5
5
 
6
- var _chunkQXK4IUBIcjs = require('./chunk-QXK4IUBI.cjs');
6
+ var _chunkA5UJF6LPcjs = require('./chunk-A5UJF6LP.cjs');
7
7
 
8
8
  // packages/basic/string/toJsons.ts
9
9
  var TYPE_MARKERS = {
@@ -260,7 +260,7 @@ function toJSONSParse(str, context) {
260
260
  case TYPE_MARKERS.SYMBOL:
261
261
  return markerValue.k ? Symbol.for(markerValue.k) : Symbol(markerValue.d);
262
262
  case TYPE_MARKERS.FUNCTION:
263
- return _chunkQXK4IUBIcjs.toFunction.call(void 0, markerValue, key) || function() {
263
+ return _chunkTZSUAKSWcjs.toFunction.call(void 0, markerValue, key) || function() {
264
264
  };
265
265
  case TYPE_MARKERS.NAN:
266
266
  return NaN;
@@ -1,24 +1,20 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
3
 
4
- var _chunkJHV27P2Qcjs = require('./chunk-JHV27P2Q.cjs');
4
+ var _chunk6LN4VV4Ucjs = require('./chunk-6LN4VV4U.cjs');
5
5
 
6
6
 
7
7
 
8
+ var _chunkFQJK53WCcjs = require('./chunk-FQJK53WC.cjs');
8
9
 
9
10
 
10
- var _chunk3FQKILLZcjs = require('./chunk-3FQKILLZ.cjs');
11
11
 
12
12
 
13
- var _chunkXG44HG5Ncjs = require('./chunk-XG44HG5N.cjs');
14
13
 
14
+ var _chunkO5RJK4XRcjs = require('./chunk-O5RJK4XR.cjs');
15
15
 
16
16
 
17
- var _chunkQXK4IUBIcjs = require('./chunk-QXK4IUBI.cjs');
18
-
19
-
20
-
21
- var _chunk4PUYFFPOcjs = require('./chunk-4PUYFFPO.cjs');
17
+ var _chunkAYJPZCJFcjs = require('./chunk-AYJPZCJF.cjs');
22
18
 
23
19
 
24
20
 
@@ -31,13 +27,16 @@ var _chunkJ7S3KBHLcjs = require('./chunk-J7S3KBHL.cjs');
31
27
  var _chunkL7FSHU27cjs = require('./chunk-L7FSHU27.cjs');
32
28
 
33
29
 
34
- var _chunkXWCRGY54cjs = require('./chunk-XWCRGY54.cjs');
35
30
 
36
31
 
37
- var _chunkUEVMS6QDcjs = require('./chunk-UEVMS6QD.cjs');
32
+ var _chunkTZSUAKSWcjs = require('./chunk-TZSUAKSW.cjs');
38
33
 
39
34
 
40
- var _chunkOQL4GIEJcjs = require('./chunk-OQL4GIEJ.cjs');
35
+ var _chunkXWCRGY54cjs = require('./chunk-XWCRGY54.cjs');
36
+
37
+
38
+
39
+ var _chunk4PUYFFPOcjs = require('./chunk-4PUYFFPO.cjs');
41
40
 
42
41
 
43
42
  var _chunk2H3KVSFAcjs = require('./chunk-2H3KVSFA.cjs');
@@ -55,6 +54,12 @@ var _chunkJR6ZN6QDcjs = require('./chunk-JR6ZN6QD.cjs');
55
54
  var _chunkPW7RP73Jcjs = require('./chunk-PW7RP73J.cjs');
56
55
 
57
56
 
57
+ var _chunkUEVMS6QDcjs = require('./chunk-UEVMS6QD.cjs');
58
+
59
+
60
+ var _chunkOQL4GIEJcjs = require('./chunk-OQL4GIEJ.cjs');
61
+
62
+
58
63
  var _chunk75ZPJI57cjs = require('./chunk-75ZPJI57.cjs');
59
64
 
60
65
  // packages/basic/string/index.ts
@@ -63,26 +68,29 @@ _chunk75ZPJI57cjs.__export.call(void 0, string_exports, {
63
68
  appearNum: () => _chunkOJBZ7UUCcjs.appearNum,
64
69
  appearNumSeat: () => _chunkJR6ZN6QDcjs.appearNumSeat,
65
70
  deComment: () => _chunkXWCRGY54cjs.deComment,
71
+ extractParams: () => _chunkTZSUAKSWcjs.extractParams,
66
72
  firstLower: () => _chunkUEVMS6QDcjs.firstLower,
67
73
  firstUpper: () => _chunkOQL4GIEJcjs.firstUpper,
68
74
  getContent: () => _chunk4PUYFFPOcjs.getContent,
69
75
  getContents: () => _chunk4PUYFFPOcjs.getContents,
70
- getFunctionFormat: () => _chunkQXK4IUBIcjs.getFunctionFormat,
76
+ getFunctionFormat: () => _chunkTZSUAKSWcjs.getFunctionFormat,
71
77
  getImports: () => _chunkHWHYHL6Jcjs.getImports,
72
78
  getImportss: () => _chunkHWHYHL6Jcjs.getImportss,
73
79
  getStartSame: () => _chunkJ7S3KBHLcjs.getStartSame,
74
80
  getStartSames: () => _chunkPW7RP73Jcjs.getStartSames,
75
81
  getStrNunPosit: () => _chunk2H3KVSFAcjs.getStrNunPosit,
76
- serializeCodeBlock: () => _chunk3FQKILLZcjs.serializeCodeBlock,
77
- serializeFunctionRef: () => _chunk3FQKILLZcjs.serializeFunctionRef,
82
+ serializeCodeBlock: () => _chunkO5RJK4XRcjs.serializeCodeBlock,
83
+ serializeFunctionRef: () => _chunkO5RJK4XRcjs.serializeFunctionRef,
78
84
  splitUpper: () => _chunkL7FSHU27cjs.splitUpper,
79
85
  startsNum: () => _chunkILJLXJ5Ocjs.startsNum,
80
- toFunction: () => _chunkQXK4IUBIcjs.toFunction,
81
- toJSONParse: () => _chunkJHV27P2Qcjs.toJSONParse,
82
- toJSONSParse: () => _chunk3FQKILLZcjs.toJSONSParse,
83
- toJSONSStringify: () => _chunk3FQKILLZcjs.toJSONSStringify,
84
- toJSONStringify: () => _chunkJHV27P2Qcjs.toJSONStringify,
85
- toStringParse: () => _chunkXG44HG5Ncjs.toStringParse
86
+ toFunction: () => _chunkTZSUAKSWcjs.toFunction,
87
+ toFunctionParam: () => _chunk6LN4VV4Ucjs.toFunctionParam,
88
+ toFunctionParamOptions: () => _chunk6LN4VV4Ucjs.toFunctionParamOptions,
89
+ toJSONParse: () => _chunkFQJK53WCcjs.toJSONParse,
90
+ toJSONSParse: () => _chunkO5RJK4XRcjs.toJSONSParse,
91
+ toJSONSStringify: () => _chunkO5RJK4XRcjs.toJSONSStringify,
92
+ toJSONStringify: () => _chunkFQJK53WCcjs.toJSONStringify,
93
+ toStringParse: () => _chunkAYJPZCJFcjs.toStringParse
86
94
  });
87
95
 
88
96
 
@@ -37,38 +37,6 @@ function extractParams(paramStr) {
37
37
  if (current.trim()) result.push(current.trim());
38
38
  return result;
39
39
  }
40
- function toFunction(str, key) {
41
- try {
42
- const obj = getFunctionFormat(str);
43
- if (!obj?.body) return void 0;
44
- const params = obj.param ? extractParams(obj.param) : [];
45
- if (params.length > 1e3) {
46
- throw new Error("Too many parameters (max: 1000)");
47
- }
48
- if (obj.isAsync) {
49
- try {
50
- const fullFunction = `async function${obj.isGenerator ? "*" : ""} ${obj.name ?? key ?? ""} (${obj.param}) { ${obj.body} }`;
51
- return new Function(`return ${fullFunction}`)();
52
- } catch (error) {
53
- const fullFunction = `async function${obj.isGenerator ? "*" : ""} (${obj.param}) { ${obj.body} }`;
54
- return new Function(`return ${fullFunction}`)();
55
- }
56
- } else {
57
- try {
58
- const fullFunction = `function${obj.isGenerator ? "*" : ""} ${obj.name ?? key ?? ""}(${obj.param}) { ${obj.body} }`;
59
- return new Function(`return (${fullFunction})`)();
60
- } catch (error) {
61
- return new Function(...params, obj.body);
62
- }
63
- }
64
- } catch (error) {
65
- console.error("Function creation failed:", {
66
- input: str.slice(0, 100),
67
- error
68
- });
69
- return void 0;
70
- }
71
- }
72
40
  var FUNCTION_REGEX = /^\s*(?:(async)\s+)?(?:function\s*(\*?)\s*(\w*)\s*\(([\s\S]*?)\)|(\*?\s*)\b(\w+)\s*\(([\s\S]*?)\)|\(([\s\S]*?)\)|([^=>,\(\)]+?))\s*(?:=>)?\s*(?:\{([\s\S]*?)\}|([\s\S]*))$/;
73
41
  function getFunctionFormat(v) {
74
42
  if (!v) return;
@@ -135,8 +103,41 @@ function getFunctionFormat(v) {
135
103
  body: body.trim()
136
104
  };
137
105
  }
106
+ function toFunction(str, key) {
107
+ try {
108
+ const obj = getFunctionFormat(str);
109
+ if (!obj?.body) return void 0;
110
+ const params = obj.param ? extractParams(obj.param) : [];
111
+ if (params.length > 1e3) {
112
+ throw new Error("Too many parameters (max: 1000)");
113
+ }
114
+ if (obj.isAsync) {
115
+ try {
116
+ const fullFunction = `async function${obj.isGenerator ? "*" : ""} ${obj.name ?? key ?? ""} (${obj.param}) { ${obj.body} }`;
117
+ return new Function(`return ${fullFunction}`)();
118
+ } catch (error) {
119
+ const fullFunction = `async function${obj.isGenerator ? "*" : ""} (${obj.param}) { ${obj.body} }`;
120
+ return new Function(`return ${fullFunction}`)();
121
+ }
122
+ } else {
123
+ try {
124
+ const fullFunction = `function${obj.isGenerator ? "*" : ""} ${obj.name ?? key ?? ""}(${obj.param}) { ${obj.body} }`;
125
+ return new Function(`return (${fullFunction})`)();
126
+ } catch (error) {
127
+ return new Function(...params, obj.body);
128
+ }
129
+ }
130
+ } catch (error) {
131
+ console.error("Function creation failed:", {
132
+ input: str.slice(0, 100),
133
+ error
134
+ });
135
+ return void 0;
136
+ }
137
+ }
138
138
 
139
139
  export {
140
- toFunction,
141
- getFunctionFormat
140
+ extractParams,
141
+ getFunctionFormat,
142
+ toFunction
142
143
  };
@@ -1,24 +1,20 @@
1
+ import {
2
+ toFunctionParam,
3
+ toFunctionParamOptions
4
+ } from "./chunk-DWDFQC7A.js";
1
5
  import {
2
6
  toJSONParse,
3
7
  toJSONStringify
4
- } from "./chunk-U3PZBQ6G.js";
8
+ } from "./chunk-AMVTUA4M.js";
5
9
  import {
6
10
  serializeCodeBlock,
7
11
  serializeFunctionRef,
8
12
  toJSONSParse,
9
13
  toJSONSStringify
10
- } from "./chunk-SXTTMHYU.js";
14
+ } from "./chunk-IWUJSVXJ.js";
11
15
  import {
12
16
  toStringParse
13
- } from "./chunk-MGK5PCGH.js";
14
- import {
15
- getFunctionFormat,
16
- toFunction
17
- } from "./chunk-7O4MJOHM.js";
18
- import {
19
- getContent,
20
- getContents
21
- } from "./chunk-YKSVLAAK.js";
17
+ } from "./chunk-5SCROVEG.js";
22
18
  import {
23
19
  getImports,
24
20
  getImportss
@@ -29,15 +25,18 @@ import {
29
25
  import {
30
26
  splitUpper
31
27
  } from "./chunk-VKE5JARB.js";
28
+ import {
29
+ extractParams,
30
+ getFunctionFormat,
31
+ toFunction
32
+ } from "./chunk-OQMYUG4U.js";
32
33
  import {
33
34
  deComment
34
35
  } from "./chunk-FS4JPT23.js";
35
36
  import {
36
- firstLower
37
- } from "./chunk-4OBNLDTJ.js";
38
- import {
39
- firstUpper
40
- } from "./chunk-EWJJKQIO.js";
37
+ getContent,
38
+ getContents
39
+ } from "./chunk-YKSVLAAK.js";
41
40
  import {
42
41
  getStrNunPosit
43
42
  } from "./chunk-USIMBBLW.js";
@@ -53,6 +52,12 @@ import {
53
52
  import {
54
53
  getStartSames
55
54
  } from "./chunk-A276ZDLP.js";
55
+ import {
56
+ firstLower
57
+ } from "./chunk-4OBNLDTJ.js";
58
+ import {
59
+ firstUpper
60
+ } from "./chunk-EWJJKQIO.js";
56
61
  import {
57
62
  __export
58
63
  } from "./chunk-MLKGABMK.js";
@@ -63,6 +68,7 @@ __export(string_exports, {
63
68
  appearNum: () => appearNum,
64
69
  appearNumSeat: () => appearNumSeat,
65
70
  deComment: () => deComment,
71
+ extractParams: () => extractParams,
66
72
  firstLower: () => firstLower,
67
73
  firstUpper: () => firstUpper,
68
74
  getContent: () => getContent,
@@ -78,6 +84,8 @@ __export(string_exports, {
78
84
  splitUpper: () => splitUpper,
79
85
  startsNum: () => startsNum,
80
86
  toFunction: () => toFunction,
87
+ toFunctionParam: () => toFunctionParam,
88
+ toFunctionParamOptions: () => toFunctionParamOptions,
81
89
  toJSONParse: () => toJSONParse,
82
90
  toJSONSParse: () => toJSONSParse,
83
91
  toJSONSStringify: () => toJSONSStringify,