@oscarpalmer/atoms 0.166.3 → 0.168.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.
package/dist/index.mjs CHANGED
@@ -538,6 +538,146 @@ function take(array, first, second) {
538
538
  const EXTRACT_DROP = "drop";
539
539
  const EXTRACT_TAKE = "take";
540
540
  //#endregion
541
+ //#region src/array/splice.ts
542
+ function splice(array, start, deleteCountOrItems, items) {
543
+ return insertValues(INSERT_TYPE_SPLICE, array, typeof deleteCountOrItems === "number" ? items : deleteCountOrItems, start, typeof deleteCountOrItems === "number" ? deleteCountOrItems : 0);
544
+ }
545
+ //#endregion
546
+ //#region src/array/to-set.ts
547
+ function toSet(array, value) {
548
+ if (!Array.isArray(array)) return /* @__PURE__ */ new Set();
549
+ const callbacks = getArrayCallbacks(void 0, void 0, value);
550
+ if (callbacks?.value == null) return new Set(array);
551
+ const { length } = array;
552
+ const set = /* @__PURE__ */ new Set();
553
+ for (let index = 0; index < length; index += 1) set.add(callbacks.value(array[index], index, array));
554
+ return set;
555
+ }
556
+ //#endregion
557
+ //#region src/internal/array/update.ts
558
+ function updateInArray(array, items, key, replace) {
559
+ if (!Array.isArray(array)) return [];
560
+ const itemsIsArray = Array.isArray(items);
561
+ if (array.length === 0 || !itemsIsArray) {
562
+ if (itemsIsArray) array.push(...items);
563
+ return array;
564
+ }
565
+ const { length } = items;
566
+ if (length === 0) return array;
567
+ const callback = getArrayCallback(key);
568
+ for (let valuesIndex = 0; valuesIndex < length; valuesIndex += 1) {
569
+ const item = items[valuesIndex];
570
+ const value = callback?.(item) ?? item;
571
+ const arrayIndex = callback == null ? array.indexOf(value) : array.findIndex((arrayItem, arrayIndex) => callback(arrayItem, arrayIndex, array) === value);
572
+ if (arrayIndex === -1) array.push(item);
573
+ else if (replace) array[arrayIndex] = item;
574
+ else array.splice(arrayIndex, 1);
575
+ }
576
+ return array;
577
+ }
578
+ //#endregion
579
+ //#region src/array/toggle.ts
580
+ function toggle(array, values, key) {
581
+ return updateInArray(array, values, key, false);
582
+ }
583
+ //#endregion
584
+ //#region src/array/union.ts
585
+ function union(first, second, key) {
586
+ return compareSets(COMPARE_SETS_UNION, first, second, key);
587
+ }
588
+ //#endregion
589
+ //#region src/array/unique.ts
590
+ function unique(array, key) {
591
+ if (!Array.isArray(array)) return [];
592
+ return array.length > 1 ? findValues(FIND_VALUES_UNIQUE, array, [key, void 0]).matched : array;
593
+ }
594
+ //#endregion
595
+ //#region src/array/update.ts
596
+ function update(array, values, key) {
597
+ return updateInArray(array, values, key, true);
598
+ }
599
+ //#endregion
600
+ //#region src/internal/array/overlap.ts
601
+ function arraysOverlap(first, second) {
602
+ const firstArray = first.index < second.index ? first.array : second.array;
603
+ const secondArray = first.index < second.index ? second.array : first.array;
604
+ const firstIndex = firstArray === first.array ? first.index : second.index;
605
+ const secondIndex = firstArray === first.array ? second.index : first.index;
606
+ const firstEnd = firstIndex + firstArray.length - 1;
607
+ return {
608
+ overlap: firstIndex <= secondIndex + secondArray.length - 1 && firstEnd >= secondIndex,
609
+ first: {
610
+ array: firstArray,
611
+ index: firstIndex
612
+ },
613
+ second: {
614
+ array: secondArray,
615
+ index: secondIndex
616
+ }
617
+ };
618
+ }
619
+ //#endregion
620
+ //#region src/array/move.ts
621
+ function move(array, from, to, key) {
622
+ if (!Array.isArray(array)) return [];
623
+ const firstArray = Array.isArray(from) ? from : [from];
624
+ const secondArray = Array.isArray(to) ? to : [to];
625
+ if (firstArray.length === 0 || secondArray.length === 0) return array;
626
+ const firstPosition = indexOfArray(array, firstArray, key);
627
+ const secondPosition = indexOfArray(array, secondArray, key);
628
+ if (firstPosition === -1 || secondPosition === -1 || firstPosition === secondPosition) return array;
629
+ const { overlap } = arraysOverlap({
630
+ array: firstArray,
631
+ index: firstPosition
632
+ }, {
633
+ array: secondArray,
634
+ index: secondPosition
635
+ });
636
+ if (overlap) return array;
637
+ array.splice(firstPosition, firstArray.length);
638
+ const next = secondPosition < firstPosition ? secondPosition : secondPosition + secondArray.length - firstArray.length;
639
+ if (next >= array.length) array.push(...firstArray);
640
+ else array.splice(next, 0, ...firstArray);
641
+ return array;
642
+ }
643
+ move.indices = moveIndices;
644
+ move.toIndex = moveToIndex;
645
+ /**
646
+ * Move an item from one index to another within an array
647
+ *
648
+ * If the from index is out of bounds, the array will be returned unchanged
649
+ * @param array Array to move within
650
+ * @param from Index to move from
651
+ * @param to Index to move to
652
+ * @returns Original array with item moved _(or unchanged if unable to move)_
653
+ */
654
+ function moveIndices(array, from, to) {
655
+ if (!Array.isArray(array)) return [];
656
+ const { length } = array;
657
+ if (length === 0 || typeof from !== "number" || typeof to !== "number") return array;
658
+ const fromIndex = from < 0 ? length + from : from;
659
+ const toIndex = to < 0 ? length + to : to;
660
+ if (fromIndex === toIndex || fromIndex >= length || toIndex >= length) return array;
661
+ const spliced = array.splice(fromIndex, 1);
662
+ if (toIndex >= array.length) array.push(...spliced);
663
+ else array.splice(toIndex, 0, ...spliced);
664
+ return array;
665
+ }
666
+ function moveToIndex(array, value, index, key) {
667
+ if (!Array.isArray(array)) return [];
668
+ const { length } = array;
669
+ if (length === 0 || typeof index !== "number") return array;
670
+ const next = index < 0 ? length + index : index;
671
+ if (next >= length) return array;
672
+ const values = Array.isArray(value) ? value : [value];
673
+ const position = indexOfArray(array, values, key);
674
+ if (position === -1 || position === next) return array;
675
+ array.splice(position, values.length);
676
+ if (next >= array.length) array.push(...values);
677
+ else array.splice(next, 0, ...values);
678
+ return array;
679
+ }
680
+ //#endregion
541
681
  //#region src/internal/math/aggregate.ts
542
682
  function aggregate(type, array, key) {
543
683
  const length = Array.isArray(array) ? array.length : 0;
@@ -770,6 +910,9 @@ function getComparisonSorter(callback, modifier) {
770
910
  identifier: String(callback)
771
911
  };
772
912
  }
913
+ function getModifier(first, second) {
914
+ return modifiers[first === true || second === true ? SORT_DIRECTION_DESCENDING : SORT_DIRECTION_ASCENDING];
915
+ }
773
916
  function getObjectSorter(obj, modifier) {
774
917
  let sorter;
775
918
  if (typeof obj.comparison === "function") sorter = getComparisonSorter(obj.comparison, modifier);
@@ -788,6 +931,17 @@ function getSorter(value, modifier) {
788
931
  default: break;
789
932
  }
790
933
  }
934
+ function getSorters(value, modifier) {
935
+ const array = Array.isArray(value) ? value : [value];
936
+ const { length } = array;
937
+ const sorters = [];
938
+ for (let index = 0; index < length; index += 1) {
939
+ const item = array[index];
940
+ const sorter = getSorter(item, modifier);
941
+ if (sorter != null) sorters.push(sorter);
942
+ }
943
+ return sorters.filter((value, index, array) => array.findIndex((next) => next.identifier === value.identifier) === index);
944
+ }
791
945
  function getValueSorter(value, modifier) {
792
946
  return {
793
947
  modifier,
@@ -796,32 +950,31 @@ function getValueSorter(value, modifier) {
796
950
  value: typeof value === "function" ? value : (item) => item[value]
797
951
  };
798
952
  }
953
+ function initializeSort(first, second) {
954
+ const modifier = getModifier(first, second);
955
+ const sorters = getSorters(first, modifier);
956
+ return (array) => work$1(array, sorters, modifier);
957
+ }
799
958
  function sort(array, first, second) {
959
+ const modifier = getModifier(first, second);
960
+ return work$1(array, getSorters(first, modifier), modifier);
961
+ }
962
+ function work$1(array, sorters, modifier) {
800
963
  if (!Array.isArray(array)) return [];
801
964
  if (array.length < 2) return array;
802
- const modifier = modifiers[first === true || second === true ? SORT_DIRECTION_DESCENDING : SORT_DIRECTION_ASCENDING];
803
- const sorters = (Array.isArray(first) ? first : [first]).map((item) => getSorter(item, modifier)).filter((sorter) => sorter != null).filter((current, index, filtered) => filtered.findIndex((next) => next.identifier === current.identifier) === index);
804
965
  const { length } = sorters;
805
966
  if (length === 0) return array.sort((first, second) => compare(first, second) * modifier);
806
- if (length === 1) {
807
- const sorter = sorters[0];
808
- return array.sort((firstItem, secondItem) => {
809
- const firstValue = sorter.get ? sorter.value(firstItem) : firstItem;
810
- const secondValue = sorter.get ? sorter.value(secondItem) : secondItem;
811
- return (sorter.compare?.complex?.(firstItem, firstValue, secondItem, secondValue) ?? sorter.compare?.simple?.(firstItem, secondItem) ?? compare(firstValue, secondValue)) * sorter.modifier;
812
- });
813
- }
814
- return array.sort((firstItem, secondItem) => {
967
+ return array.sort((first, second) => {
815
968
  for (let index = 0; index < length; index += 1) {
816
969
  const sorter = sorters[index];
817
- const firstValue = sorter.value?.(firstItem) ?? firstItem;
818
- const secondValue = sorter.value?.(secondItem) ?? secondItem;
819
- const comparison = (sorter.compare?.complex?.(firstItem, firstValue, secondItem, secondValue) ?? sorter.compare?.simple?.(firstItem, secondItem) ?? compare(firstValue, secondValue)) * sorter.modifier;
970
+ const values = [sorter.get ? sorter.value(first) : first, sorter.get ? sorter.value(second) : second];
971
+ const comparison = (sorter.compare?.complex?.(first, values[0], second, values[1]) ?? sorter.compare?.simple?.(values[0], values[1]) ?? compare(values[0], values[1])) * sorter.modifier;
820
972
  if (comparison !== 0) return comparison;
821
973
  }
822
974
  return 0;
823
975
  });
824
976
  }
977
+ sort.initialize = initializeSort;
825
978
  const SORT_DIRECTION_ASCENDING = "ascending";
826
979
  const SORT_DIRECTION_DESCENDING = "descending";
827
980
  const modifiers = {
@@ -829,146 +982,6 @@ const modifiers = {
829
982
  [SORT_DIRECTION_DESCENDING]: -1
830
983
  };
831
984
  //#endregion
832
- //#region src/array/splice.ts
833
- function splice(array, start, deleteCountOrItems, items) {
834
- return insertValues(INSERT_TYPE_SPLICE, array, typeof deleteCountOrItems === "number" ? items : deleteCountOrItems, start, typeof deleteCountOrItems === "number" ? deleteCountOrItems : 0);
835
- }
836
- //#endregion
837
- //#region src/array/to-set.ts
838
- function toSet(array, value) {
839
- if (!Array.isArray(array)) return /* @__PURE__ */ new Set();
840
- const callbacks = getArrayCallbacks(void 0, void 0, value);
841
- if (callbacks?.value == null) return new Set(array);
842
- const { length } = array;
843
- const set = /* @__PURE__ */ new Set();
844
- for (let index = 0; index < length; index += 1) set.add(callbacks.value(array[index], index, array));
845
- return set;
846
- }
847
- //#endregion
848
- //#region src/internal/array/update.ts
849
- function updateInArray(array, items, key, replace) {
850
- if (!Array.isArray(array)) return [];
851
- const itemsIsArray = Array.isArray(items);
852
- if (array.length === 0 || !itemsIsArray) {
853
- if (itemsIsArray) array.push(...items);
854
- return array;
855
- }
856
- const { length } = items;
857
- if (length === 0) return array;
858
- const callback = getArrayCallback(key);
859
- for (let valuesIndex = 0; valuesIndex < length; valuesIndex += 1) {
860
- const item = items[valuesIndex];
861
- const value = callback?.(item) ?? item;
862
- const arrayIndex = callback == null ? array.indexOf(value) : array.findIndex((arrayItem, arrayIndex) => callback(arrayItem, arrayIndex, array) === value);
863
- if (arrayIndex === -1) array.push(item);
864
- else if (replace) array[arrayIndex] = item;
865
- else array.splice(arrayIndex, 1);
866
- }
867
- return array;
868
- }
869
- //#endregion
870
- //#region src/array/toggle.ts
871
- function toggle(array, values, key) {
872
- return updateInArray(array, values, key, false);
873
- }
874
- //#endregion
875
- //#region src/array/union.ts
876
- function union(first, second, key) {
877
- return compareSets(COMPARE_SETS_UNION, first, second, key);
878
- }
879
- //#endregion
880
- //#region src/array/unique.ts
881
- function unique(array, key) {
882
- if (!Array.isArray(array)) return [];
883
- return array.length > 1 ? findValues(FIND_VALUES_UNIQUE, array, [key, void 0]).matched : array;
884
- }
885
- //#endregion
886
- //#region src/array/update.ts
887
- function update(array, values, key) {
888
- return updateInArray(array, values, key, true);
889
- }
890
- //#endregion
891
- //#region src/internal/array/overlap.ts
892
- function arraysOverlap(first, second) {
893
- const firstArray = first.index < second.index ? first.array : second.array;
894
- const secondArray = first.index < second.index ? second.array : first.array;
895
- const firstIndex = firstArray === first.array ? first.index : second.index;
896
- const secondIndex = firstArray === first.array ? second.index : first.index;
897
- const firstEnd = firstIndex + firstArray.length - 1;
898
- return {
899
- overlap: firstIndex <= secondIndex + secondArray.length - 1 && firstEnd >= secondIndex,
900
- first: {
901
- array: firstArray,
902
- index: firstIndex
903
- },
904
- second: {
905
- array: secondArray,
906
- index: secondIndex
907
- }
908
- };
909
- }
910
- //#endregion
911
- //#region src/array/move.ts
912
- function move(array, from, to, key) {
913
- if (!Array.isArray(array)) return [];
914
- const firstArray = Array.isArray(from) ? from : [from];
915
- const secondArray = Array.isArray(to) ? to : [to];
916
- if (firstArray.length === 0 || secondArray.length === 0) return array;
917
- const firstPosition = indexOfArray(array, firstArray, key);
918
- const secondPosition = indexOfArray(array, secondArray, key);
919
- if (firstPosition === -1 || secondPosition === -1 || firstPosition === secondPosition) return array;
920
- const { overlap } = arraysOverlap({
921
- array: firstArray,
922
- index: firstPosition
923
- }, {
924
- array: secondArray,
925
- index: secondPosition
926
- });
927
- if (overlap) return array;
928
- array.splice(firstPosition, firstArray.length);
929
- const next = secondPosition < firstPosition ? secondPosition : secondPosition + secondArray.length - firstArray.length;
930
- if (next >= array.length) array.push(...firstArray);
931
- else array.splice(next, 0, ...firstArray);
932
- return array;
933
- }
934
- move.indices = moveIndices;
935
- move.toIndex = moveToIndex;
936
- /**
937
- * Move an item from one index to another within an array
938
- *
939
- * If the from index is out of bounds, the array will be returned unchanged
940
- * @param array Array to move within
941
- * @param from Index to move from
942
- * @param to Index to move to
943
- * @returns Original array with item moved _(or unchanged if unable to move)_
944
- */
945
- function moveIndices(array, from, to) {
946
- if (!Array.isArray(array)) return [];
947
- const { length } = array;
948
- if (length === 0 || typeof from !== "number" || typeof to !== "number") return array;
949
- const fromIndex = from < 0 ? length + from : from;
950
- const toIndex = to < 0 ? length + to : to;
951
- if (fromIndex === toIndex || fromIndex >= length || toIndex >= length) return array;
952
- const spliced = array.splice(fromIndex, 1);
953
- if (toIndex >= array.length) array.push(...spliced);
954
- else array.splice(toIndex, 0, ...spliced);
955
- return array;
956
- }
957
- function moveToIndex(array, value, index, key) {
958
- if (!Array.isArray(array)) return [];
959
- const { length } = array;
960
- if (length === 0 || typeof index !== "number") return array;
961
- const next = index < 0 ? length + index : index;
962
- if (next >= length) return array;
963
- const values = Array.isArray(value) ? value : [value];
964
- const position = indexOfArray(array, values, key);
965
- if (position === -1 || position === next) return array;
966
- array.splice(position, values.length);
967
- if (next >= array.length) array.push(...values);
968
- else array.splice(next, 0, ...values);
969
- return array;
970
- }
971
- //#endregion
972
985
  //#region src/array/swap.ts
973
986
  function swap(array, first, second, third) {
974
987
  if (!Array.isArray(array)) return [];
@@ -3808,7 +3821,7 @@ function isType(value, type) {
3808
3821
  function cancelable(executor) {
3809
3822
  return new CancelablePromise(executor);
3810
3823
  }
3811
- function handleResult$1(status, parameters) {
3824
+ function handleResult(status, parameters) {
3812
3825
  const { abort, complete, data, handlers, index, signal, value } = parameters;
3813
3826
  if (signal?.aborted ?? false) return;
3814
3827
  if (!complete && status === "rejected") {
@@ -3834,6 +3847,28 @@ async function toResult(value) {
3834
3847
  return actual.then((result) => ok(result)).catch((reason) => error(reason));
3835
3848
  }
3836
3849
  //#endregion
3850
+ //#region src/promise/delay.ts
3851
+ function delay(options) {
3852
+ const { signal, time } = getPromiseOptions(options);
3853
+ if (signal?.aborted ?? false) return Promise.reject(signal.reason);
3854
+ function abort() {
3855
+ timer.cancel();
3856
+ rejector(signal.reason);
3857
+ }
3858
+ const timer = getTimer(TIMER_WAIT, () => {
3859
+ settlePromise(abort, resolver, void 0, signal);
3860
+ }, time);
3861
+ signal?.addEventListener(PROMISE_ABORT_EVENT, abort, PROMISE_ABORT_OPTIONS);
3862
+ let rejector;
3863
+ let resolver;
3864
+ return new Promise((resolve, reject) => {
3865
+ rejector = reject;
3866
+ resolver = resolve;
3867
+ if (time === 0) settlePromise(abort, resolve, void 0, signal);
3868
+ else timer();
3869
+ });
3870
+ }
3871
+ //#endregion
3837
3872
  //#region src/promise/timed.ts
3838
3873
  async function getTimedPromise(promise, time, signal) {
3839
3874
  function abort() {
@@ -3862,28 +3897,6 @@ async function timed(promise, options) {
3862
3897
  return time > 0 ? getTimedPromise(promise, time, signal) : promise;
3863
3898
  }
3864
3899
  //#endregion
3865
- //#region src/promise/delay.ts
3866
- function delay(options) {
3867
- const { signal, time } = getPromiseOptions(options);
3868
- if (signal?.aborted ?? false) return Promise.reject(signal.reason);
3869
- function abort() {
3870
- timer.cancel();
3871
- rejector(signal.reason);
3872
- }
3873
- const timer = getTimer(TIMER_WAIT, () => {
3874
- settlePromise(abort, resolver, void 0, signal);
3875
- }, time);
3876
- signal?.addEventListener(PROMISE_ABORT_EVENT, abort, PROMISE_ABORT_OPTIONS);
3877
- let rejector;
3878
- let resolver;
3879
- return new Promise((resolve, reject) => {
3880
- rejector = reject;
3881
- resolver = resolve;
3882
- if (time === 0) settlePromise(abort, resolve, void 0, signal);
3883
- else timer();
3884
- });
3885
- }
3886
- //#endregion
3887
3900
  //#region src/promise/index.ts
3888
3901
  async function attemptPromise(value, options) {
3889
3902
  const isFunction = typeof value === "function";
@@ -3932,7 +3945,7 @@ async function promises(items, options) {
3932
3945
  reject,
3933
3946
  resolve
3934
3947
  };
3935
- for (let index = 0; index < length; index += 1) actual[index].then((value) => handleResult$1(PROMISE_TYPE_FULFILLED, {
3948
+ for (let index = 0; index < length; index += 1) actual[index].then((value) => handleResult(PROMISE_TYPE_FULFILLED, {
3936
3949
  abort,
3937
3950
  complete,
3938
3951
  data,
@@ -3940,7 +3953,7 @@ async function promises(items, options) {
3940
3953
  index,
3941
3954
  signal,
3942
3955
  value
3943
- })).catch((reason) => handleResult$1(PROMISE_TYPE_REJECTED, {
3956
+ })).catch((reason) => handleResult(PROMISE_TYPE_REJECTED, {
3944
3957
  abort,
3945
3958
  complete,
3946
3959
  data,
@@ -4187,11 +4200,11 @@ var Queue = class {
4187
4200
  if (this.#paused) {
4188
4201
  const paused = item;
4189
4202
  this.#handled.push(() => {
4190
- handleResult(paused, error, result);
4203
+ handleResult$1(paused, error, result);
4191
4204
  });
4192
4205
  break;
4193
4206
  }
4194
- handleResult(item, error, result);
4207
+ handleResult$1(item, error, result);
4195
4208
  item = this.#items.shift();
4196
4209
  }
4197
4210
  this.#runners -= 1;
@@ -4217,7 +4230,7 @@ function getOptions(input) {
4217
4230
  maximum: getNumberOrDefault(options.maximum, 0)
4218
4231
  };
4219
4232
  }
4220
- function handleResult(item, error, result) {
4233
+ function handleResult$1(item, error, result) {
4221
4234
  item.signal?.removeEventListener(EVENT_NAME, item.abort);
4222
4235
  if (item.signal?.aborted ?? false) item.reject();
4223
4236
  else if (error) item.reject(result);
@@ -4435,4 +4448,4 @@ var SizedSet = class extends Set {
4435
4448
  }
4436
4449
  };
4437
4450
  //#endregion
4438
- export { CancelablePromise, PromiseTimeoutError, QueueError, RetryError, SORT_DIRECTION_ASCENDING, SORT_DIRECTION_DESCENDING, SizedMap, SizedSet, assert, attempt, attemptPromise, average, beacon, between, camelCase, cancelable, capitalize, ceil, chunk, clamp, clone, compact, compare, count, debounce, delay, diff, difference, drop, endsWith, endsWithArray, equal, error, exists, filter, find, flatten, floor, flow, toResult as fromPromise, toResult, fromQuery, toPromise as fromResult, toPromise, getArray, getArrayPosition, getColor, getForegroundColor, getHexColor, getHexaColor, getHslColor, getHslaColor, getNormalizedHex, getNumber, getRandomBoolean, getRandomCharacters, getRandomColor, getRandomFloat, getRandomHex, getRandomInteger, getRandomItem, getRandomItems, getRgbColor, getRgbaColor, getString, getUuid, getValue, groupBy, hasValue, hexToHsl, hexToHsla, hexToRgb, hexToRgba, hslToHex, hslToRgb, hslToRgba, ignoreKey, includes, includesArray, indexOf, indexOfArray, insert, intersection, isArrayOrPlainObject, isColor, isConstructor, isEmpty, isError, isFulfilled, isHexColor, isHslColor, isHslLike, isHslaColor, isInstanceOf, isKey, isNonNullable, isNullable, isNullableOrEmpty, isNullableOrWhitespace, isNumber, isNumerical, isObject, isOk, isPlainObject, isPrimitive, isRejected, isResult, isRgbColor, isRgbLike, isRgbaColor, isTypedArray, join, kebabCase, logger, lowerCase, max, median, memoize, merge, min, move, noop, ok, omit, once, parse, partition, pascalCase, pick, pipe, promises, push, queue, range, retry, rgbToHex, rgbToHsl, rgbToHsla, round, select, setValue, shuffle, slice, smush, snakeCase, sort, splice, startsWith, startsWithArray, sum, swap, take, template, throttle, timed, times, titleCase, toMap, toQuery, toRecord, toSet, toggle, trim, truncate, tryDecode, tryEncode, union, unique, unsmush, unwrap, update, upperCase, words };
4451
+ export { CancelablePromise, PROMISE_ABORT_EVENT, PROMISE_ABORT_OPTIONS, PROMISE_ERROR_NAME, PROMISE_MESSAGE_EXPECTATION_ATTEMPT, PROMISE_MESSAGE_EXPECTATION_RESULT, PROMISE_MESSAGE_EXPECTATION_TIMED, PROMISE_MESSAGE_TIMEOUT, PROMISE_STRATEGY_ALL, PROMISE_STRATEGY_DEFAULT, PROMISE_TYPE_FULFILLED, PROMISE_TYPE_REJECTED, PromiseTimeoutError, QueueError, RetryError, SORT_DIRECTION_ASCENDING, SORT_DIRECTION_DESCENDING, SizedMap, SizedSet, assert, attempt, attemptFlow, attemptPipe, attemptPromise, average, beacon, between, camelCase, cancelable, capitalize, ceil, chunk, clamp, clone, compact, compare, count, debounce, delay, diff, difference, drop, endsWith, endsWithArray, equal, error, exists, filter, find, flatten, floor, flow, fromQuery, toPromise as fromResult, toPromise, getArray, getArrayPosition, getColor, getError, getForegroundColor, getHexColor, getHexaColor, getHslColor, getHslaColor, getNormalizedHex, getNumber, getRandomBoolean, getRandomCharacters, getRandomColor, getRandomFloat, getRandomHex, getRandomInteger, getRandomItem, getRandomItems, getRgbColor, getRgbaColor, getString, getTimedPromise, getUuid, getValue, groupBy, handleResult, hasValue, hexToHsl, hexToHsla, hexToRgb, hexToRgba, hslToHex, hslToRgb, hslToRgba, ignoreKey, includes, includesArray, indexOf, indexOfArray, insert, intersection, isArrayOrPlainObject, isColor, isConstructor, isEmpty, isError, isFulfilled, isHexColor, isHslColor, isHslLike, isHslaColor, isInstanceOf, isKey, isNonNullable, isNullable, isNullableOrEmpty, isNullableOrWhitespace, isNumber, isNumerical, isObject, isOk, isPlainObject, isPrimitive, isRejected, isResult, isRgbColor, isRgbLike, isRgbaColor, isTypedArray, join, kebabCase, logger, lowerCase, matchResult, max, median, memoize, merge, min, move, noop, ok, omit, once, parse, partition, pascalCase, pick, pipe, promises, push, queue, range, retry, rgbToHex, rgbToHsl, rgbToHsla, round, select, setValue, settlePromise, shuffle, slice, smush, snakeCase, sort, splice, startsWith, startsWithArray, sum, swap, take, template, throttle, timed, times, titleCase, toMap, toQuery, toRecord, toResult, toSet, toggle, trim, truncate, tryDecode, tryEncode, union, unique, unsmush, unwrap, update, upperCase, words };
@@ -1,10 +1,5 @@
1
1
  import { Result } from "../result/models.mjs";
2
- import { CancelablePromise, FulfilledPromise, PromiseOptions, PromiseStrategy, PromiseTimeoutError, PromisesItems, PromisesOptions, PromisesResult, PromisesUnwrapped, PromisesValue, PromisesValues, RejectedPromise } from "./models.mjs";
3
- import { toPromise } from "../result/misc.mjs";
4
- import { delay } from "./delay.mjs";
5
- import { isFulfilled, isRejected } from "./helpers.mjs";
6
- import { cancelable, toResult } from "./misc.mjs";
7
- import { timed } from "./timed.mjs";
2
+ import { PromiseOptions, PromisesItems, PromisesOptions, PromisesResult, PromisesUnwrapped, PromisesValue, PromisesValues } from "./models.mjs";
8
3
 
9
4
  //#region src/promise/index.d.ts
10
5
  /**
@@ -100,4 +95,4 @@ declare function resultPromises<Items extends unknown[]>(items: [...Items], sign
100
95
  */
101
96
  declare function resultPromises<Value>(items: Promise<Value>[], signal?: AbortSignal): Promise<Result<Awaited<Value>>[]>;
102
97
  //#endregion
103
- export { CancelablePromise, type FulfilledPromise, type PromiseOptions, type PromiseStrategy, PromiseTimeoutError, type PromisesOptions, type PromisesResult, type PromisesValues as PromisesValue, type PromisesValue as PromisesValueItem, type RejectedPromise, attemptPromise, cancelable, delay, toPromise as fromResult, isFulfilled, isRejected, promises, timed, toResult };
98
+ export { attemptPromise, promises };
@@ -1,9 +1,7 @@
1
- import { toPromise } from "../result/misc.mjs";
2
- import { CancelablePromise, PROMISE_ABORT_EVENT, PROMISE_ABORT_OPTIONS, PROMISE_MESSAGE_EXPECTATION_ATTEMPT, PROMISE_STRATEGY_DEFAULT, PROMISE_TYPE_FULFILLED, PROMISE_TYPE_REJECTED, PromiseTimeoutError } from "./models.mjs";
3
- import { getPromiseOptions, getPromisesOptions, getResultsFromPromises, isFulfilled, isRejected } from "./helpers.mjs";
4
- import { cancelable, handleResult, settlePromise, toResult } from "./misc.mjs";
5
- import { getTimedPromise, timed } from "./timed.mjs";
6
- import { delay } from "./delay.mjs";
1
+ import { PROMISE_ABORT_EVENT, PROMISE_ABORT_OPTIONS, PROMISE_MESSAGE_EXPECTATION_ATTEMPT, PROMISE_STRATEGY_DEFAULT, PROMISE_TYPE_FULFILLED, PROMISE_TYPE_REJECTED } from "./models.mjs";
2
+ import { getPromiseOptions, getPromisesOptions, getResultsFromPromises } from "./helpers.mjs";
3
+ import { handleResult, settlePromise } from "./misc.mjs";
4
+ import { getTimedPromise } from "./timed.mjs";
7
5
  //#region src/promise/index.ts
8
6
  async function attemptPromise(value, options) {
9
7
  const isFunction = typeof value === "function";
@@ -76,4 +74,4 @@ async function resultPromises(items, signal) {
76
74
  return promises(items, signal).then(getResultsFromPromises);
77
75
  }
78
76
  //#endregion
79
- export { CancelablePromise, PromiseTimeoutError, attemptPromise, cancelable, delay, toPromise as fromResult, isFulfilled, isRejected, promises, timed, toResult };
77
+ export { attemptPromise, promises };
@@ -1,5 +1,7 @@
1
1
  import { Result } from "../result/models.mjs";
2
2
  import { CancelablePromise, PromiseParameters } from "./models.mjs";
3
+ import { toPromise } from "../result/misc.mjs";
4
+ import { isFulfilled, isRejected } from "./helpers.mjs";
3
5
 
4
6
  //#region src/promise/misc.d.ts
5
7
  /**
@@ -23,4 +25,4 @@ declare function toResult<Value>(callback: () => Promise<Value>): Promise<Result
23
25
  */
24
26
  declare function toResult<Value>(promise: Promise<Value>): Promise<Result<Value>>;
25
27
  //#endregion
26
- export { cancelable, handleResult, settlePromise, toResult };
28
+ export { cancelable, toPromise as fromResult, handleResult, isFulfilled, isRejected, settlePromise, toResult };
@@ -1,5 +1,6 @@
1
- import { error, ok } from "../result/misc.mjs";
1
+ import { error, ok, toPromise } from "../result/misc.mjs";
2
2
  import { CancelablePromise, PROMISE_ABORT_EVENT, PROMISE_MESSAGE_EXPECTATION_RESULT } from "./models.mjs";
3
+ import { isFulfilled, isRejected } from "./helpers.mjs";
3
4
  //#region src/promise/misc.ts
4
5
  /**
5
6
  * Create a cancelable promise
@@ -35,4 +36,4 @@ async function toResult(value) {
35
36
  return actual.then((result) => ok(result)).catch((reason) => error(reason));
36
37
  }
37
38
  //#endregion
38
- export { cancelable, handleResult, settlePromise, toResult };
39
+ export { cancelable, toPromise as fromResult, handleResult, isFulfilled, isRejected, settlePromise, toResult };
@@ -1,11 +1,8 @@
1
- import { Err, ExtendedErr, ExtendedResult, Ok, Result } from "./models.mjs";
2
- import { error, ok, toPromise, unwrap } from "./misc.mjs";
3
- import { toResult } from "../promise/misc.mjs";
1
+ import { ExtendedResult, Result } from "./models.mjs";
4
2
  import { attemptPromise } from "../promise/index.mjs";
5
3
  import { matchResult } from "./match.mjs";
6
4
  import { attemptFlow } from "./work/flow.mjs";
7
5
  import { attemptPipe } from "./work/pipe.mjs";
8
- import { isError, isOk, isResult } from "../internal/result.mjs";
9
6
 
10
7
  //#region src/result/index.d.ts
11
8
  /**
@@ -55,4 +52,4 @@ declare namespace attempt {
55
52
  var promise: typeof attemptPromise;
56
53
  }
57
54
  //#endregion
58
- export { type Err, type ExtendedErr, type ExtendedResult, type Ok, type Result, attempt, error, toResult as fromPromise, isError, isOk, isResult, ok, toPromise, unwrap };
55
+ export { attempt };
@@ -1,6 +1,4 @@
1
- import { isError, isOk, isResult } from "../internal/result.mjs";
2
- import { error, getError, ok, toPromise, unwrap } from "./misc.mjs";
3
- import { toResult } from "../promise/misc.mjs";
1
+ import { getError, ok } from "./misc.mjs";
4
2
  import { attemptPromise } from "../promise/index.mjs";
5
3
  import { matchResult } from "./match.mjs";
6
4
  import { attemptFlow } from "./work/flow.mjs";
@@ -28,4 +26,4 @@ attempt.match = matchResult;
28
26
  attempt.pipe = attemptPipe;
29
27
  attempt.promise = attemptPromise;
30
28
  //#endregion
31
- export { attempt, error, toResult as fromPromise, isError, isOk, isResult, ok, toPromise, unwrap };
29
+ export { attempt };
@@ -1,4 +1,5 @@
1
1
  import { AnyResult, Err, ExtendedErr, Ok, Result } from "./models.mjs";
2
+ import { isError, isOk, isResult } from "../internal/result.mjs";
2
3
 
3
4
  //#region src/result/misc.d.ts
4
5
  /**
@@ -52,4 +53,4 @@ declare function unwrap<Value, E = Error>(value: Result<Value, E>, defaultValue:
52
53
  */
53
54
  declare function unwrap(value: unknown, defaultValue: unknown): unknown;
54
55
  //#endregion
55
- export { error, getError, ok, toPromise, unwrap };
56
+ export { error, getError, isError, isOk, isResult, ok, toPromise, unwrap };
@@ -1,4 +1,4 @@
1
- import { isOk, isResult } from "../internal/result.mjs";
1
+ import { isError, isOk, isResult } from "../internal/result.mjs";
2
2
  //#region src/result/misc.ts
3
3
  function error(value, original) {
4
4
  return getError(value, original);
@@ -39,4 +39,4 @@ function unwrap(value, defaultValue) {
39
39
  }
40
40
  const MESSAGE_PROMISE_RESULT = "toPromise expected to receive a Result";
41
41
  //#endregion
42
- export { error, getError, ok, toPromise, unwrap };
42
+ export { error, getError, isError, isOk, isResult, ok, toPromise, unwrap };