@lowentry/utils 1.22.2 → 1.23.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowentry/utils",
3
- "version": "1.22.2",
3
+ "version": "1.23.1",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./index.js",
package/src/LeUtils.js CHANGED
@@ -586,43 +586,42 @@ export const LeUtils = {
586
586
  {
587
587
  return index;
588
588
  }
589
- if(ArrayBuffer.isView(elements) && !(elements instanceof DataView))
589
+ if(typeof elements !== 'string')
590
590
  {
591
- return elements[index];
592
- }
593
- if(typeof elements === 'string')
594
- {
595
- return elements.charAt(index);
596
- }
597
- if(typeof elements?.[Symbol.iterator] === 'function')
598
- {
599
- let i = 0;
600
- for(const value of elements)
591
+ if(ArrayBuffer.isView(elements) && !(elements instanceof DataView))
601
592
  {
602
- if(i === index)
603
- {
604
- return value;
605
- }
606
- i++;
593
+ return elements[index];
607
594
  }
608
- return undefined;
609
- }
610
- if(typeof elements?.forEach === 'function')
611
- {
612
- let result = undefined;
613
- let shouldContinue = true;
614
- elements.forEach((value, i) =>
595
+ if(typeof elements?.[Symbol.iterator] === 'function')
615
596
  {
616
- if(shouldContinue)
597
+ let i = 0;
598
+ for(const value of elements)
617
599
  {
618
600
  if(i === index)
619
601
  {
620
- result = value;
621
- shouldContinue = false;
602
+ return value;
622
603
  }
604
+ i++;
623
605
  }
624
- });
625
- return result;
606
+ return undefined;
607
+ }
608
+ if(typeof elements?.forEach === 'function')
609
+ {
610
+ let result = undefined;
611
+ let shouldContinue = true;
612
+ elements.forEach((value, i) =>
613
+ {
614
+ if(shouldContinue)
615
+ {
616
+ if(i === index)
617
+ {
618
+ result = value;
619
+ shouldContinue = false;
620
+ }
621
+ }
622
+ });
623
+ return result;
624
+ }
626
625
  }
627
626
  if((typeof elements === 'object') || (typeof elements === 'function'))
628
627
  {
@@ -644,14 +643,13 @@ export const LeUtils = {
644
643
  supportsEach:
645
644
  (elements) =>
646
645
  {
647
- if((elements === null) || (typeof elements === 'undefined'))
646
+ if((elements === null) || (typeof elements === 'undefined') || (typeof elements === 'string'))
648
647
  {
649
648
  return false;
650
649
  }
651
650
  return !!(
652
651
  (Array.isArray(elements))
653
652
  || ((typeof elements === 'object') && (elements?.constructor === Object))
654
- || (typeof elements === 'string')
655
653
  || (typeof elements?.[Symbol.iterator] === 'function')
656
654
  || (typeof elements?.forEach === 'function')
657
655
  || ((typeof elements === 'object') || (typeof elements === 'function'))
@@ -707,36 +705,31 @@ export const LeUtils = {
707
705
  }
708
706
  return;
709
707
  }
710
- if(typeof elements === 'string')
708
+ if(typeof elements !== 'string')
711
709
  {
712
- for(let i = 0; i < elements.length; i++)
710
+ if(typeof elements?.[Symbol.iterator] === 'function')
713
711
  {
714
- yield [elements.charAt(i), i];
712
+ let i = 0;
713
+ for(const value of elements)
714
+ {
715
+ yield [value, i];
716
+ i++;
717
+ }
718
+ return;
715
719
  }
716
- return;
717
- }
718
- if(typeof elements?.[Symbol.iterator] === 'function')
719
- {
720
- let i = 0;
721
- for(const value of elements)
720
+ if(typeof elements?.forEach === 'function')
722
721
  {
723
- yield [value, i];
724
- i++;
725
- }
726
- return;
727
- }
728
- if(typeof elements?.forEach === 'function')
729
- {
730
- const buffer = [];
731
- elements.forEach((value, i) =>
732
- {
733
- buffer.push([value, i]);
734
- });
735
- for(const entry of buffer)
736
- {
737
- yield entry;
722
+ const buffer = [];
723
+ elements.forEach((value, i) =>
724
+ {
725
+ buffer.push([value, i]);
726
+ });
727
+ for(const entry of buffer)
728
+ {
729
+ yield entry;
730
+ }
731
+ return;
738
732
  }
739
- return;
740
733
  }
741
734
  if((typeof elements === 'object') || (typeof elements === 'function'))
742
735
  {
@@ -898,7 +891,7 @@ export const LeUtils = {
898
891
  collection.set(index, value);
899
892
  };
900
893
  }
901
- else if((typeof elements === 'string') || (typeof elements?.[Symbol.iterator] === 'function') || (typeof elements?.forEach === 'function'))
894
+ else if((typeof elements !== 'string') && ((typeof elements?.[Symbol.iterator] === 'function') || (typeof elements?.forEach === 'function')))
902
895
  {
903
896
  collection = [];
904
897
  add = (value, index) =>
@@ -1119,7 +1112,7 @@ export const LeUtils = {
1119
1112
  {
1120
1113
  const flattenToArrayRecursive = (result, elements, optionalSkipHasOwnPropertyCheck) =>
1121
1114
  {
1122
- if(!LeUtils.supportsEach(elements) || (typeof elements === 'string'))
1115
+ if(!LeUtils.supportsEach(elements))
1123
1116
  {
1124
1117
  result.push(elements);
1125
1118
  return;
@@ -1132,7 +1125,7 @@ export const LeUtils = {
1132
1125
 
1133
1126
  return (elements, optionalSkipHasOwnPropertyCheck = false) =>
1134
1127
  {
1135
- if(!LeUtils.supportsEach(elements) || (typeof elements === 'string'))
1128
+ if(!LeUtils.supportsEach(elements))
1136
1129
  {
1137
1130
  return [elements];
1138
1131
  }
@@ -2055,7 +2048,7 @@ export const LeUtils = {
2055
2048
  generateNamePermutations:
2056
2049
  (...names) =>
2057
2050
  {
2058
- names = LeUtils.flattenArray(names)
2051
+ names = LeUtils.flattenToArray(names)
2059
2052
  .map(name => STRING(name).trim().toLowerCase())
2060
2053
  .filter(name => (name.length > 0));
2061
2054
  let results = [];