@valkyriestudios/utils 12.38.0 → 12.40.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.
@@ -1,23 +1,23 @@
1
1
  function innerOmit(obj, keys) {
2
2
  const result = { ...obj };
3
- const groups = {};
4
3
  for (let i = 0; i < keys.length; i++) {
5
- if (typeof keys[i] === 'string') {
6
- const [root, ...rest] = keys[i].split('.');
7
- if (rest.length) {
8
- if (!groups[root])
9
- groups[root] = [];
10
- groups[root].push(rest.join('.'));
11
- }
12
- else {
13
- delete result[root];
4
+ const key = keys[i];
5
+ if (typeof key !== 'string')
6
+ continue;
7
+ let target = result;
8
+ const parts = key.split('.');
9
+ const last = parts.length - 1;
10
+ for (let j = 0; j < last; j++) {
11
+ const part = parts[j];
12
+ const val = target[part];
13
+ if (Object.prototype.toString.call(val) === '[object Object]') {
14
+ if (target[part] === obj[part]) {
15
+ target[part] = { ...val };
16
+ }
17
+ target = target[part];
14
18
  }
15
19
  }
16
- }
17
- for (const root in groups) {
18
- if (typeof result[root] === 'object' &&
19
- result[root] !== null)
20
- result[root] = innerOmit(result[root], groups[root]);
20
+ delete target[parts[last]];
21
21
  }
22
22
  return result;
23
23
  }
package/index.d.ts CHANGED
@@ -205,6 +205,12 @@ declare module "caching/LRU" {
205
205
  }
206
206
  export { LRUCache, LRUCache as default };
207
207
  }
208
+ declare module "date/isFormat" {
209
+ export const MONTHS_LEAP: number[];
210
+ export const MONTHS: number[];
211
+ function isDateFormat(input: unknown, spec: string): input is string;
212
+ export { isDateFormat, isDateFormat as default };
213
+ }
208
214
  declare module "date/format" {
209
215
  const WEEK_STARTS: {
210
216
  readonly mon: "mon";
@@ -262,10 +268,6 @@ declare module "date/toUTC" {
262
268
  function toUTC(val: Date): Date;
263
269
  export { toUTC, toUTC as default };
264
270
  }
265
- declare module "date/isFormat" {
266
- function isDateFormat(input: unknown, spec: string): input is string;
267
- export { isDateFormat, isDateFormat as default };
268
- }
269
271
  declare module "date/index" {
270
272
  export { addUTC } from "date/addUTC";
271
273
  export { convertToDate } from "date/convertToDate";