@weapp-core/shared 1.0.8 → 2.0.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/dist/index.cjs +2 -2
- package/dist/index.js +19 -17
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -33,9 +33,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
33
33
|
));
|
|
34
34
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
35
35
|
|
|
36
|
-
// ../../node_modules/.pnpm/tsup@8.
|
|
36
|
+
// ../../node_modules/.pnpm/tsup@8.5.0_@swc+core@1.12.0_jiti@2.4.2_postcss@8.5.4_tsx@4.20.1_typescript@5.8.3_yaml@2.8.0/node_modules/tsup/assets/cjs_shims.js
|
|
37
37
|
var init_cjs_shims = __esm({
|
|
38
|
-
"../../node_modules/.pnpm/tsup@8.
|
|
38
|
+
"../../node_modules/.pnpm/tsup@8.5.0_@swc+core@1.12.0_jiti@2.4.2_postcss@8.5.4_tsx@4.20.1_typescript@5.8.3_yaml@2.8.0/node_modules/tsup/assets/cjs_shims.js"() {
|
|
39
39
|
"use strict";
|
|
40
40
|
}
|
|
41
41
|
});
|
package/dist/index.js
CHANGED
|
@@ -27,9 +27,11 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
27
|
mod
|
|
28
28
|
));
|
|
29
29
|
|
|
30
|
-
// ../../node_modules/.pnpm/tsup@8.
|
|
30
|
+
// ../../node_modules/.pnpm/tsup@8.5.0_@swc+core@1.12.0_jiti@2.4.2_postcss@8.5.4_tsx@4.20.1_typescript@5.8.3_yaml@2.8.0/node_modules/tsup/assets/esm_shims.js
|
|
31
|
+
import path from "path";
|
|
32
|
+
import { fileURLToPath } from "url";
|
|
31
33
|
var init_esm_shims = __esm({
|
|
32
|
-
"../../node_modules/.pnpm/tsup@8.
|
|
34
|
+
"../../node_modules/.pnpm/tsup@8.5.0_@swc+core@1.12.0_jiti@2.4.2_postcss@8.5.4_tsx@4.20.1_typescript@5.8.3_yaml@2.8.0/node_modules/tsup/assets/esm_shims.js"() {
|
|
33
35
|
"use strict";
|
|
34
36
|
}
|
|
35
37
|
});
|
|
@@ -181,9 +183,9 @@ var require_set_value = __commonJS({
|
|
|
181
183
|
}
|
|
182
184
|
return obj;
|
|
183
185
|
};
|
|
184
|
-
var setValue = (target,
|
|
185
|
-
if (!
|
|
186
|
-
const keys = split2(
|
|
186
|
+
var setValue = (target, path2, value, options) => {
|
|
187
|
+
if (!path2 || !isObject3(target)) return target;
|
|
188
|
+
const keys = split2(path2, options);
|
|
187
189
|
let obj = target;
|
|
188
190
|
for (let i = 0; i < keys.length; i++) {
|
|
189
191
|
const key = keys[i];
|
|
@@ -215,7 +217,7 @@ var require_set_value = __commonJS({
|
|
|
215
217
|
|
|
216
218
|
// src/index.ts
|
|
217
219
|
init_esm_shims();
|
|
218
|
-
import { extname } from "
|
|
220
|
+
import { extname } from "path";
|
|
219
221
|
|
|
220
222
|
// ../../node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.mjs
|
|
221
223
|
init_esm_shims();
|
|
@@ -300,11 +302,11 @@ var join = /* @__PURE__ */ __name((segs, joinChar, options) => {
|
|
|
300
302
|
}
|
|
301
303
|
return segs[0] + joinChar + segs[1];
|
|
302
304
|
}, "join");
|
|
303
|
-
var split = /* @__PURE__ */ __name((
|
|
305
|
+
var split = /* @__PURE__ */ __name((path2, splitChar, options) => {
|
|
304
306
|
if (typeof options.split === "function") {
|
|
305
|
-
return options.split(
|
|
307
|
+
return options.split(path2);
|
|
306
308
|
}
|
|
307
|
-
return
|
|
309
|
+
return path2.split(splitChar);
|
|
308
310
|
}, "split");
|
|
309
311
|
var isValid = /* @__PURE__ */ __name((key, target = {}, options) => {
|
|
310
312
|
if (typeof options?.isValid === "function") {
|
|
@@ -315,27 +317,27 @@ var isValid = /* @__PURE__ */ __name((key, target = {}, options) => {
|
|
|
315
317
|
var isValidObject = /* @__PURE__ */ __name((v) => {
|
|
316
318
|
return isObject(v) || typeof v === "function";
|
|
317
319
|
}, "isValidObject");
|
|
318
|
-
var getValue = /* @__PURE__ */ __name((target,
|
|
320
|
+
var getValue = /* @__PURE__ */ __name((target, path2, options = {}) => {
|
|
319
321
|
if (!isObject(options)) {
|
|
320
322
|
options = { default: options };
|
|
321
323
|
}
|
|
322
324
|
if (!isValidObject(target)) {
|
|
323
325
|
return typeof options.default !== "undefined" ? options.default : target;
|
|
324
326
|
}
|
|
325
|
-
if (typeof
|
|
326
|
-
|
|
327
|
+
if (typeof path2 === "number") {
|
|
328
|
+
path2 = String(path2);
|
|
327
329
|
}
|
|
328
|
-
const pathIsArray = Array.isArray(
|
|
329
|
-
const pathIsString = typeof
|
|
330
|
+
const pathIsArray = Array.isArray(path2);
|
|
331
|
+
const pathIsString = typeof path2 === "string";
|
|
330
332
|
const splitChar = options.separator || ".";
|
|
331
333
|
const joinChar = options.joinChar || (typeof splitChar === "string" ? splitChar : ".");
|
|
332
334
|
if (!pathIsString && !pathIsArray) {
|
|
333
335
|
return target;
|
|
334
336
|
}
|
|
335
|
-
if (target[
|
|
336
|
-
return isValid(
|
|
337
|
+
if (target[path2] !== void 0) {
|
|
338
|
+
return isValid(path2, target, options) ? target[path2] : options.default;
|
|
337
339
|
}
|
|
338
|
-
const segs = pathIsArray ?
|
|
340
|
+
const segs = pathIsArray ? path2 : split(path2, splitChar, options);
|
|
339
341
|
const len = segs.length;
|
|
340
342
|
let idx = 0;
|
|
341
343
|
do {
|