moderndash 3.11.1 → 4.0.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/README.md CHANGED
@@ -14,9 +14,8 @@
14
14
  ✅ Typescript Strict Mode (no any)
15
15
  <br>
16
16
  ✅ 100% Test Coverage
17
- ✅ Zero dependencies
17
+ ✅ Zero runtime dependencies
18
18
  ✅ Hoverable Docs
19
- ✅ TS Decorators
20
19
  </div>
21
20
  <p></p>
22
21
 
@@ -57,12 +56,7 @@ npm install moderndash
57
56
  ```
58
57
  ## 📋 Requirements
59
58
 
60
- **NodeJS**: >=16.15 | **Typescript**: >=4.8
61
-
62
- > `NodeJS 16-18`: Enable the [experimental-global-webcrypto](https://nodejs.dev/en/api/v16/cli#--experimental-global-webcrypto) flag to use crypto functions.
63
- *Works out of the box with NodeJS 19+*
64
-
65
- > `TypeScript`: Enable the [experimentalDecorators](https://www.typescriptlang.org/tsconfig#experimentalDecorators) flag to use decorator functions.
59
+ **NodeJS**: >=20.x | **Typescript**: >=5.0
66
60
 
67
61
  ## 🚀 Performance
68
62
 
@@ -77,11 +71,6 @@ ModernDash does not include any lodash functions that can be easily replaced by
77
71
  Please refer to [You-Dont-Need-Lodash](https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore) or [youmightnotneed.com/lodash](https://youmightnotneed.com/lodash) for native replacements.
78
72
  If you still believe a function is missing, please open an issue.
79
73
 
80
- ### Why no pipe utility functions?
81
- The upcoming [pipe operator](https://github.com/tc39/proposal-pipeline-operator) in JavaScript will provide function composition, so the framework focuses on providing other useful utility functions that are not yet available.
82
-
83
- The pipe operator can already be included via [babel](https://babeljs.io/docs/en/babel-plugin-proposal-pipeline-operator).
84
-
85
74
  ## 💌 Love & Thanks
86
75
 
87
76
  To [type-fest](https://github.com/sindresorhus/type-fest) for providing some valuable types.
package/dist/index.cjs CHANGED
@@ -317,12 +317,10 @@ function randomInt(min, max) {
317
317
  // src/crypto/randomElem.ts
318
318
  function randomElem(array, multi) {
319
319
  if (multi === void 0) {
320
- if (array.length === 0)
321
- return void 0;
320
+ if (array.length === 0) return void 0;
322
321
  return getSingleElement(array);
323
322
  }
324
- if (multi && array.length === 0)
325
- return [];
323
+ if (multi && array.length === 0) return [];
326
324
  const result = new Array(multi);
327
325
  for (let i = 0; i < multi; i++) {
328
326
  result[i] = getSingleElement(array);
@@ -348,8 +346,7 @@ function randomFloat(min, max) {
348
346
  // src/crypto/randomString.ts
349
347
  var DEFAULT_CHARSET = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
350
348
  function randomString(length, charSet = DEFAULT_CHARSET) {
351
- if (charSet.length <= 0)
352
- return "";
349
+ if (charSet.length <= 0) return "";
353
350
  let result = "";
354
351
  for (let index = 0; index < length; index++) {
355
352
  const randomIndex = randomInt(0, charSet.length - 1);
@@ -361,9 +358,9 @@ function randomString(length, charSet = DEFAULT_CHARSET) {
361
358
  // src/decorator/toDecorator.ts
362
359
  function toDecorator(func) {
363
360
  return function(...args) {
364
- return function(_target, _key, descriptor) {
365
- const creatorArgs = [descriptor.value, ...args];
366
- descriptor.value = func(...creatorArgs);
361
+ return function(originalMethod, _context) {
362
+ const funcArgs = [originalMethod, ...args];
363
+ return func(...funcArgs);
367
364
  };
368
365
  };
369
366
  }
@@ -773,8 +770,7 @@ function splitWords(str) {
773
770
 
774
771
  // src/string/capitalize.ts
775
772
  function capitalize(str) {
776
- if (str === "")
777
- return "";
773
+ if (str === "") return "";
778
774
  return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
779
775
  }
780
776
 
@@ -786,12 +782,10 @@ function deburr(str) {
786
782
 
787
783
  // src/string/camelCase.ts
788
784
  function camelCase(str) {
789
- if (str === "")
790
- return "";
785
+ if (str === "") return "";
791
786
  str = deburr(str);
792
787
  const words = splitWords(str);
793
- if (words.length === 0)
794
- return "";
788
+ if (words.length === 0) return "";
795
789
  let camelCase2 = words[0].toLowerCase();
796
790
  for (let index = 1; index < words.length; index++) {
797
791
  const word = words[index];
@@ -821,8 +815,7 @@ function escapeRegExp(str) {
821
815
 
822
816
  // src/string/kebabCase.ts
823
817
  function kebabCase(str) {
824
- if (str === "")
825
- return "";
818
+ if (str === "") return "";
826
819
  str = deburr(str);
827
820
  const words = splitWords(str);
828
821
  let kebabCase2 = "";
@@ -834,8 +827,7 @@ function kebabCase(str) {
834
827
 
835
828
  // src/string/pascalCase.ts
836
829
  function pascalCase(str) {
837
- if (str === "")
838
- return "";
830
+ if (str === "") return "";
839
831
  str = deburr(str);
840
832
  const words = splitWords(str);
841
833
  let pascalCase2 = "";
@@ -855,8 +847,7 @@ function replaceLast(str, searchFor, replaceWith) {
855
847
 
856
848
  // src/string/snakeCase.ts
857
849
  function snakeCase(str) {
858
- if (str === "")
859
- return "";
850
+ if (str === "") return "";
860
851
  str = deburr(str);
861
852
  const words = splitWords(str);
862
853
  let snakeCase2 = "";
@@ -871,8 +862,7 @@ function snakeCase(str) {
871
862
 
872
863
  // src/string/titleCase.ts
873
864
  function titleCase(str) {
874
- if (str === "")
875
- return "";
865
+ if (str === "") return "";
876
866
  str = deburr(str);
877
867
  const words = splitWords(str);
878
868
  let titleCase2 = "";
@@ -913,24 +903,10 @@ function trimStart(str, chars) {
913
903
  return str.slice(startIndex);
914
904
  }
915
905
 
916
- // src/string/unescapeHtml.ts
917
- var htmlEntitiesRegex = /&(?:amp|lt|gt|quot|#39);/g;
918
- var entityMap = /* @__PURE__ */ new Map([
919
- ["&amp;", "&"],
920
- ["&lt;", "<"],
921
- ["&gt;", ">"],
922
- ["&quot;", '"'],
923
- ["&#39;", "'"]
924
- ]);
925
- function unescapeHtml(str) {
926
- return str.replace(htmlEntitiesRegex, (entity) => entityMap.get(entity));
927
- }
928
-
929
906
  // src/string/truncate.ts
930
907
  function truncate(str, options) {
931
908
  const { length = 30, ellipsis = "...", separator } = options ?? {};
932
- if (str.length <= length)
933
- return str;
909
+ if (str.length <= length) return str;
934
910
  const end = length - ellipsis.length;
935
911
  if (end < 1)
936
912
  return ellipsis;
@@ -944,6 +920,19 @@ function truncate(str, options) {
944
920
  return truncated + ellipsis;
945
921
  }
946
922
 
923
+ // src/string/unescapeHtml.ts
924
+ var htmlEntitiesRegex = /&(?:amp|lt|gt|quot|#39);/g;
925
+ var entityMap = /* @__PURE__ */ new Map([
926
+ ["&amp;", "&"],
927
+ ["&lt;", "<"],
928
+ ["&gt;", ">"],
929
+ ["&quot;", '"'],
930
+ ["&#39;", "'"]
931
+ ]);
932
+ function unescapeHtml(str) {
933
+ return str.replace(htmlEntitiesRegex, (entity) => entityMap.get(entity));
934
+ }
935
+
947
936
  // src/validate/isEmpty.ts
948
937
  function isEmpty(value) {
949
938
  if (value === null || value === void 0)
@@ -961,10 +950,8 @@ function isEmpty(value) {
961
950
 
962
951
  // src/validate/isEqual.ts
963
952
  function isEqual(a, b) {
964
- if (Object.is(a, b))
965
- return true;
966
- if (typeof a !== typeof b)
967
- return false;
953
+ if (Object.is(a, b)) return true;
954
+ if (typeof a !== typeof b) return false;
968
955
  if (Array.isArray(a) && Array.isArray(b))
969
956
  return isSameArray(a, b);
970
957
  if (a instanceof Date && b instanceof Date)
@@ -978,8 +965,7 @@ function isEqual(a, b) {
978
965
  if (a instanceof DataView && b instanceof DataView)
979
966
  return dataViewsAreEqual(a, b);
980
967
  if (isTypedArray(a) && isTypedArray(b)) {
981
- if (a.byteLength !== b.byteLength)
982
- return false;
968
+ if (a.byteLength !== b.byteLength) return false;
983
969
  return isSameArray(a, b);
984
970
  }
985
971
  return false;
@@ -987,25 +973,20 @@ function isEqual(a, b) {
987
973
  function isSameObject(a, b) {
988
974
  const keys1 = Object.keys(a);
989
975
  const keys2 = Object.keys(b);
990
- if (!isEqual(keys1, keys2))
991
- return false;
976
+ if (!isEqual(keys1, keys2)) return false;
992
977
  for (const key of keys1) {
993
- if (!isEqual(a[key], b[key]))
994
- return false;
978
+ if (!isEqual(a[key], b[key])) return false;
995
979
  }
996
980
  return true;
997
981
  }
998
982
  function isSameArray(a, b) {
999
- if (a.length !== b.length)
1000
- return false;
983
+ if (a.length !== b.length) return false;
1001
984
  return a.every((element, index) => isEqual(element, b[index]));
1002
985
  }
1003
986
  function dataViewsAreEqual(a, b) {
1004
- if (a.byteLength !== b.byteLength)
1005
- return false;
987
+ if (a.byteLength !== b.byteLength) return false;
1006
988
  for (let offset = 0; offset < a.byteLength; offset++) {
1007
- if (a.getUint8(offset) !== b.getUint8(offset))
1008
- return false;
989
+ if (a.getUint8(offset) !== b.getUint8(offset)) return false;
1009
990
  }
1010
991
  return true;
1011
992
  }