@base-web-kits/base-tools-ts 0.9.99 → 1.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.js CHANGED
@@ -2739,10 +2739,273 @@ function invariant(condition, message) {
2739
2739
  throw message;
2740
2740
  }
2741
2741
 
2742
+ // node_modules/.pnpm/es-toolkit@1.42.0/node_modules/es-toolkit/dist/compat/_internal/isDeepKey.mjs
2743
+ function isDeepKey(key) {
2744
+ switch (typeof key) {
2745
+ case "number":
2746
+ case "symbol": {
2747
+ return false;
2748
+ }
2749
+ case "string": {
2750
+ return key.includes(".") || key.includes("[") || key.includes("]");
2751
+ }
2752
+ }
2753
+ }
2754
+
2755
+ // node_modules/.pnpm/es-toolkit@1.42.0/node_modules/es-toolkit/dist/compat/_internal/toKey.mjs
2756
+ function toKey(value) {
2757
+ if (typeof value === "string" || typeof value === "symbol") {
2758
+ return value;
2759
+ }
2760
+ if (Object.is(value?.valueOf?.(), -0)) {
2761
+ return "-0";
2762
+ }
2763
+ return String(value);
2764
+ }
2765
+
2766
+ // node_modules/.pnpm/es-toolkit@1.42.0/node_modules/es-toolkit/dist/compat/util/toString.mjs
2767
+ function toString(value) {
2768
+ if (value == null) {
2769
+ return "";
2770
+ }
2771
+ if (typeof value === "string") {
2772
+ return value;
2773
+ }
2774
+ if (Array.isArray(value)) {
2775
+ return value.map(toString).join(",");
2776
+ }
2777
+ const result = String(value);
2778
+ if (result === "0" && Object.is(Number(value), -0)) {
2779
+ return "-0";
2780
+ }
2781
+ return result;
2782
+ }
2783
+
2784
+ // node_modules/.pnpm/es-toolkit@1.42.0/node_modules/es-toolkit/dist/compat/util/toPath.mjs
2785
+ function toPath(deepKey) {
2786
+ if (Array.isArray(deepKey)) {
2787
+ return deepKey.map(toKey);
2788
+ }
2789
+ if (typeof deepKey === "symbol") {
2790
+ return [deepKey];
2791
+ }
2792
+ deepKey = toString(deepKey);
2793
+ const result = [];
2794
+ const length = deepKey.length;
2795
+ if (length === 0) {
2796
+ return result;
2797
+ }
2798
+ let index = 0;
2799
+ let key = "";
2800
+ let quoteChar = "";
2801
+ let bracket = false;
2802
+ if (deepKey.charCodeAt(0) === 46) {
2803
+ result.push("");
2804
+ index++;
2805
+ }
2806
+ while (index < length) {
2807
+ const char = deepKey[index];
2808
+ if (quoteChar) {
2809
+ if (char === "\\" && index + 1 < length) {
2810
+ index++;
2811
+ key += deepKey[index];
2812
+ } else if (char === quoteChar) {
2813
+ quoteChar = "";
2814
+ } else {
2815
+ key += char;
2816
+ }
2817
+ } else if (bracket) {
2818
+ if (char === '"' || char === "'") {
2819
+ quoteChar = char;
2820
+ } else if (char === "]") {
2821
+ bracket = false;
2822
+ result.push(key);
2823
+ key = "";
2824
+ } else {
2825
+ key += char;
2826
+ }
2827
+ } else {
2828
+ if (char === "[") {
2829
+ bracket = true;
2830
+ if (key) {
2831
+ result.push(key);
2832
+ key = "";
2833
+ }
2834
+ } else if (char === ".") {
2835
+ if (key) {
2836
+ result.push(key);
2837
+ key = "";
2838
+ }
2839
+ } else {
2840
+ key += char;
2841
+ }
2842
+ }
2843
+ index++;
2844
+ }
2845
+ if (key) {
2846
+ result.push(key);
2847
+ }
2848
+ return result;
2849
+ }
2850
+
2851
+ // node_modules/.pnpm/es-toolkit@1.42.0/node_modules/es-toolkit/dist/compat/object/get.mjs
2852
+ function get(object, path, defaultValue) {
2853
+ if (object == null) {
2854
+ return defaultValue;
2855
+ }
2856
+ switch (typeof path) {
2857
+ case "string": {
2858
+ if (isUnsafeProperty(path)) {
2859
+ return defaultValue;
2860
+ }
2861
+ const result = object[path];
2862
+ if (result === void 0) {
2863
+ if (isDeepKey(path)) {
2864
+ return get(object, toPath(path), defaultValue);
2865
+ } else {
2866
+ return defaultValue;
2867
+ }
2868
+ }
2869
+ return result;
2870
+ }
2871
+ case "number":
2872
+ case "symbol": {
2873
+ if (typeof path === "number") {
2874
+ path = toKey(path);
2875
+ }
2876
+ const result = object[path];
2877
+ if (result === void 0) {
2878
+ return defaultValue;
2879
+ }
2880
+ return result;
2881
+ }
2882
+ default: {
2883
+ if (Array.isArray(path)) {
2884
+ return getWithPath(object, path, defaultValue);
2885
+ }
2886
+ if (Object.is(path?.valueOf(), -0)) {
2887
+ path = "-0";
2888
+ } else {
2889
+ path = String(path);
2890
+ }
2891
+ if (isUnsafeProperty(path)) {
2892
+ return defaultValue;
2893
+ }
2894
+ const result = object[path];
2895
+ if (result === void 0) {
2896
+ return defaultValue;
2897
+ }
2898
+ return result;
2899
+ }
2900
+ }
2901
+ }
2902
+ function getWithPath(object, path, defaultValue) {
2903
+ if (path.length === 0) {
2904
+ return defaultValue;
2905
+ }
2906
+ let current = object;
2907
+ for (let index = 0; index < path.length; index++) {
2908
+ if (current == null) {
2909
+ return defaultValue;
2910
+ }
2911
+ if (isUnsafeProperty(path[index])) {
2912
+ return defaultValue;
2913
+ }
2914
+ current = current[path[index]];
2915
+ }
2916
+ if (current === void 0) {
2917
+ return defaultValue;
2918
+ }
2919
+ return current;
2920
+ }
2921
+
2922
+ // node_modules/.pnpm/es-toolkit@1.42.0/node_modules/es-toolkit/dist/compat/predicate/isObject.mjs
2923
+ function isObject(value) {
2924
+ return value !== null && (typeof value === "object" || typeof value === "function");
2925
+ }
2926
+
2927
+ // node_modules/.pnpm/es-toolkit@1.42.0/node_modules/es-toolkit/dist/compat/_internal/isIndex.mjs
2928
+ var IS_UNSIGNED_INTEGER = /^(?:0|[1-9]\d*)$/;
2929
+ function isIndex(value, length = Number.MAX_SAFE_INTEGER) {
2930
+ switch (typeof value) {
2931
+ case "number": {
2932
+ return Number.isInteger(value) && value >= 0 && value < length;
2933
+ }
2934
+ case "symbol": {
2935
+ return false;
2936
+ }
2937
+ case "string": {
2938
+ return IS_UNSIGNED_INTEGER.test(value);
2939
+ }
2940
+ }
2941
+ }
2942
+
2943
+ // node_modules/.pnpm/es-toolkit@1.42.0/node_modules/es-toolkit/dist/compat/_internal/isKey.mjs
2944
+ var regexIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/;
2945
+ var regexIsPlainProp = /^\w*$/;
2946
+ function isKey(value, object) {
2947
+ if (Array.isArray(value)) {
2948
+ return false;
2949
+ }
2950
+ if (typeof value === "number" || typeof value === "boolean" || value == null || isSymbol(value)) {
2951
+ return true;
2952
+ }
2953
+ return typeof value === "string" && (regexIsPlainProp.test(value) || !regexIsDeepProp.test(value)) || object != null && Object.hasOwn(object, value);
2954
+ }
2955
+
2956
+ // node_modules/.pnpm/es-toolkit@1.42.0/node_modules/es-toolkit/dist/compat/_internal/assignValue.mjs
2957
+ var assignValue = (object, key, value) => {
2958
+ const objValue = object[key];
2959
+ if (!(Object.hasOwn(object, key) && eq(objValue, value)) || value === void 0 && !(key in object)) {
2960
+ object[key] = value;
2961
+ }
2962
+ };
2963
+
2964
+ // node_modules/.pnpm/es-toolkit@1.42.0/node_modules/es-toolkit/dist/compat/object/updateWith.mjs
2965
+ function updateWith(obj, path, updater, customizer) {
2966
+ if (obj == null && !isObject(obj)) {
2967
+ return obj;
2968
+ }
2969
+ let resolvedPath;
2970
+ if (isKey(path, obj)) {
2971
+ resolvedPath = [path];
2972
+ } else if (Array.isArray(path)) {
2973
+ resolvedPath = path;
2974
+ } else {
2975
+ resolvedPath = toPath(path);
2976
+ }
2977
+ const updateValue = updater(get(obj, resolvedPath));
2978
+ let current = obj;
2979
+ for (let i = 0; i < resolvedPath.length && current != null; i++) {
2980
+ const key = toKey(resolvedPath[i]);
2981
+ if (isUnsafeProperty(key)) {
2982
+ continue;
2983
+ }
2984
+ let newValue;
2985
+ if (i === resolvedPath.length - 1) {
2986
+ newValue = updateValue;
2987
+ } else {
2988
+ const objValue = current[key];
2989
+ const customizerResult = customizer?.(objValue, key, obj);
2990
+ newValue = customizerResult !== void 0 ? customizerResult : isObject(objValue) ? objValue : isIndex(resolvedPath[i + 1]) ? [] : {};
2991
+ }
2992
+ assignValue(current, key, newValue);
2993
+ current = current[key];
2994
+ }
2995
+ return obj;
2996
+ }
2997
+
2998
+ // node_modules/.pnpm/es-toolkit@1.42.0/node_modules/es-toolkit/dist/compat/object/set.mjs
2999
+ function set(obj, path, value) {
3000
+ return updateWith(obj, path, () => value, () => void 0);
3001
+ }
3002
+
2742
3003
  // src/ts/object/index.ts
2743
3004
  function getObjectKeys(obj) {
2744
3005
  return Object.keys(obj);
2745
3006
  }
3007
+ var getObjectValue = get;
3008
+ var setObjectValue = set;
2746
3009
 
2747
3010
  // src/ts/string/format.ts
2748
3011
  function toMaskText(s, keepLeft = 1, keepRight = 0, maskChar = "*") {
@@ -3371,6 +3634,7 @@ export {
3371
3634
  getOSSImg,
3372
3635
  getOSSVideo,
3373
3636
  getObjectKeys,
3637
+ getObjectValue,
3374
3638
  getQnAudio,
3375
3639
  getQnHls,
3376
3640
  getQnImg,
@@ -3505,6 +3769,7 @@ export {
3505
3769
  round,
3506
3770
  sample,
3507
3771
  sampleSize,
3772
+ setObjectValue,
3508
3773
  shuffle,
3509
3774
  snakeCase,
3510
3775
  sortBy,