@base-web-kits/base-tools-ts 0.9.99 → 1.0.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.
@@ -779,6 +779,7 @@ var baseToolsTS = (() => {
779
779
  getOSSImg: () => getOSSImg,
780
780
  getOSSVideo: () => getOSSVideo,
781
781
  getObjectKeys: () => getObjectKeys,
782
+ getObjectValue: () => getObjectValue,
782
783
  getQnAudio: () => getQnAudio,
783
784
  getQnHls: () => getQnHls,
784
785
  getQnImg: () => getQnImg,
@@ -913,6 +914,7 @@ var baseToolsTS = (() => {
913
914
  round: () => round,
914
915
  sample: () => sample,
915
916
  sampleSize: () => sampleSize,
917
+ setObjectValue: () => setObjectValue,
916
918
  shuffle: () => shuffle,
917
919
  snakeCase: () => snakeCase,
918
920
  sortBy: () => sortBy,
@@ -5071,10 +5073,273 @@ var baseToolsTS = (() => {
5071
5073
  throw message;
5072
5074
  }
5073
5075
 
5076
+ // node_modules/.pnpm/es-toolkit@1.42.0/node_modules/es-toolkit/dist/compat/_internal/isDeepKey.mjs
5077
+ function isDeepKey(key) {
5078
+ switch (typeof key) {
5079
+ case "number":
5080
+ case "symbol": {
5081
+ return false;
5082
+ }
5083
+ case "string": {
5084
+ return key.includes(".") || key.includes("[") || key.includes("]");
5085
+ }
5086
+ }
5087
+ }
5088
+
5089
+ // node_modules/.pnpm/es-toolkit@1.42.0/node_modules/es-toolkit/dist/compat/_internal/toKey.mjs
5090
+ function toKey(value) {
5091
+ if (typeof value === "string" || typeof value === "symbol") {
5092
+ return value;
5093
+ }
5094
+ if (Object.is(value?.valueOf?.(), -0)) {
5095
+ return "-0";
5096
+ }
5097
+ return String(value);
5098
+ }
5099
+
5100
+ // node_modules/.pnpm/es-toolkit@1.42.0/node_modules/es-toolkit/dist/compat/util/toString.mjs
5101
+ function toString(value) {
5102
+ if (value == null) {
5103
+ return "";
5104
+ }
5105
+ if (typeof value === "string") {
5106
+ return value;
5107
+ }
5108
+ if (Array.isArray(value)) {
5109
+ return value.map(toString).join(",");
5110
+ }
5111
+ const result = String(value);
5112
+ if (result === "0" && Object.is(Number(value), -0)) {
5113
+ return "-0";
5114
+ }
5115
+ return result;
5116
+ }
5117
+
5118
+ // node_modules/.pnpm/es-toolkit@1.42.0/node_modules/es-toolkit/dist/compat/util/toPath.mjs
5119
+ function toPath(deepKey) {
5120
+ if (Array.isArray(deepKey)) {
5121
+ return deepKey.map(toKey);
5122
+ }
5123
+ if (typeof deepKey === "symbol") {
5124
+ return [deepKey];
5125
+ }
5126
+ deepKey = toString(deepKey);
5127
+ const result = [];
5128
+ const length = deepKey.length;
5129
+ if (length === 0) {
5130
+ return result;
5131
+ }
5132
+ let index = 0;
5133
+ let key = "";
5134
+ let quoteChar = "";
5135
+ let bracket = false;
5136
+ if (deepKey.charCodeAt(0) === 46) {
5137
+ result.push("");
5138
+ index++;
5139
+ }
5140
+ while (index < length) {
5141
+ const char = deepKey[index];
5142
+ if (quoteChar) {
5143
+ if (char === "\\" && index + 1 < length) {
5144
+ index++;
5145
+ key += deepKey[index];
5146
+ } else if (char === quoteChar) {
5147
+ quoteChar = "";
5148
+ } else {
5149
+ key += char;
5150
+ }
5151
+ } else if (bracket) {
5152
+ if (char === '"' || char === "'") {
5153
+ quoteChar = char;
5154
+ } else if (char === "]") {
5155
+ bracket = false;
5156
+ result.push(key);
5157
+ key = "";
5158
+ } else {
5159
+ key += char;
5160
+ }
5161
+ } else {
5162
+ if (char === "[") {
5163
+ bracket = true;
5164
+ if (key) {
5165
+ result.push(key);
5166
+ key = "";
5167
+ }
5168
+ } else if (char === ".") {
5169
+ if (key) {
5170
+ result.push(key);
5171
+ key = "";
5172
+ }
5173
+ } else {
5174
+ key += char;
5175
+ }
5176
+ }
5177
+ index++;
5178
+ }
5179
+ if (key) {
5180
+ result.push(key);
5181
+ }
5182
+ return result;
5183
+ }
5184
+
5185
+ // node_modules/.pnpm/es-toolkit@1.42.0/node_modules/es-toolkit/dist/compat/object/get.mjs
5186
+ function get(object, path, defaultValue) {
5187
+ if (object == null) {
5188
+ return defaultValue;
5189
+ }
5190
+ switch (typeof path) {
5191
+ case "string": {
5192
+ if (isUnsafeProperty(path)) {
5193
+ return defaultValue;
5194
+ }
5195
+ const result = object[path];
5196
+ if (result === void 0) {
5197
+ if (isDeepKey(path)) {
5198
+ return get(object, toPath(path), defaultValue);
5199
+ } else {
5200
+ return defaultValue;
5201
+ }
5202
+ }
5203
+ return result;
5204
+ }
5205
+ case "number":
5206
+ case "symbol": {
5207
+ if (typeof path === "number") {
5208
+ path = toKey(path);
5209
+ }
5210
+ const result = object[path];
5211
+ if (result === void 0) {
5212
+ return defaultValue;
5213
+ }
5214
+ return result;
5215
+ }
5216
+ default: {
5217
+ if (Array.isArray(path)) {
5218
+ return getWithPath(object, path, defaultValue);
5219
+ }
5220
+ if (Object.is(path?.valueOf(), -0)) {
5221
+ path = "-0";
5222
+ } else {
5223
+ path = String(path);
5224
+ }
5225
+ if (isUnsafeProperty(path)) {
5226
+ return defaultValue;
5227
+ }
5228
+ const result = object[path];
5229
+ if (result === void 0) {
5230
+ return defaultValue;
5231
+ }
5232
+ return result;
5233
+ }
5234
+ }
5235
+ }
5236
+ function getWithPath(object, path, defaultValue) {
5237
+ if (path.length === 0) {
5238
+ return defaultValue;
5239
+ }
5240
+ let current = object;
5241
+ for (let index = 0; index < path.length; index++) {
5242
+ if (current == null) {
5243
+ return defaultValue;
5244
+ }
5245
+ if (isUnsafeProperty(path[index])) {
5246
+ return defaultValue;
5247
+ }
5248
+ current = current[path[index]];
5249
+ }
5250
+ if (current === void 0) {
5251
+ return defaultValue;
5252
+ }
5253
+ return current;
5254
+ }
5255
+
5256
+ // node_modules/.pnpm/es-toolkit@1.42.0/node_modules/es-toolkit/dist/compat/predicate/isObject.mjs
5257
+ function isObject(value) {
5258
+ return value !== null && (typeof value === "object" || typeof value === "function");
5259
+ }
5260
+
5261
+ // node_modules/.pnpm/es-toolkit@1.42.0/node_modules/es-toolkit/dist/compat/_internal/isIndex.mjs
5262
+ var IS_UNSIGNED_INTEGER = /^(?:0|[1-9]\d*)$/;
5263
+ function isIndex(value, length = Number.MAX_SAFE_INTEGER) {
5264
+ switch (typeof value) {
5265
+ case "number": {
5266
+ return Number.isInteger(value) && value >= 0 && value < length;
5267
+ }
5268
+ case "symbol": {
5269
+ return false;
5270
+ }
5271
+ case "string": {
5272
+ return IS_UNSIGNED_INTEGER.test(value);
5273
+ }
5274
+ }
5275
+ }
5276
+
5277
+ // node_modules/.pnpm/es-toolkit@1.42.0/node_modules/es-toolkit/dist/compat/_internal/isKey.mjs
5278
+ var regexIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/;
5279
+ var regexIsPlainProp = /^\w*$/;
5280
+ function isKey(value, object) {
5281
+ if (Array.isArray(value)) {
5282
+ return false;
5283
+ }
5284
+ if (typeof value === "number" || typeof value === "boolean" || value == null || isSymbol(value)) {
5285
+ return true;
5286
+ }
5287
+ return typeof value === "string" && (regexIsPlainProp.test(value) || !regexIsDeepProp.test(value)) || object != null && Object.hasOwn(object, value);
5288
+ }
5289
+
5290
+ // node_modules/.pnpm/es-toolkit@1.42.0/node_modules/es-toolkit/dist/compat/_internal/assignValue.mjs
5291
+ var assignValue = (object, key, value) => {
5292
+ const objValue = object[key];
5293
+ if (!(Object.hasOwn(object, key) && eq(objValue, value)) || value === void 0 && !(key in object)) {
5294
+ object[key] = value;
5295
+ }
5296
+ };
5297
+
5298
+ // node_modules/.pnpm/es-toolkit@1.42.0/node_modules/es-toolkit/dist/compat/object/updateWith.mjs
5299
+ function updateWith(obj, path, updater, customizer) {
5300
+ if (obj == null && !isObject(obj)) {
5301
+ return obj;
5302
+ }
5303
+ let resolvedPath;
5304
+ if (isKey(path, obj)) {
5305
+ resolvedPath = [path];
5306
+ } else if (Array.isArray(path)) {
5307
+ resolvedPath = path;
5308
+ } else {
5309
+ resolvedPath = toPath(path);
5310
+ }
5311
+ const updateValue = updater(get(obj, resolvedPath));
5312
+ let current = obj;
5313
+ for (let i = 0; i < resolvedPath.length && current != null; i++) {
5314
+ const key = toKey(resolvedPath[i]);
5315
+ if (isUnsafeProperty(key)) {
5316
+ continue;
5317
+ }
5318
+ let newValue;
5319
+ if (i === resolvedPath.length - 1) {
5320
+ newValue = updateValue;
5321
+ } else {
5322
+ const objValue = current[key];
5323
+ const customizerResult = customizer?.(objValue, key, obj);
5324
+ newValue = customizerResult !== void 0 ? customizerResult : isObject(objValue) ? objValue : isIndex(resolvedPath[i + 1]) ? [] : {};
5325
+ }
5326
+ assignValue(current, key, newValue);
5327
+ current = current[key];
5328
+ }
5329
+ return obj;
5330
+ }
5331
+
5332
+ // node_modules/.pnpm/es-toolkit@1.42.0/node_modules/es-toolkit/dist/compat/object/set.mjs
5333
+ function set(obj, path, value) {
5334
+ return updateWith(obj, path, () => value, () => void 0);
5335
+ }
5336
+
5074
5337
  // src/ts/object/index.ts
5075
5338
  function getObjectKeys(obj) {
5076
5339
  return Object.keys(obj);
5077
5340
  }
5341
+ var getObjectValue = get;
5342
+ var setObjectValue = set;
5078
5343
 
5079
5344
  // src/ts/string/format.ts
5080
5345
  function toMaskText(s, keepLeft = 1, keepRight = 0, maskChar = "*") {