@oscarpalmer/atoms 0.120.0 → 0.122.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.
@@ -3,7 +3,6 @@ import { filter } from "./filter.js";
3
3
  import { find } from "./find.js";
4
4
  import { flatten } from "./flatten.js";
5
5
  import { getArray } from "./get.js";
6
- import { groupBy } from "./group-by.js";
7
6
  import { indexOf } from "./index-of.js";
8
7
  import { chunk } from "../internal/array/chunk.js";
9
8
  import { compact } from "../internal/array/compact.js";
@@ -12,8 +11,6 @@ import { insert } from "./insert.js";
12
11
  import { push } from "./push.js";
13
12
  import { sort } from "./sort.js";
14
13
  import { splice } from "./splice.js";
15
- import { toMap } from "./to-map.js";
16
- import { toRecord } from "./to-record.js";
17
14
  import { toSet } from "./to-set.js";
18
15
  import { unique } from "./unique.js";
19
- export { chunk, compact, exists, filter, find, flatten, getArray, groupBy, indexOf, insert, push, shuffle, sort, splice, toMap, toRecord, toSet, unique };
16
+ export { chunk, compact, exists, filter, find, flatten, getArray, indexOf, insert, push, shuffle, sort, splice, toSet, unique };
@@ -189,32 +189,6 @@ function getArray(value, indiced) {
189
189
  }
190
190
  return array;
191
191
  }
192
- function groupValues(array, key, value, arrays) {
193
- if (!Array.isArray(array) || array.length === 0) return {};
194
- const { length } = array;
195
- const callbacks = getArrayCallbacks(void 0, key, value);
196
- const record = {};
197
- for (let index = 0; index < length; index += 1) {
198
- const item = array[index];
199
- const keyed = callbacks?.keyed?.(item, index, array) ?? index;
200
- const valued = callbacks?.value?.(item, index, array) ?? item;
201
- if (arrays) {
202
- const existing = record[keyed];
203
- if (existing == null) record[keyed] = [valued];
204
- else existing.push(valued);
205
- } else record[keyed] = valued;
206
- }
207
- return record;
208
- }
209
- function groupBy(array, first, second) {
210
- return groupValues(array, first, second, false);
211
- }
212
- (function(_groupBy) {
213
- function arrays(array, first, second) {
214
- return groupValues(array, first, second, true);
215
- }
216
- _groupBy.arrays = arrays;
217
- })(groupBy || (groupBy = {}));
218
192
  function indexOf(array, ...parameters) {
219
193
  return findValue("index", array, parameters);
220
194
  }
@@ -425,6 +399,45 @@ function sort(array, first, second) {
425
399
  function splice(array, start, deleteCountOrItems, items) {
426
400
  return insertValues("splice", array, typeof deleteCountOrItems === "number" ? items : deleteCountOrItems, start, typeof deleteCountOrItems === "number" ? deleteCountOrItems : 0);
427
401
  }
402
+ function toSet(array, value) {
403
+ if (!Array.isArray(array)) return /* @__PURE__ */ new Set();
404
+ const callbacks = getArrayCallbacks(void 0, void 0, value);
405
+ if (callbacks?.value == null) return new Set(array);
406
+ const { length } = array;
407
+ const set = /* @__PURE__ */ new Set();
408
+ for (let index = 0; index < length; index += 1) set.add(callbacks.value(array[index], index, array));
409
+ return set;
410
+ }
411
+ function unique(array, key) {
412
+ if (!Array.isArray(array)) return [];
413
+ return array.length > 1 ? findValues("unique", array, [key, void 0]) : array;
414
+ }
415
+ function groupValues(array, key, value, arrays) {
416
+ if (!Array.isArray(array) || array.length === 0) return {};
417
+ const { length } = array;
418
+ const callbacks = getArrayCallbacks(void 0, key, value);
419
+ const record = {};
420
+ for (let index = 0; index < length; index += 1) {
421
+ const item = array[index];
422
+ const keyed = callbacks?.keyed?.(item, index, array) ?? index;
423
+ const valued = callbacks?.value?.(item, index, array) ?? item;
424
+ if (arrays) {
425
+ const existing = record[keyed];
426
+ if (existing == null) record[keyed] = [valued];
427
+ else existing.push(valued);
428
+ } else record[keyed] = valued;
429
+ }
430
+ return record;
431
+ }
432
+ function groupBy(array, first, second) {
433
+ return groupValues(array, first, second, false);
434
+ }
435
+ (function(_groupBy) {
436
+ function arrays(array, first, second) {
437
+ return groupValues(array, first, second, true);
438
+ }
439
+ _groupBy.arrays = arrays;
440
+ })(groupBy || (groupBy = {}));
428
441
  function getMapValues(array, first, second, arrays) {
429
442
  if (!Array.isArray(array)) return /* @__PURE__ */ new Map();
430
443
  const { length } = array;
@@ -460,19 +473,6 @@ function toRecord(array, first, second) {
460
473
  }
461
474
  _toRecord.arrays = arrays;
462
475
  })(toRecord || (toRecord = {}));
463
- function toSet(array, value) {
464
- if (!Array.isArray(array)) return /* @__PURE__ */ new Set();
465
- const callbacks = getArrayCallbacks(void 0, void 0, value);
466
- if (callbacks?.value == null) return new Set(array);
467
- const { length } = array;
468
- const set = /* @__PURE__ */ new Set();
469
- for (let index = 0; index < length; index += 1) set.add(callbacks.value(array[index], index, array));
470
- return set;
471
- }
472
- function unique(array, key) {
473
- if (!Array.isArray(array)) return [];
474
- return array.length > 1 ? findValues("unique", array, [key, void 0]) : array;
475
- }
476
476
  function noop() {}
477
477
  var Beacon = class {
478
478
  #options;
@@ -1317,6 +1317,145 @@ function throttle(callback, time) {
1317
1317
  return getLimiter(callback, true, time);
1318
1318
  }
1319
1319
  const DEFAULT_CACHE_SIZE = 1024;
1320
+ function equal(first, second, options) {
1321
+ return equalValue(first, second, getEqualOptions(options));
1322
+ }
1323
+ (function(_equal) {
1324
+ function initialize(options) {
1325
+ const actual = getEqualOptions(options);
1326
+ return (first, second) => equalValue(first, second, actual);
1327
+ }
1328
+ _equal.initialize = initialize;
1329
+ })(equal || (equal = {}));
1330
+ function equalArray(first, second, options) {
1331
+ const { length } = first;
1332
+ if (length !== second.length) return false;
1333
+ let offset = 0;
1334
+ if (length >= ARRAY_THRESHOLD) {
1335
+ offset = Math.round(length / ARRAY_PEEK_PERCENTAGE);
1336
+ offset = offset > ARRAY_THRESHOLD ? ARRAY_THRESHOLD : offset;
1337
+ for (let index = 0; index < offset; index += 1) if (!(equalValue(first[index], second[index], options) && equalValue(first[length - index - 1], second[length - index - 1], options))) return false;
1338
+ }
1339
+ const firstChunks = chunk(first.slice(offset, length - offset), ARRAY_THRESHOLD);
1340
+ const secondChunks = chunk(second.slice(offset, length - offset), ARRAY_THRESHOLD);
1341
+ const chunksLength = firstChunks.length;
1342
+ for (let chunkIndex = 0; chunkIndex < chunksLength; chunkIndex += 1) {
1343
+ const firstChunk = firstChunks[chunkIndex];
1344
+ const secondChunk = secondChunks[chunkIndex];
1345
+ const chunkLength = firstChunk.length;
1346
+ for (let index = 0; index < chunkLength; index += 1) if (!equalValue(firstChunk[index], secondChunk[index], options)) return false;
1347
+ }
1348
+ return true;
1349
+ }
1350
+ function equalArrayBuffer(first, second, options) {
1351
+ return first.byteLength === second.byteLength ? equalArray(new Uint8Array(first), new Uint8Array(second), options) : false;
1352
+ }
1353
+ function equalDataView(first, second, options) {
1354
+ return first.byteOffset === second.byteOffset ? equalArrayBuffer(first.buffer, second.buffer, options) : false;
1355
+ }
1356
+ function equalMap(first, second, options) {
1357
+ const { size } = first;
1358
+ if (size !== second.size) return false;
1359
+ const firstKeys = [...first.keys()];
1360
+ const secondKeys = [...second.keys()];
1361
+ if (firstKeys.some((key) => !secondKeys.includes(key))) return false;
1362
+ for (let index = 0; index < size; index += 1) {
1363
+ const key = firstKeys[index];
1364
+ if (!equalValue(first.get(key), second.get(key), options)) return false;
1365
+ }
1366
+ return true;
1367
+ }
1368
+ function equalObject(first, second, options) {
1369
+ const firstKeys = [...Object.keys(first), ...Object.getOwnPropertySymbols(first)].filter((key) => filterKey(key, options));
1370
+ const secondKeys = [...Object.keys(second), ...Object.getOwnPropertySymbols(second)].filter((key) => filterKey(key, options));
1371
+ const { length } = firstKeys;
1372
+ if (length !== secondKeys.length || firstKeys.some((key) => !secondKeys.includes(key))) return false;
1373
+ for (let index = 0; index < length; index += 1) {
1374
+ const key = firstKeys[index];
1375
+ if (!equalValue(first[key], second[key], options)) return false;
1376
+ }
1377
+ return true;
1378
+ }
1379
+ function equalProperties(first, second, properties, options) {
1380
+ const { length } = properties;
1381
+ for (let index = 0; index < length; index += 1) {
1382
+ const property = properties[index];
1383
+ if (!equalValue(first[property], second[property], options)) return false;
1384
+ }
1385
+ return true;
1386
+ }
1387
+ function equalSet(first, second, options) {
1388
+ const { size } = first;
1389
+ if (size !== second.size) return false;
1390
+ const firstValues = [...first];
1391
+ const secondValues = [...second];
1392
+ for (let index = 0; index < size; index += 1) {
1393
+ const firstValue = firstValues[index];
1394
+ if (!secondValues.some((secondValue) => equalValue(firstValue, secondValue, options))) return false;
1395
+ }
1396
+ return true;
1397
+ }
1398
+ function equalTypedArray(first, second) {
1399
+ if (first.constructor !== second.constructor) return false;
1400
+ if (first.byteLength !== second.byteLength) return false;
1401
+ const { length } = first;
1402
+ for (let index = 0; index < length; index += 1) if (first[index] !== second[index]) return false;
1403
+ return true;
1404
+ }
1405
+ function equalValue(first, second, options) {
1406
+ if (options.relaxedNullish === true && first == null && second == null) return true;
1407
+ switch (true) {
1408
+ case Object.is(first, second): return true;
1409
+ case first == null || second == null: return first === second;
1410
+ case typeof first !== typeof second: return false;
1411
+ case typeof first === "string" && options.ignoreCase === true: return Object.is(first.toLocaleLowerCase(), second.toLocaleLowerCase());
1412
+ case first instanceof ArrayBuffer && second instanceof ArrayBuffer: return equalArrayBuffer(first, second, options);
1413
+ case first instanceof Date && second instanceof Date: return Object.is(Number(first), Number(second));
1414
+ case first instanceof DataView && second instanceof DataView: return equalDataView(first, second, options);
1415
+ case first instanceof Error && second instanceof Error: return equalProperties(first, second, ["name", "message"], options);
1416
+ case first instanceof Map && second instanceof Map: return equalMap(first, second, options);
1417
+ case first instanceof RegExp && second instanceof RegExp: return equalProperties(first, second, ["source", "flags"], options);
1418
+ case first instanceof Set && second instanceof Set: return equalSet(first, second, options);
1419
+ case Array.isArray(first) && Array.isArray(second): return equalArray(first, second, options);
1420
+ case isPlainObject(first) && isPlainObject(second): return equalObject(first, second, options);
1421
+ case isTypedArray(first) && isTypedArray(second): return equalTypedArray(first, second);
1422
+ default: return Object.is(first, second);
1423
+ }
1424
+ }
1425
+ function filterKey(key, options) {
1426
+ if (typeof key !== "string") return true;
1427
+ if (options.ignoreExpressions.enabled && options.ignoreExpressions.values.some((expression) => expression.test(key))) return false;
1428
+ if (options.ignoreKeys.enabled && options.ignoreKeys.values.has(key)) return false;
1429
+ return true;
1430
+ }
1431
+ function getEqualOptions(input) {
1432
+ const options = {
1433
+ ignoreCase: false,
1434
+ ignoreExpressions: {
1435
+ enabled: false,
1436
+ values: []
1437
+ },
1438
+ ignoreKeys: {
1439
+ enabled: false,
1440
+ values: /* @__PURE__ */ new Set()
1441
+ },
1442
+ relaxedNullish: false
1443
+ };
1444
+ if (typeof input === "boolean") {
1445
+ options.ignoreCase = input;
1446
+ return options;
1447
+ }
1448
+ if (!isPlainObject(input)) return options;
1449
+ options.ignoreCase = typeof input.ignoreCase === "boolean" ? input.ignoreCase : false;
1450
+ options.ignoreExpressions.values = (Array.isArray(input.ignoreKeys) ? input.ignoreKeys : [input.ignoreKeys]).filter((key) => key instanceof RegExp);
1451
+ options.ignoreKeys.values = new Set((Array.isArray(input.ignoreKeys) ? input.ignoreKeys : [input.ignoreKeys]).filter((key) => typeof key === "string"));
1452
+ options.ignoreExpressions.enabled = options.ignoreExpressions.values.length > 0;
1453
+ options.ignoreKeys.enabled = options.ignoreKeys.values.size > 0;
1454
+ options.relaxedNullish = input.relaxedNullish === true;
1455
+ return options;
1456
+ }
1457
+ const ARRAY_PEEK_PERCENTAGE = 10;
1458
+ const ARRAY_THRESHOLD = 100;
1320
1459
  let enabled = true;
1321
1460
  var Logger = class {
1322
1461
  get debug() {
@@ -1695,145 +1834,6 @@ function template(value, variables, options) {
1695
1834
  _template.initialize = initialize;
1696
1835
  })(template || (template = {}));
1697
1836
  const EXPRESSION_VARIABLE = /{{([\s\S]+?)}}/g;
1698
- function equal(first, second, options) {
1699
- return equalValue(first, second, getEqualOptions(options));
1700
- }
1701
- (function(_equal) {
1702
- function initialize(options) {
1703
- const actual = getEqualOptions(options);
1704
- return (first, second) => equalValue(first, second, actual);
1705
- }
1706
- _equal.initialize = initialize;
1707
- })(equal || (equal = {}));
1708
- function equalArray(first, second, options) {
1709
- const { length } = first;
1710
- if (length !== second.length) return false;
1711
- let offset = 0;
1712
- if (length >= ARRAY_THRESHOLD) {
1713
- offset = Math.round(length / ARRAY_PEEK_PERCENTAGE);
1714
- offset = offset > ARRAY_THRESHOLD ? ARRAY_THRESHOLD : offset;
1715
- for (let index = 0; index < offset; index += 1) if (!(equalValue(first[index], second[index], options) && equalValue(first[length - index - 1], second[length - index - 1], options))) return false;
1716
- }
1717
- const firstChunks = chunk(first.slice(offset, length - offset), ARRAY_THRESHOLD);
1718
- const secondChunks = chunk(second.slice(offset, length - offset), ARRAY_THRESHOLD);
1719
- const chunksLength = firstChunks.length;
1720
- for (let chunkIndex = 0; chunkIndex < chunksLength; chunkIndex += 1) {
1721
- const firstChunk = firstChunks[chunkIndex];
1722
- const secondChunk = secondChunks[chunkIndex];
1723
- const chunkLength = firstChunk.length;
1724
- for (let index = 0; index < chunkLength; index += 1) if (!equalValue(firstChunk[index], secondChunk[index], options)) return false;
1725
- }
1726
- return true;
1727
- }
1728
- function equalArrayBuffer(first, second, options) {
1729
- return first.byteLength === second.byteLength ? equalArray(new Uint8Array(first), new Uint8Array(second), options) : false;
1730
- }
1731
- function equalDataView(first, second, options) {
1732
- return first.byteOffset === second.byteOffset ? equalArrayBuffer(first.buffer, second.buffer, options) : false;
1733
- }
1734
- function equalMap(first, second, options) {
1735
- const { size } = first;
1736
- if (size !== second.size) return false;
1737
- const firstKeys = [...first.keys()];
1738
- const secondKeys = [...second.keys()];
1739
- if (firstKeys.some((key) => !secondKeys.includes(key))) return false;
1740
- for (let index = 0; index < size; index += 1) {
1741
- const key = firstKeys[index];
1742
- if (!equalValue(first.get(key), second.get(key), options)) return false;
1743
- }
1744
- return true;
1745
- }
1746
- function equalObject(first, second, options) {
1747
- const firstKeys = [...Object.keys(first), ...Object.getOwnPropertySymbols(first)].filter((key) => filterKey(key, options));
1748
- const secondKeys = [...Object.keys(second), ...Object.getOwnPropertySymbols(second)].filter((key) => filterKey(key, options));
1749
- const { length } = firstKeys;
1750
- if (length !== secondKeys.length || firstKeys.some((key) => !secondKeys.includes(key))) return false;
1751
- for (let index = 0; index < length; index += 1) {
1752
- const key = firstKeys[index];
1753
- if (!equalValue(first[key], second[key], options)) return false;
1754
- }
1755
- return true;
1756
- }
1757
- function equalProperties(first, second, properties, options) {
1758
- const { length } = properties;
1759
- for (let index = 0; index < length; index += 1) {
1760
- const property = properties[index];
1761
- if (!equalValue(first[property], second[property], options)) return false;
1762
- }
1763
- return true;
1764
- }
1765
- function equalSet(first, second, options) {
1766
- const { size } = first;
1767
- if (size !== second.size) return false;
1768
- const firstValues = [...first];
1769
- const secondValues = [...second];
1770
- for (let index = 0; index < size; index += 1) {
1771
- const firstValue = firstValues[index];
1772
- if (!secondValues.some((secondValue) => equalValue(firstValue, secondValue, options))) return false;
1773
- }
1774
- return true;
1775
- }
1776
- function equalTypedArray(first, second) {
1777
- if (first.constructor !== second.constructor) return false;
1778
- if (first.byteLength !== second.byteLength) return false;
1779
- const { length } = first;
1780
- for (let index = 0; index < length; index += 1) if (first[index] !== second[index]) return false;
1781
- return true;
1782
- }
1783
- function equalValue(first, second, options) {
1784
- if (options.relaxedNullish === true && first == null && second == null) return true;
1785
- switch (true) {
1786
- case Object.is(first, second): return true;
1787
- case first == null || second == null: return first === second;
1788
- case typeof first !== typeof second: return false;
1789
- case typeof first === "string" && options.ignoreCase === true: return Object.is(first.toLocaleLowerCase(), second.toLocaleLowerCase());
1790
- case first instanceof ArrayBuffer && second instanceof ArrayBuffer: return equalArrayBuffer(first, second, options);
1791
- case first instanceof Date && second instanceof Date: return Object.is(Number(first), Number(second));
1792
- case first instanceof DataView && second instanceof DataView: return equalDataView(first, second, options);
1793
- case first instanceof Error && second instanceof Error: return equalProperties(first, second, ["name", "message"], options);
1794
- case first instanceof Map && second instanceof Map: return equalMap(first, second, options);
1795
- case first instanceof RegExp && second instanceof RegExp: return equalProperties(first, second, ["source", "flags"], options);
1796
- case first instanceof Set && second instanceof Set: return equalSet(first, second, options);
1797
- case Array.isArray(first) && Array.isArray(second): return equalArray(first, second, options);
1798
- case isPlainObject(first) && isPlainObject(second): return equalObject(first, second, options);
1799
- case isTypedArray(first) && isTypedArray(second): return equalTypedArray(first, second);
1800
- default: return Object.is(first, second);
1801
- }
1802
- }
1803
- function filterKey(key, options) {
1804
- if (typeof key !== "string") return true;
1805
- if (options.ignoreExpressions.enabled && options.ignoreExpressions.values.some((expression) => expression.test(key))) return false;
1806
- if (options.ignoreKeys.enabled && options.ignoreKeys.values.has(key)) return false;
1807
- return true;
1808
- }
1809
- function getEqualOptions(input) {
1810
- const options = {
1811
- ignoreCase: false,
1812
- ignoreExpressions: {
1813
- enabled: false,
1814
- values: []
1815
- },
1816
- ignoreKeys: {
1817
- enabled: false,
1818
- values: /* @__PURE__ */ new Set()
1819
- },
1820
- relaxedNullish: false
1821
- };
1822
- if (typeof input === "boolean") {
1823
- options.ignoreCase = input;
1824
- return options;
1825
- }
1826
- if (!isPlainObject(input)) return options;
1827
- options.ignoreCase = typeof input.ignoreCase === "boolean" ? input.ignoreCase : false;
1828
- options.ignoreExpressions.values = (Array.isArray(input.ignoreKeys) ? input.ignoreKeys : [input.ignoreKeys]).filter((key) => key instanceof RegExp);
1829
- options.ignoreKeys.values = new Set((Array.isArray(input.ignoreKeys) ? input.ignoreKeys : [input.ignoreKeys]).filter((key) => typeof key === "string"));
1830
- options.ignoreExpressions.enabled = options.ignoreExpressions.values.length > 0;
1831
- options.ignoreKeys.enabled = options.ignoreKeys.values.size > 0;
1832
- options.relaxedNullish = input.relaxedNullish === true;
1833
- return options;
1834
- }
1835
- const ARRAY_PEEK_PERCENTAGE = 10;
1836
- const ARRAY_THRESHOLD = 100;
1837
1837
  function clone(value) {
1838
1838
  return cloneValue(value, 0, /* @__PURE__ */ new WeakMap());
1839
1839
  }
@@ -1929,6 +1929,71 @@ function tryStructuredClone(value, depth, references) {
1929
1929
  }
1930
1930
  }
1931
1931
  const MAX_CLONE_DEPTH = 100;
1932
+ function partial(value, keys) {
1933
+ if (typeof value !== "object" || value === null || Object.keys(value).length === 0 || !Array.isArray(keys) || keys.length === 0) return {};
1934
+ const { length } = keys;
1935
+ const result = {};
1936
+ for (let index = 0; index < length; index += 1) {
1937
+ const key = keys[index];
1938
+ if (key in value) result[key] = value[key];
1939
+ }
1940
+ return result;
1941
+ }
1942
+ function flattenObject(value, depth, smushed, prefix) {
1943
+ if (depth >= MAX_DEPTH) return {};
1944
+ if (smushed.has(value)) return smushed.get(value);
1945
+ const keys = Object.keys(value);
1946
+ const { length } = keys;
1947
+ const flattened = {};
1948
+ for (let index = 0; index < length; index += 1) {
1949
+ const key = keys[index];
1950
+ const val = value[key];
1951
+ if (isArrayOrPlainObject(val)) {
1952
+ const prefixedKey = join([prefix, key], ".");
1953
+ flattened[prefixedKey] = Array.isArray(val) ? [...val] : { ...val };
1954
+ const nested = flattenObject(val, depth + 1, smushed, prefixedKey);
1955
+ const nestedKeys = Object.keys(nested);
1956
+ const nestedLength = nestedKeys.length;
1957
+ for (let nestedIndex = 0; nestedIndex < nestedLength; nestedIndex += 1) {
1958
+ const nestedKey = nestedKeys[nestedIndex];
1959
+ flattened[nestedKey] = nested[nestedKey];
1960
+ }
1961
+ } else flattened[join([prefix, key], ".")] = val;
1962
+ }
1963
+ smushed.set(value, flattened);
1964
+ return flattened;
1965
+ }
1966
+ function smush(value) {
1967
+ return typeof value === "object" && value !== null ? flattenObject(value, 0, /* @__PURE__ */ new WeakMap()) : {};
1968
+ }
1969
+ const MAX_DEPTH = 100;
1970
+ function getKeys(value) {
1971
+ const keys = Object.keys(value);
1972
+ const { length } = keys;
1973
+ const result = [];
1974
+ for (let index = 0; index < length; index += 1) {
1975
+ const key = keys[index];
1976
+ result.push({
1977
+ order: key.split(".").length,
1978
+ value: key
1979
+ });
1980
+ }
1981
+ return result.sort((first, second) => first.order - second.order);
1982
+ }
1983
+ function unsmush(value) {
1984
+ if (typeof value !== "object" || value === null) return {};
1985
+ const keys = getKeys(value);
1986
+ const { length } = keys;
1987
+ const unsmushed = {};
1988
+ for (let index = 0; index < length; index += 1) {
1989
+ const key = keys[index].value;
1990
+ const val = value[key];
1991
+ let next = val;
1992
+ if (isArrayOrPlainObject(val)) next = Array.isArray(val) ? [...val] : { ...val };
1993
+ setValue(unsmushed, key, next);
1994
+ }
1995
+ return unsmushed;
1996
+ }
1932
1997
  function diff(first, second, options) {
1933
1998
  const relaxedNullish = typeof options === "object" && options?.relaxedNullish === true;
1934
1999
  const result = {
@@ -2069,69 +2134,4 @@ function mergeValues(values, options, validate, prefix) {
2069
2134
  const actual = validate ? values.filter(isArrayOrPlainObject) : values;
2070
2135
  return actual.length > 1 ? mergeObjects(actual, options, prefix) : actual[0] ?? {};
2071
2136
  }
2072
- function partial(value, keys) {
2073
- if (typeof value !== "object" || value === null || Object.keys(value).length === 0 || !Array.isArray(keys) || keys.length === 0) return {};
2074
- const { length } = keys;
2075
- const result = {};
2076
- for (let index = 0; index < length; index += 1) {
2077
- const key = keys[index];
2078
- if (key in value) result[key] = value[key];
2079
- }
2080
- return result;
2081
- }
2082
- function flattenObject(value, depth, smushed, prefix) {
2083
- if (depth >= MAX_DEPTH) return {};
2084
- if (smushed.has(value)) return smushed.get(value);
2085
- const keys = Object.keys(value);
2086
- const { length } = keys;
2087
- const flattened = {};
2088
- for (let index = 0; index < length; index += 1) {
2089
- const key = keys[index];
2090
- const val = value[key];
2091
- if (isArrayOrPlainObject(val)) {
2092
- const prefixedKey = join([prefix, key], ".");
2093
- flattened[prefixedKey] = Array.isArray(val) ? [...val] : { ...val };
2094
- const nested = flattenObject(val, depth + 1, smushed, prefixedKey);
2095
- const nestedKeys = Object.keys(nested);
2096
- const nestedLength = nestedKeys.length;
2097
- for (let nestedIndex = 0; nestedIndex < nestedLength; nestedIndex += 1) {
2098
- const nestedKey = nestedKeys[nestedIndex];
2099
- flattened[nestedKey] = nested[nestedKey];
2100
- }
2101
- } else flattened[join([prefix, key], ".")] = val;
2102
- }
2103
- smushed.set(value, flattened);
2104
- return flattened;
2105
- }
2106
- function smush(value) {
2107
- return typeof value === "object" && value !== null ? flattenObject(value, 0, /* @__PURE__ */ new WeakMap()) : {};
2108
- }
2109
- const MAX_DEPTH = 100;
2110
- function getKeys(value) {
2111
- const keys = Object.keys(value);
2112
- const { length } = keys;
2113
- const result = [];
2114
- for (let index = 0; index < length; index += 1) {
2115
- const key = keys[index];
2116
- result.push({
2117
- order: key.split(".").length,
2118
- value: key
2119
- });
2120
- }
2121
- return result.sort((first, second) => first.order - second.order);
2122
- }
2123
- function unsmush(value) {
2124
- if (typeof value !== "object" || value === null) return {};
2125
- const keys = getKeys(value);
2126
- const { length } = keys;
2127
- const unsmushed = {};
2128
- for (let index = 0; index < length; index += 1) {
2129
- const key = keys[index].value;
2130
- const val = value[key];
2131
- let next = val;
2132
- if (isArrayOrPlainObject(val)) next = Array.isArray(val) ? [...val] : { ...val };
2133
- setValue(unsmushed, key, next);
2134
- }
2135
- return unsmushed;
2136
- }
2137
2137
  export { frame_rate_default as FRAME_RATE_MS, SizedMap, SizedSet, average, beacon, between, camelCase, capitalize, chunk, clamp, clone, compact, compare, count, createUuid, debounce, diff, equal, exists, filter, find, flatten, fromQuery, getArray, getColor, getForegroundColor, getHexColor, getHexaColor, getHslColor, getHslaColor, getNormalizedHex, getNumber, getRandomBoolean, getRandomCharacters, getRandomColor, getRandomFloat, getRandomHex, getRandomInteger, getRandomItem, getRandomItems, getRgbColor, getRgbaColor, getString, getUuid, getValue, groupBy, hexToHsl, hexToHsla, hexToRgb, hexToRgba, hslToHex, hslToRgb, hslToRgba, indexOf, insert, isArrayOrPlainObject, isColor, isEmpty, isHexColor, isHslColor, isHslLike, isHslaColor, isKey, isNullable, isNullableOrEmpty, isNullableOrWhitespace, isNumber, isNumerical, isObject, isPlainObject, isPrimitive, isRgbColor, isRgbLike, isRgbaColor, isTypedArray, join, kebabCase, logger, max, memoize, merge, min, noop, parse, partial, pascalCase, push, rgbToHex, rgbToHsl, rgbToHsla, round, setValue, shuffle, smush, snakeCase, sort, splice, sum, template, throttle, titleCase, toMap, toQuery, toRecord, toSet, truncate, unique, unsmush, words };
package/dist/index.js CHANGED
@@ -17,11 +17,11 @@ import { getString, join, words } from "./internal/string.js";
17
17
  import { compare } from "./internal/value/compare.js";
18
18
  import { sort } from "./array/sort.js";
19
19
  import { splice } from "./array/splice.js";
20
- import { toMap } from "./array/to-map.js";
21
- import { toRecord } from "./array/to-record.js";
22
20
  import { toSet } from "./array/to-set.js";
23
21
  import { unique } from "./array/unique.js";
24
22
  import "./array/index.js";
23
+ import { toMap } from "./array/to-map.js";
24
+ import { toRecord } from "./array/to-record.js";
25
25
  import { noop } from "./internal/function.js";
26
26
  import { beacon } from "./beacon.js";
27
27
  import { between, clamp, getNumber } from "./internal/number.js";
@@ -36,6 +36,7 @@ import frame_rate_default from "./internal/frame-rate.js";
36
36
  import { isEmpty, isNullable, isNullableOrEmpty, isNullableOrWhitespace, isNumerical, isObject, isPrimitive } from "./is.js";
37
37
  import { SizedMap, SizedSet } from "./sized.js";
38
38
  import { debounce, memoize, throttle } from "./function.js";
39
+ import { equal } from "./internal/value/equal.js";
39
40
  import { logger } from "./logger.js";
40
41
  import { average, count, min, round, sum } from "./math.js";
41
42
  import { setValue } from "./internal/value/set.js";
@@ -43,15 +44,14 @@ import { fromQuery, toQuery } from "./query.js";
43
44
  import { getRandomBoolean, getRandomCharacters, getRandomColor, getRandomHex, getRandomItem, getRandomItems } from "./random.js";
44
45
  import { camelCase, capitalize, kebabCase, pascalCase, snakeCase, titleCase } from "./string/case.js";
45
46
  import { createUuid, getUuid, parse, truncate } from "./string/misc.js";
47
+ import "./string/index.js";
46
48
  import { getValue } from "./internal/value/get.js";
47
49
  import { template } from "./string/template.js";
48
- import "./string/index.js";
49
- import { equal } from "./internal/value/equal.js";
50
50
  import { clone } from "./value/clone.js";
51
- import { diff } from "./value/diff.js";
52
- import { merge } from "./value/merge.js";
53
51
  import { partial } from "./value/partial.js";
54
52
  import { smush } from "./value/smush.js";
55
53
  import { unsmush } from "./value/unsmush.js";
56
54
  import "./value/index.js";
55
+ import { diff } from "./value/diff.js";
56
+ import { merge } from "./value/merge.js";
57
57
  export { frame_rate_default as FRAME_RATE_MS, SizedMap, SizedSet, average, beacon, between, camelCase, capitalize, chunk, clamp, clone, compact, compare, count, createUuid, debounce, diff, equal, exists, filter, find, flatten, fromQuery, getArray, getColor, getForegroundColor, getHexColor, getHexaColor, getHslColor, getHslaColor, getNormalizedHex, getNumber, getRandomBoolean, getRandomCharacters, getRandomColor, getRandomFloat, getRandomHex, getRandomInteger, getRandomItem, getRandomItems, getRgbColor, getRgbaColor, getString, getUuid, getValue, groupBy, hexToHsl, hexToHsla, hexToRgb, hexToRgba, hslToHex, hslToRgb, hslToRgba, indexOf, insert, isArrayOrPlainObject, isColor, isEmpty, isHexColor, isHslColor, isHslLike, isHslaColor, isKey, isNullable, isNullableOrEmpty, isNullableOrWhitespace, isNumber, isNumerical, isObject, isPlainObject, isPrimitive, isRgbColor, isRgbLike, isRgbaColor, isTypedArray, join, kebabCase, logger, max, memoize, merge, min, noop, parse, partial, pascalCase, push, rgbToHex, rgbToHsl, rgbToHsla, round, setValue, shuffle, smush, snakeCase, sort, splice, sum, template, throttle, titleCase, toMap, toQuery, toRecord, toSet, truncate, unique, unsmush, words };
@@ -1,5 +1,4 @@
1
1
  import { getString, join, words } from "../internal/string.js";
2
2
  import { camelCase, capitalize, kebabCase, pascalCase, snakeCase, titleCase } from "./case.js";
3
3
  import { createUuid, getUuid, parse, truncate } from "./misc.js";
4
- import { template } from "./template.js";
5
- export { camelCase, capitalize, createUuid, getString, getUuid, join, kebabCase, parse, pascalCase, snakeCase, template, titleCase, truncate, words };
4
+ export { camelCase, capitalize, createUuid, getString, getUuid, join, kebabCase, parse, pascalCase, snakeCase, titleCase, truncate, words };
@@ -1,11 +1,8 @@
1
1
  import { compare } from "../internal/value/compare.js";
2
2
  import { setValue } from "../internal/value/set.js";
3
3
  import { getValue } from "../internal/value/get.js";
4
- import { equal } from "../internal/value/equal.js";
5
4
  import { clone } from "./clone.js";
6
- import { diff } from "./diff.js";
7
- import { merge } from "./merge.js";
8
5
  import { partial } from "./partial.js";
9
6
  import { smush } from "./smush.js";
10
7
  import { unsmush } from "./unsmush.js";
11
- export { clone, compare, diff, equal, getValue, merge, partial, setValue, smush, unsmush };
8
+ export { clone, compare, getValue, partial, setValue, smush, unsmush };
package/package.json CHANGED
@@ -26,6 +26,18 @@
26
26
  "types": "./types/array/index.d.ts",
27
27
  "default": "./dist/array/index.js"
28
28
  },
29
+ "./array/group-by": {
30
+ "types": "./types/array/group-by.d.ts",
31
+ "default": "./dist/array/group-by.js"
32
+ },
33
+ "./array/to-map": {
34
+ "types": "./types/array/to-map.d.ts",
35
+ "default": "./dist/array/to-map.js"
36
+ },
37
+ "./array/to-record": {
38
+ "types": "./types/array/to-record.d.ts",
39
+ "default": "./dist/array/to-record.js"
40
+ },
29
41
  "./beacon": {
30
42
  "types": "./types/beacon.d.ts",
31
43
  "default": "./dist/beacon.js"
@@ -77,9 +89,25 @@
77
89
  "types": "./types/string/index.d.ts",
78
90
  "default": "./dist/string/index.js"
79
91
  },
92
+ "./string/template": {
93
+ "types": "./types/string/template.d.ts",
94
+ "default": "./dist/string/template.js"
95
+ },
80
96
  "./value": {
81
97
  "types": "./types/value/index.d.ts",
82
98
  "default": "./dist/value/index.js"
99
+ },
100
+ "./value/diff": {
101
+ "types": "./types/value/diff.d.ts",
102
+ "default": "./dist/value/diff.js"
103
+ },
104
+ "./value/equal": {
105
+ "types": "./types/internal/value/equal.d.ts",
106
+ "default": "./dist/internal/value/equal.js"
107
+ },
108
+ "./value/merge": {
109
+ "types": "./types/value/merge.d.ts",
110
+ "default": "./dist/value/merge.js"
83
111
  }
84
112
  },
85
113
  "files": ["dist", "src", "types"],
@@ -101,5 +129,5 @@
101
129
  },
102
130
  "type": "module",
103
131
  "types": "./types/index.d.ts",
104
- "version": "0.120.0"
132
+ "version": "0.122.0"
105
133
  }
@@ -6,14 +6,11 @@ export * from './filter';
6
6
  export * from './find';
7
7
  export * from './flatten';
8
8
  export * from './get';
9
- export * from './group-by';
10
9
  export * from './index-of';
11
10
  export * from './insert';
12
11
  export * from './models';
13
12
  export * from './push';
14
13
  export * from './sort';
15
14
  export * from './splice';
16
- export * from './to-map';
17
- export * from './to-record';
18
15
  export * from './to-set';
19
16
  export * from './unique';
package/src/index.ts CHANGED
@@ -1,9 +1,13 @@
1
1
  import FRAME_RATE_MS from './internal/frame-rate';
2
2
 
3
3
  export * from './array/index';
4
+ export * from './array/group-by';
5
+ export * from './array/to-map';
6
+ export * from './array/to-record';
4
7
  export * from './beacon';
5
8
  export * from './color/index';
6
9
  export * from './function';
10
+ export * from './internal/value/equal';
7
11
  export * from './is';
8
12
  export * from './logger';
9
13
  export * from './math';
@@ -13,6 +17,9 @@ export * from './query';
13
17
  export * from './random';
14
18
  export * from './sized';
15
19
  export * from './string/index';
20
+ export * from './string/template';
16
21
  export * from './value/index';
22
+ export * from './value/diff';
23
+ export * from './value/merge';
17
24
 
18
25
  export {FRAME_RATE_MS};
@@ -2,4 +2,3 @@ export {getString, join, words} from '../internal/string';
2
2
  export type {PlainObject} from '../models';
3
3
  export * from './case';
4
4
  export * from './misc';
5
- export * from './template';
@@ -1,11 +1,8 @@
1
- export * from '../internal/value/compare';
2
- export * from '../internal/value/equal';
3
- export * from '../internal/value/get';
4
- export * from '../internal/value/set';
1
+ export {compare} from '../internal/value/compare';
2
+ export {getValue} from '../internal/value/get';
3
+ export {setValue} from '../internal/value/set';
5
4
  export type {ArrayOrPlainObject, NestedPartial, PlainObject} from '../models';
6
- export * from './clone';
7
- export * from './diff';
8
- export * from './merge';
9
- export * from './partial';
10
- export * from './smush';
11
- export * from './unsmush';
5
+ export {clone} from './clone';
6
+ export {partial} from './partial';
7
+ export {smush} from './smush';
8
+ export {unsmush} from './unsmush';
@@ -6,14 +6,11 @@ export * from './filter';
6
6
  export * from './find';
7
7
  export * from './flatten';
8
8
  export * from './get';
9
- export * from './group-by';
10
9
  export * from './index-of';
11
10
  export * from './insert';
12
11
  export * from './models';
13
12
  export * from './push';
14
13
  export * from './sort';
15
14
  export * from './splice';
16
- export * from './to-map';
17
- export * from './to-record';
18
15
  export * from './to-set';
19
16
  export * from './unique';
package/types/index.d.ts CHANGED
@@ -1,8 +1,12 @@
1
1
  import FRAME_RATE_MS from './internal/frame-rate';
2
2
  export * from './array/index';
3
+ export * from './array/group-by';
4
+ export * from './array/to-map';
5
+ export * from './array/to-record';
3
6
  export * from './beacon';
4
7
  export * from './color/index';
5
8
  export * from './function';
9
+ export * from './internal/value/equal';
6
10
  export * from './is';
7
11
  export * from './logger';
8
12
  export * from './math';
@@ -12,5 +16,8 @@ export * from './query';
12
16
  export * from './random';
13
17
  export * from './sized';
14
18
  export * from './string/index';
19
+ export * from './string/template';
15
20
  export * from './value/index';
21
+ export * from './value/diff';
22
+ export * from './value/merge';
16
23
  export { FRAME_RATE_MS };
@@ -2,4 +2,3 @@ export { getString, join, words } from '../internal/string';
2
2
  export type { PlainObject } from '../models';
3
3
  export * from './case';
4
4
  export * from './misc';
5
- export * from './template';
@@ -1,11 +1,8 @@
1
- export * from '../internal/value/compare';
2
- export * from '../internal/value/equal';
3
- export * from '../internal/value/get';
4
- export * from '../internal/value/set';
1
+ export { compare } from '../internal/value/compare';
2
+ export { getValue } from '../internal/value/get';
3
+ export { setValue } from '../internal/value/set';
5
4
  export type { ArrayOrPlainObject, NestedPartial, PlainObject } from '../models';
6
- export * from './clone';
7
- export * from './diff';
8
- export * from './merge';
9
- export * from './partial';
10
- export * from './smush';
11
- export * from './unsmush';
5
+ export { clone } from './clone';
6
+ export { partial } from './partial';
7
+ export { smush } from './smush';
8
+ export { unsmush } from './unsmush';