@base-web-kits/base-tools-ts 0.9.99 → 1.0.1-alpha.1

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 CHANGED
@@ -100,6 +100,7 @@ __export(index_exports, {
100
100
  getOSSImg: () => getOSSImg,
101
101
  getOSSVideo: () => getOSSVideo,
102
102
  getObjectKeys: () => getObjectKeys,
103
+ getObjectValue: () => getObjectValue,
103
104
  getQnAudio: () => getQnAudio,
104
105
  getQnHls: () => getQnHls,
105
106
  getQnImg: () => getQnImg,
@@ -234,6 +235,7 @@ __export(index_exports, {
234
235
  round: () => round,
235
236
  sample: () => sample,
236
237
  sampleSize: () => sampleSize,
238
+ setObjectValue: () => setObjectValue,
237
239
  shuffle: () => shuffle,
238
240
  snakeCase: () => snakeCase,
239
241
  sortBy: () => sortBy,
@@ -3033,10 +3035,273 @@ function invariant(condition, message) {
3033
3035
  throw message;
3034
3036
  }
3035
3037
 
3038
+ // node_modules/.pnpm/es-toolkit@1.42.0/node_modules/es-toolkit/dist/compat/_internal/isDeepKey.mjs
3039
+ function isDeepKey(key) {
3040
+ switch (typeof key) {
3041
+ case "number":
3042
+ case "symbol": {
3043
+ return false;
3044
+ }
3045
+ case "string": {
3046
+ return key.includes(".") || key.includes("[") || key.includes("]");
3047
+ }
3048
+ }
3049
+ }
3050
+
3051
+ // node_modules/.pnpm/es-toolkit@1.42.0/node_modules/es-toolkit/dist/compat/_internal/toKey.mjs
3052
+ function toKey(value) {
3053
+ if (typeof value === "string" || typeof value === "symbol") {
3054
+ return value;
3055
+ }
3056
+ if (Object.is(value?.valueOf?.(), -0)) {
3057
+ return "-0";
3058
+ }
3059
+ return String(value);
3060
+ }
3061
+
3062
+ // node_modules/.pnpm/es-toolkit@1.42.0/node_modules/es-toolkit/dist/compat/util/toString.mjs
3063
+ function toString(value) {
3064
+ if (value == null) {
3065
+ return "";
3066
+ }
3067
+ if (typeof value === "string") {
3068
+ return value;
3069
+ }
3070
+ if (Array.isArray(value)) {
3071
+ return value.map(toString).join(",");
3072
+ }
3073
+ const result = String(value);
3074
+ if (result === "0" && Object.is(Number(value), -0)) {
3075
+ return "-0";
3076
+ }
3077
+ return result;
3078
+ }
3079
+
3080
+ // node_modules/.pnpm/es-toolkit@1.42.0/node_modules/es-toolkit/dist/compat/util/toPath.mjs
3081
+ function toPath(deepKey) {
3082
+ if (Array.isArray(deepKey)) {
3083
+ return deepKey.map(toKey);
3084
+ }
3085
+ if (typeof deepKey === "symbol") {
3086
+ return [deepKey];
3087
+ }
3088
+ deepKey = toString(deepKey);
3089
+ const result = [];
3090
+ const length = deepKey.length;
3091
+ if (length === 0) {
3092
+ return result;
3093
+ }
3094
+ let index = 0;
3095
+ let key = "";
3096
+ let quoteChar = "";
3097
+ let bracket = false;
3098
+ if (deepKey.charCodeAt(0) === 46) {
3099
+ result.push("");
3100
+ index++;
3101
+ }
3102
+ while (index < length) {
3103
+ const char = deepKey[index];
3104
+ if (quoteChar) {
3105
+ if (char === "\\" && index + 1 < length) {
3106
+ index++;
3107
+ key += deepKey[index];
3108
+ } else if (char === quoteChar) {
3109
+ quoteChar = "";
3110
+ } else {
3111
+ key += char;
3112
+ }
3113
+ } else if (bracket) {
3114
+ if (char === '"' || char === "'") {
3115
+ quoteChar = char;
3116
+ } else if (char === "]") {
3117
+ bracket = false;
3118
+ result.push(key);
3119
+ key = "";
3120
+ } else {
3121
+ key += char;
3122
+ }
3123
+ } else {
3124
+ if (char === "[") {
3125
+ bracket = true;
3126
+ if (key) {
3127
+ result.push(key);
3128
+ key = "";
3129
+ }
3130
+ } else if (char === ".") {
3131
+ if (key) {
3132
+ result.push(key);
3133
+ key = "";
3134
+ }
3135
+ } else {
3136
+ key += char;
3137
+ }
3138
+ }
3139
+ index++;
3140
+ }
3141
+ if (key) {
3142
+ result.push(key);
3143
+ }
3144
+ return result;
3145
+ }
3146
+
3147
+ // node_modules/.pnpm/es-toolkit@1.42.0/node_modules/es-toolkit/dist/compat/object/get.mjs
3148
+ function get(object, path, defaultValue) {
3149
+ if (object == null) {
3150
+ return defaultValue;
3151
+ }
3152
+ switch (typeof path) {
3153
+ case "string": {
3154
+ if (isUnsafeProperty(path)) {
3155
+ return defaultValue;
3156
+ }
3157
+ const result = object[path];
3158
+ if (result === void 0) {
3159
+ if (isDeepKey(path)) {
3160
+ return get(object, toPath(path), defaultValue);
3161
+ } else {
3162
+ return defaultValue;
3163
+ }
3164
+ }
3165
+ return result;
3166
+ }
3167
+ case "number":
3168
+ case "symbol": {
3169
+ if (typeof path === "number") {
3170
+ path = toKey(path);
3171
+ }
3172
+ const result = object[path];
3173
+ if (result === void 0) {
3174
+ return defaultValue;
3175
+ }
3176
+ return result;
3177
+ }
3178
+ default: {
3179
+ if (Array.isArray(path)) {
3180
+ return getWithPath(object, path, defaultValue);
3181
+ }
3182
+ if (Object.is(path?.valueOf(), -0)) {
3183
+ path = "-0";
3184
+ } else {
3185
+ path = String(path);
3186
+ }
3187
+ if (isUnsafeProperty(path)) {
3188
+ return defaultValue;
3189
+ }
3190
+ const result = object[path];
3191
+ if (result === void 0) {
3192
+ return defaultValue;
3193
+ }
3194
+ return result;
3195
+ }
3196
+ }
3197
+ }
3198
+ function getWithPath(object, path, defaultValue) {
3199
+ if (path.length === 0) {
3200
+ return defaultValue;
3201
+ }
3202
+ let current = object;
3203
+ for (let index = 0; index < path.length; index++) {
3204
+ if (current == null) {
3205
+ return defaultValue;
3206
+ }
3207
+ if (isUnsafeProperty(path[index])) {
3208
+ return defaultValue;
3209
+ }
3210
+ current = current[path[index]];
3211
+ }
3212
+ if (current === void 0) {
3213
+ return defaultValue;
3214
+ }
3215
+ return current;
3216
+ }
3217
+
3218
+ // node_modules/.pnpm/es-toolkit@1.42.0/node_modules/es-toolkit/dist/compat/predicate/isObject.mjs
3219
+ function isObject(value) {
3220
+ return value !== null && (typeof value === "object" || typeof value === "function");
3221
+ }
3222
+
3223
+ // node_modules/.pnpm/es-toolkit@1.42.0/node_modules/es-toolkit/dist/compat/_internal/isIndex.mjs
3224
+ var IS_UNSIGNED_INTEGER = /^(?:0|[1-9]\d*)$/;
3225
+ function isIndex(value, length = Number.MAX_SAFE_INTEGER) {
3226
+ switch (typeof value) {
3227
+ case "number": {
3228
+ return Number.isInteger(value) && value >= 0 && value < length;
3229
+ }
3230
+ case "symbol": {
3231
+ return false;
3232
+ }
3233
+ case "string": {
3234
+ return IS_UNSIGNED_INTEGER.test(value);
3235
+ }
3236
+ }
3237
+ }
3238
+
3239
+ // node_modules/.pnpm/es-toolkit@1.42.0/node_modules/es-toolkit/dist/compat/_internal/isKey.mjs
3240
+ var regexIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/;
3241
+ var regexIsPlainProp = /^\w*$/;
3242
+ function isKey(value, object) {
3243
+ if (Array.isArray(value)) {
3244
+ return false;
3245
+ }
3246
+ if (typeof value === "number" || typeof value === "boolean" || value == null || isSymbol(value)) {
3247
+ return true;
3248
+ }
3249
+ return typeof value === "string" && (regexIsPlainProp.test(value) || !regexIsDeepProp.test(value)) || object != null && Object.hasOwn(object, value);
3250
+ }
3251
+
3252
+ // node_modules/.pnpm/es-toolkit@1.42.0/node_modules/es-toolkit/dist/compat/_internal/assignValue.mjs
3253
+ var assignValue = (object, key, value) => {
3254
+ const objValue = object[key];
3255
+ if (!(Object.hasOwn(object, key) && eq(objValue, value)) || value === void 0 && !(key in object)) {
3256
+ object[key] = value;
3257
+ }
3258
+ };
3259
+
3260
+ // node_modules/.pnpm/es-toolkit@1.42.0/node_modules/es-toolkit/dist/compat/object/updateWith.mjs
3261
+ function updateWith(obj, path, updater, customizer) {
3262
+ if (obj == null && !isObject(obj)) {
3263
+ return obj;
3264
+ }
3265
+ let resolvedPath;
3266
+ if (isKey(path, obj)) {
3267
+ resolvedPath = [path];
3268
+ } else if (Array.isArray(path)) {
3269
+ resolvedPath = path;
3270
+ } else {
3271
+ resolvedPath = toPath(path);
3272
+ }
3273
+ const updateValue = updater(get(obj, resolvedPath));
3274
+ let current = obj;
3275
+ for (let i = 0; i < resolvedPath.length && current != null; i++) {
3276
+ const key = toKey(resolvedPath[i]);
3277
+ if (isUnsafeProperty(key)) {
3278
+ continue;
3279
+ }
3280
+ let newValue;
3281
+ if (i === resolvedPath.length - 1) {
3282
+ newValue = updateValue;
3283
+ } else {
3284
+ const objValue = current[key];
3285
+ const customizerResult = customizer?.(objValue, key, obj);
3286
+ newValue = customizerResult !== void 0 ? customizerResult : isObject(objValue) ? objValue : isIndex(resolvedPath[i + 1]) ? [] : {};
3287
+ }
3288
+ assignValue(current, key, newValue);
3289
+ current = current[key];
3290
+ }
3291
+ return obj;
3292
+ }
3293
+
3294
+ // node_modules/.pnpm/es-toolkit@1.42.0/node_modules/es-toolkit/dist/compat/object/set.mjs
3295
+ function set(obj, path, value) {
3296
+ return updateWith(obj, path, () => value, () => void 0);
3297
+ }
3298
+
3036
3299
  // src/ts/object/index.ts
3037
3300
  function getObjectKeys(obj) {
3038
3301
  return Object.keys(obj);
3039
3302
  }
3303
+ var getObjectValue = get;
3304
+ var setObjectValue = set;
3040
3305
 
3041
3306
  // src/ts/string/format.ts
3042
3307
  function toMaskText(s, keepLeft = 1, keepRight = 0, maskChar = "*") {
@@ -3666,6 +3931,7 @@ function isLongitude(s) {
3666
3931
  getOSSImg,
3667
3932
  getOSSVideo,
3668
3933
  getObjectKeys,
3934
+ getObjectValue,
3669
3935
  getQnAudio,
3670
3936
  getQnHls,
3671
3937
  getQnImg,
@@ -3800,6 +4066,7 @@ function isLongitude(s) {
3800
4066
  round,
3801
4067
  sample,
3802
4068
  sampleSize,
4069
+ setObjectValue,
3803
4070
  shuffle,
3804
4071
  snakeCase,
3805
4072
  sortBy,