@oscarpalmer/atoms 0.196.0 → 0.197.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.
@@ -7,5 +7,6 @@ function filter(array, ...parameters) {
7
7
  return findValues("all", array, parameters).matched;
8
8
  }
9
9
  filter.remove = exclude;
10
+ Object.defineProperty(filter, "remove", { value: exclude });
10
11
  //#endregion
11
12
  export { exclude, filter };
@@ -3,9 +3,10 @@ import { FIND_VALUE_ITEM, findValue } from "../internal/array/find.mjs";
3
3
  function find(array, ...parameters) {
4
4
  return findValue(FIND_VALUE_ITEM, array, parameters, false);
5
5
  }
6
- find.last = findLast;
7
6
  function findLast(array, ...parameters) {
8
7
  return findValue(FIND_VALUE_ITEM, array, parameters, true);
9
8
  }
9
+ find.last = findLast;
10
+ Object.defineProperty(find, "last", { value: findLast });
10
11
  //#endregion
11
12
  export { find, findLast };
@@ -3,9 +3,10 @@ import { findAbsoluteValueOrDefault } from "../internal/array/find.mjs";
3
3
  function first(array, ...parameters) {
4
4
  return findAbsoluteValueOrDefault(array, parameters, void 0, false, false);
5
5
  }
6
- first.default = firstOrDefault;
7
6
  function firstOrDefault(array, defaultValue, ...parameters) {
8
7
  return findAbsoluteValueOrDefault(array, parameters, defaultValue, true, false);
9
8
  }
9
+ first.default = firstOrDefault;
10
+ Object.defineProperty(first, "default", { value: firstOrDefault });
10
11
  //#endregion
11
12
  export { first, firstOrDefault };
@@ -3,9 +3,10 @@ import { groupValues } from "../internal/array/group.mjs";
3
3
  function groupBy(array, first, second) {
4
4
  return groupValues(array, first, second, false);
5
5
  }
6
- groupBy.arrays = groupArraysBy;
7
6
  function groupArraysBy(array, first, second) {
8
7
  return groupValues(array, first, second, true);
9
8
  }
9
+ groupBy.arrays = groupArraysBy;
10
+ Object.defineProperty(groupBy, "arrays", { value: groupArraysBy });
10
11
  //#endregion
11
12
  export { groupArraysBy, groupBy };
@@ -3,9 +3,10 @@ import { findAbsoluteValueOrDefault } from "../internal/array/find.mjs";
3
3
  function last(array, ...parameters) {
4
4
  return findAbsoluteValueOrDefault(array, parameters, void 0, false, true);
5
5
  }
6
- last.default = lastOrDefault;
7
6
  function lastOrDefault(array, defaultValue, ...parameters) {
8
7
  return findAbsoluteValueOrDefault(array, parameters, defaultValue, true, true);
9
8
  }
9
+ last.default = lastOrDefault;
10
+ Object.defineProperty(last, "default", { value: lastOrDefault });
10
11
  //#endregion
11
12
  export { last, lastOrDefault };
@@ -23,8 +23,6 @@ function move(array, from, to, key) {
23
23
  else array.splice(next, 0, ...firstArray);
24
24
  return array;
25
25
  }
26
- move.indices = moveIndices;
27
- move.toIndex = moveToIndex;
28
26
  /**
29
27
  * Move an item from one index to another within an array
30
28
  *
@@ -72,5 +70,11 @@ function moveToIndex(array, value, index, key) {
72
70
  else array.splice(next, 0, ...values);
73
71
  return array;
74
72
  }
73
+ move.indices = moveIndices;
74
+ move.toIndex = moveToIndex;
75
+ Object.defineProperties(move, {
76
+ indices: { value: moveIndices },
77
+ toIndex: { value: moveToIndex }
78
+ });
75
79
  //#endregion
76
80
  export { move, moveIndices, moveToIndex };
@@ -126,9 +126,6 @@ function sortArray(array, sorters) {
126
126
  const { length } = sorters;
127
127
  return array.length > 1 ? array.sort((first, second) => getComparisonValue(first, second, sorters, length)) : array;
128
128
  }
129
- sort.getIndex = getSortedIndex;
130
- sort.initialize = initializeSorter;
131
- sort.is = isSorted;
132
129
  const SORT_PEEK_PERCENTAGE = 10;
133
130
  const SORT_THRESHOLD = 100;
134
131
  const SORT_DIRECTION_ASCENDING = "ascending";
@@ -137,5 +134,13 @@ const modifiers = {
137
134
  [SORT_DIRECTION_ASCENDING]: 1,
138
135
  [SORT_DIRECTION_DESCENDING]: -1
139
136
  };
137
+ sort.getIndex = getSortedIndex;
138
+ sort.initialize = initializeSorter;
139
+ sort.is = isSorted;
140
+ Object.defineProperties(sort, {
141
+ getIndex: { value: getSortedIndex },
142
+ initialize: { value: initializeSorter },
143
+ is: { value: isSorted }
144
+ });
140
145
  //#endregion
141
146
  export { SORT_DIRECTION_ASCENDING, SORT_DIRECTION_DESCENDING, getSortedIndex, initializeSorter, isSorted, sort };
@@ -9,7 +9,6 @@ function swap(array, first, second, third) {
9
9
  if (Array.isArray(first) && Array.isArray(second)) return swapArrays(array, first, second, third);
10
10
  return swapValues(array, first, second, third);
11
11
  }
12
- swap.indices = swapIndices;
13
12
  function swapArrays(array, from, to, key) {
14
13
  if (from.length === 0 || to.length === 0) return array;
15
14
  if (from.length === 1 && to.length === 1) return swapValues(array, from[0], to[0], key);
@@ -58,5 +57,7 @@ function swapValues(array, from, to, key) {
58
57
  if (first === second || first === -1 || second === -1) return array;
59
58
  return swapIndices(array, first, second);
60
59
  }
60
+ swap.indices = swapIndices;
61
+ Object.defineProperty(swap, "indices", { value: swapIndices });
61
62
  //#endregion
62
63
  export { swap };
@@ -20,9 +20,10 @@ function getMapValues(array, first, second, arrays) {
20
20
  function toMap(array, first, second) {
21
21
  return getMapValues(array, first, second, false);
22
22
  }
23
- toMap.arrays = toMapArrays;
24
23
  function toMapArrays(array, first, second) {
25
24
  return getMapValues(array, first, second, true);
26
25
  }
26
+ toMap.arrays = toMapArrays;
27
+ Object.defineProperty(toMap, "arrays", { value: toMapArrays });
27
28
  //#endregion
28
29
  export { toMap, toMapArrays };
@@ -3,9 +3,10 @@ import { groupValues } from "../internal/array/group.mjs";
3
3
  function toRecord(array, first, second) {
4
4
  return groupValues(array, first, second, false);
5
5
  }
6
- toRecord.arrays = toRecordArrays;
7
6
  function toRecordArrays(array, first, second) {
8
7
  return groupValues(array, first, second, true);
9
8
  }
9
+ toRecord.arrays = toRecordArrays;
10
+ Object.defineProperty(toRecord, "arrays", { value: toRecordArrays });
10
11
  //#endregion
11
12
  export { toRecord, toRecordArrays };
package/dist/index.d.mts CHANGED
@@ -4658,12 +4658,12 @@ type Comparator<Value = any> = (first: Value, second: Value) => number;
4658
4658
  */
4659
4659
  declare function compare(first: unknown, second: unknown): number;
4660
4660
  declare namespace compare {
4661
+ var deregister: typeof deregisterComparator;
4661
4662
  var handlers: {
4662
4663
  deregister(constructor: Constructor): void;
4663
4664
  handle(first: unknown, second: unknown, ...parameters: unknown[]): number;
4664
4665
  register(constructor: Constructor, handler?: string | GenericCallback): void;
4665
4666
  };
4666
- var deregister: typeof deregisterComparator;
4667
4667
  var register: typeof registerComparator;
4668
4668
  }
4669
4669
  /**
@@ -6175,6 +6175,20 @@ declare namespace template {
6175
6175
  }
6176
6176
  //#endregion
6177
6177
  //#region src/value/clone.d.ts
6178
+ type CloneOptions = {
6179
+ /**
6180
+ * Copy functions instead of returning `undefined`? _(defaults to `false`)_
6181
+ */
6182
+ copyFunctions?: boolean;
6183
+ /**
6184
+ * Copy symbols instead of returning `Symbol(description)`? _(defaults to `false`)_
6185
+ */
6186
+ copySymbols?: boolean;
6187
+ /**
6188
+ * Clone only the value itself, without cloning nested values? _(defaults to `false`)_
6189
+ */
6190
+ flat?: boolean;
6191
+ };
6178
6192
  /**
6179
6193
  * Clone any kind of value _(shallowly)_
6180
6194
  *
@@ -6187,13 +6201,14 @@ declare function clone<Value>(value: Value, flat: true): Value;
6187
6201
  * Clone any kind of value _(deeply, if needed)_
6188
6202
  *
6189
6203
  * @param value Value to clone
6204
+ * @param options Clone options
6190
6205
  * @returns Cloned value
6191
6206
  */
6192
- declare function clone<Value>(value: Value): Value;
6207
+ declare function clone<Value>(value: Value, options?: CloneOptions): Value;
6193
6208
  declare namespace clone {
6194
6209
  var handlers: {
6195
6210
  deregister(constructor: Constructor): void;
6196
- handle(value: unknown, ...parameters: unknown[]): any;
6211
+ handle(value: unknown, ...parameters: unknown[]): unknown;
6197
6212
  register(constructor: Constructor, handler?: string | GenericCallback): void;
6198
6213
  };
6199
6214
  var deregister: typeof deregisterCloner;
@@ -7885,7 +7900,7 @@ declare function max<Item>(items: Item[], callback: (item: Item, index: number,
7885
7900
  * @param first Return only the first item with the maximum value
7886
7901
  * @returns Item with the maximum value, or `undefined` if no maximum can be found
7887
7902
  */
7888
- declare function max<Item extends PlainObject, ItemKey extends keyof NumericalValues<Item>>(items: Item[], key: ItemKey, first: true): Item | undefined;
7903
+ declare function max<Item extends PlainObject>(items: Item[], key: keyof NumericalValues<Item>, first: true): Item | undefined;
7889
7904
  /**
7890
7905
  * Get the maximum value from a list of items
7891
7906
  *
@@ -7921,7 +7936,7 @@ declare function max<Item>(items: Item[], callback: (item: Item, index: number,
7921
7936
  * @param key Key to use for value
7922
7937
  * @returns Items with the maximum value
7923
7938
  */
7924
- declare function max<Item extends PlainObject, ItemKey extends keyof NumericalValues<Item>>(items: Item[], key: ItemKey): Item[];
7939
+ declare function max<Item extends PlainObject>(items: Item[], key: keyof NumericalValues<Item>): Item[];
7925
7940
  /**
7926
7941
  * Get the maximum value from a list of numbers
7927
7942
  *
@@ -8040,18 +8055,18 @@ declare function median(array: number[]): number;
8040
8055
  * @param items List of items
8041
8056
  * @param callback Callback to get an item's value
8042
8057
  * @param first Return only the first item with the minimum value
8043
- * @returns Items with the minimum value
8058
+ * @returns First item with the minimum value, or `undefined` if no minimum can be found
8044
8059
  */
8045
- declare function min<Item>(items: Item[], callback: (item: Item, index: number, array: Item[]) => number, first: true): Item[];
8060
+ declare function min<Item>(items: Item[], callback: (item: Item, index: number, array: Item[]) => number, first: true): Item | undefined;
8046
8061
  /**
8047
8062
  * Get the minimum value from a list of items
8048
8063
  *
8049
8064
  * @param items List of items
8050
8065
  * @param key Key to use for value
8051
8066
  * @param first Return only the first item with the minimum value
8052
- * @returns Items with the minimum value
8067
+ * @returns First item with the minimum value, or `undefined` if no minimum can be found
8053
8068
  */
8054
- declare function min<Item extends PlainObject>(items: Item[], key: keyof NumericalValues<Item>, first: true): Item[];
8069
+ declare function min<Item extends PlainObject>(items: Item[], key: keyof NumericalValues<Item>, first: true): Item | undefined;
8055
8070
  /**
8056
8071
  * Get the minimum value from a list of items
8057
8072
  *
@@ -8517,4 +8532,4 @@ declare class SizedSet<Value = unknown> extends Set<Value> {
8517
8532
  get(value: Value, update?: boolean): Value | undefined;
8518
8533
  }
8519
8534
  //#endregion
8520
- export { AnyResult, ArrayComparison, ArrayComparisonSorter, ArrayKeySorter, ArrayOrPlainObject, ArraySorter, ArraySorters, ArrayValueSorter, AssertProperty, Asserter, AssignOptions, Assigner, AsyncCancelableCallback, AttemptFlow, AttemptFlowPromise, Beacon, BeaconOptions, BuiltIns, CancelableCallback, CancelablePromise, type Color, type ColorType, type ColorTypeExtended, type ColorValue, type ColorValueExtended, Constructor, DiffOptions, DiffResult, DiffValue, EqualOptions, Err, ExtendedErr, ExtendedResult, Flow, FlowPromise, Frozen, FulfilledPromise, Fuzzy, FuzzyConfiguration, FuzzyOptions, FuzzyResult, FuzzySearchOptions, GenericAsyncCallback, GenericCallback, type HSLAColor, type HSLColor, type HWBAColor, type HWBColor, Key$1 as Key, KeyedQueue, KeyedValue, Logger, Memoized, MemoizedOptions, MergeOptions, Merger, NestedArray, NestedKeys, NestedPartial, NestedValue, NestedValues, NormalizeOptions, Normalizer, NumericalKeys, NumericalValues, Observable, Ok, OnceAsyncCallback, OnceCallback, PlainObject, Primitive, PromiseData, PromiseHandlers, PromiseOptions, PromiseParameters, PromiseStrategy, PromiseTimeoutError, PromisesItems, PromisesOptions, PromisesResult, PromisesUnwrapped, PromisesValue, PromisesValues, Queue, QueueError, QueueOptions, Queued, type RGBAColor, type RGBColor, RejectedPromise, RequiredKeys, Result, ResultMatch, RetryError, RetryOptions, SORT_DIRECTION_ASCENDING, SORT_DIRECTION_DESCENDING, type Shaken, Simplify, SizedMap, SizedSet, type Smushed, SortDirection, Sorter, type Subscription, TemplateOptions, type TimedLogger, ToString, Transformer, TypedArray, UnionToIntersection, type Unsmushed, Unsubscriber, UnwrapValue, assert, assertCondition, assertDefined, assertInstanceOf, assertIs, assertProperty, assign, asyncAttempt, asyncDebounce, asyncFlow, asyncMatchResult, asyncOnce, asyncPipe, asyncThrottle, attempt, attemptAsyncFlow, attemptAsyncPipe, attemptFlow, attemptPipe, attemptPromise, average, beacon, between, camelCase, cancelable, capitalize, ceil, chunk, clamp, clone, compact, compare, copy, count, debounce, deburr, dedent, delay, deregisterCloner, deregisterComparator, deregisterEqualizer, diff, difference, drop, endsWith, endsWithArray, equal, error, exclude, exists, filter, find, findLast, first, firstOrDefault, flatFreeze, flatten, floor, flow, freeze, fromQuery, toPromise as fromResult, toPromise, fuzzy, fuzzyMatch, getArray, getArrayComparison, getColor, getForegroundColor, getHexColor, getHexaColor, getHslColor, getHslaColor, getHwbColor, getHwbaColor, getNormalizedHex, getNumber, getRandomBoolean, getRandomCharacters, getRandomColor, getRandomFloatingNumber as getRandomFloat, getRandomHex, getRandomInteger, getRandomItem, getRandomItems, getRgbColor, getRgbaColor, getSortedIndex, getString, getTimedPromise, getUuid, getValue, groupArraysBy, groupBy, handleResult, hasValue, hasValueResult, herald, hexToHsl, hexToHsla, hexToHwb, hexToHwba, hexToRgb, hexToRgba, hslToHex, hslToHwb, hslToHwba, hslToRgb, hslToRgba, hwbToHex, hwbToHsl, hwbToHsla, hwbToRgb, hwbToRgba, ignoreKey, inMap, inSet, includes, includesArray, indexOf, indexOfArray, initializeAssigner, initializeEqualizer, initializeMerger, initializeNormalizer, initializeSorter, initializeTemplater, initializeTransformer, insert, interpolate, intersection, isArrayOrPlainObject, isBeacon, isBeaconSubscription, isColor, isConstructor, isEmpty, isError, isFrozen, isFulfilled, isHerald, isHeraldEvents, isHeraldSubscription, isHexColor, isHslColor, isHslaColor, isHwbColor, isHwbaColor, isInstanceOf, isKey, isKeyedQueue, isLogger, isNonArrayOrPlainObject, isNonConstructor, isNonEmpty, isNonInstanceOf, isNonKey, isNonNullable, isNonNullableOrEmpty, isNonNullableOrWhitespace, isNonNumber, isNonNumerical, isNonObject, isNonPlainObject, isNonPrimitive, isNonTypedArray, isNullable, isNullableOrEmpty, isNullableOrWhitespace, isNumber, isNumerical, isObject, isObservable, isOk, isPlainObject, isPrimitive, isQueue, isQueueInstance, isRejected, isResult, isRgbColor, isRgbaColor, isSorted, isSubscription, isTimedLogger, isTypedArray, join, kebabCase, keyedQueue, last, lastIndexOf, lastOrDefault, lowerCase, matchResult, max, median, memoize, merge, min, move, moveIndices, moveToIndex, noop, normalize, ok, omit, once, parse, partition, pascalCase, pick, pipe, promises, push, queue, range, registerCloner, registerComparator, registerEqualizer, resultPromises, retry, reverse, rgbToHex, rgbToHsl, rgbToHsla, rgbToHwb, rgbToHwba, round, select, setValue, settlePromise, shake, shuffle, single, slice, smush, snakeCase, sort, splice, startsWith, startsWithArray, sum, swap, take, template, throttle, timed, times, titleCase, toMap, toMapArrays, toQuery, toRecord, toRecordArrays, toResult, toSet, toggle, transform, trim, truncate, tryDecode, tryEncode, union, unique, unsmush, unwrap, update, upperCase, words };
8535
+ export { AnyResult, ArrayComparison, ArrayComparisonSorter, ArrayKeySorter, ArrayOrPlainObject, ArraySorter, ArraySorters, ArrayValueSorter, AssertProperty, Asserter, AssignOptions, Assigner, AsyncCancelableCallback, AttemptFlow, AttemptFlowPromise, Beacon, BeaconOptions, BuiltIns, CancelableCallback, CancelablePromise, CloneOptions, type Color, type ColorType, type ColorTypeExtended, type ColorValue, type ColorValueExtended, Constructor, DiffOptions, DiffResult, DiffValue, EqualOptions, Err, ExtendedErr, ExtendedResult, Flow, FlowPromise, Frozen, FulfilledPromise, Fuzzy, FuzzyConfiguration, FuzzyOptions, FuzzyResult, FuzzySearchOptions, GenericAsyncCallback, GenericCallback, type HSLAColor, type HSLColor, type HWBAColor, type HWBColor, Key$1 as Key, KeyedQueue, KeyedValue, Logger, Memoized, MemoizedOptions, MergeOptions, Merger, NestedArray, NestedKeys, NestedPartial, NestedValue, NestedValues, NormalizeOptions, Normalizer, NumericalKeys, NumericalValues, Observable, Ok, OnceAsyncCallback, OnceCallback, PlainObject, Primitive, PromiseData, PromiseHandlers, PromiseOptions, PromiseParameters, PromiseStrategy, PromiseTimeoutError, PromisesItems, PromisesOptions, PromisesResult, PromisesUnwrapped, PromisesValue, PromisesValues, Queue, QueueError, QueueOptions, Queued, type RGBAColor, type RGBColor, RejectedPromise, RequiredKeys, Result, ResultMatch, RetryError, RetryOptions, SORT_DIRECTION_ASCENDING, SORT_DIRECTION_DESCENDING, type Shaken, Simplify, SizedMap, SizedSet, type Smushed, SortDirection, Sorter, type Subscription, TemplateOptions, type TimedLogger, ToString, Transformer, TypedArray, UnionToIntersection, type Unsmushed, Unsubscriber, UnwrapValue, assert, assertCondition, assertDefined, assertInstanceOf, assertIs, assertProperty, assign, asyncAttempt, asyncDebounce, asyncFlow, asyncMatchResult, asyncOnce, asyncPipe, asyncThrottle, attempt, attemptAsyncFlow, attemptAsyncPipe, attemptFlow, attemptPipe, attemptPromise, average, beacon, between, camelCase, cancelable, capitalize, ceil, chunk, clamp, clone, compact, compare, copy, count, debounce, deburr, dedent, delay, deregisterCloner, deregisterComparator, deregisterEqualizer, diff, difference, drop, endsWith, endsWithArray, equal, error, exclude, exists, filter, find, findLast, first, firstOrDefault, flatFreeze, flatten, floor, flow, freeze, fromQuery, toPromise as fromResult, toPromise, fuzzy, fuzzyMatch, getArray, getArrayComparison, getColor, getForegroundColor, getHexColor, getHexaColor, getHslColor, getHslaColor, getHwbColor, getHwbaColor, getNormalizedHex, getNumber, getRandomBoolean, getRandomCharacters, getRandomColor, getRandomFloatingNumber as getRandomFloat, getRandomHex, getRandomInteger, getRandomItem, getRandomItems, getRgbColor, getRgbaColor, getSortedIndex, getString, getTimedPromise, getUuid, getValue, groupArraysBy, groupBy, handleResult, hasValue, hasValueResult, herald, hexToHsl, hexToHsla, hexToHwb, hexToHwba, hexToRgb, hexToRgba, hslToHex, hslToHwb, hslToHwba, hslToRgb, hslToRgba, hwbToHex, hwbToHsl, hwbToHsla, hwbToRgb, hwbToRgba, ignoreKey, inMap, inSet, includes, includesArray, indexOf, indexOfArray, initializeAssigner, initializeEqualizer, initializeMerger, initializeNormalizer, initializeSorter, initializeTemplater, initializeTransformer, insert, interpolate, intersection, isArrayOrPlainObject, isBeacon, isBeaconSubscription, isColor, isConstructor, isEmpty, isError, isFrozen, isFulfilled, isHerald, isHeraldEvents, isHeraldSubscription, isHexColor, isHslColor, isHslaColor, isHwbColor, isHwbaColor, isInstanceOf, isKey, isKeyedQueue, isLogger, isNonArrayOrPlainObject, isNonConstructor, isNonEmpty, isNonInstanceOf, isNonKey, isNonNullable, isNonNullableOrEmpty, isNonNullableOrWhitespace, isNonNumber, isNonNumerical, isNonObject, isNonPlainObject, isNonPrimitive, isNonTypedArray, isNullable, isNullableOrEmpty, isNullableOrWhitespace, isNumber, isNumerical, isObject, isObservable, isOk, isPlainObject, isPrimitive, isQueue, isQueueInstance, isRejected, isResult, isRgbColor, isRgbaColor, isSorted, isSubscription, isTimedLogger, isTypedArray, join, kebabCase, keyedQueue, last, lastIndexOf, lastOrDefault, lowerCase, matchResult, max, median, memoize, merge, min, move, moveIndices, moveToIndex, noop, normalize, ok, omit, once, parse, partition, pascalCase, pick, pipe, promises, push, queue, range, registerCloner, registerComparator, registerEqualizer, resultPromises, retry, reverse, rgbToHex, rgbToHsl, rgbToHsla, rgbToHwb, rgbToHwba, round, select, setValue, settlePromise, shake, shuffle, single, slice, smush, snakeCase, sort, splice, startsWith, startsWithArray, sum, swap, take, template, throttle, timed, times, titleCase, toMap, toMapArrays, toQuery, toRecord, toRecordArrays, toResult, toSet, toggle, transform, trim, truncate, tryDecode, tryEncode, union, unique, unsmush, unwrap, update, upperCase, words };