@valkyriestudios/utils 12.3.0 → 12.5.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.
Files changed (159) hide show
  1. package/README.md +15 -4
  2. package/array/dedupe.d.ts +2 -1
  3. package/array/dedupe.js +3 -1
  4. package/array/index.d.ts +10 -0
  5. package/array/index.js +25 -0
  6. package/array/is.d.ts +2 -1
  7. package/array/is.js +2 -0
  8. package/array/isNotEmpty.d.ts +2 -1
  9. package/array/isNotEmpty.js +2 -0
  10. package/array/join.d.ts +2 -2
  11. package/array/join.js +3 -1
  12. package/array/mapFn.d.ts +4 -7
  13. package/array/mapFn.js +2 -0
  14. package/array/mapKey.d.ts +3 -4
  15. package/array/mapKey.js +2 -0
  16. package/array/mapPrimitive.d.ts +2 -2
  17. package/array/mapPrimitive.js +3 -1
  18. package/array/shuffle.d.ts +2 -1
  19. package/array/shuffle.js +2 -0
  20. package/array/sort.d.ts +2 -2
  21. package/array/sort.js +4 -2
  22. package/boolean/index.d.ts +2 -0
  23. package/boolean/index.js +6 -0
  24. package/boolean/is.d.ts +2 -1
  25. package/boolean/is.js +2 -0
  26. package/caching/index.d.ts +2 -0
  27. package/caching/index.js +5 -0
  28. package/caching/memoize.d.ts +2 -1
  29. package/caching/memoize.js +2 -0
  30. package/date/addUTC.d.ts +2 -1
  31. package/date/addUTC.js +3 -3
  32. package/date/diff.d.ts +2 -1
  33. package/date/diff.js +4 -2
  34. package/date/endOfUTC.d.ts +2 -1
  35. package/date/endOfUTC.js +3 -3
  36. package/date/format.d.ts +2 -1
  37. package/date/format.js +3 -1
  38. package/date/index.d.ts +11 -0
  39. package/date/index.js +24 -0
  40. package/date/is.d.ts +2 -1
  41. package/date/is.js +2 -0
  42. package/date/nowUnix.d.ts +2 -1
  43. package/date/nowUnix.js +2 -0
  44. package/date/nowUnixMs.d.ts +2 -1
  45. package/date/nowUnixMs.js +2 -0
  46. package/date/startOfUTC.d.ts +2 -1
  47. package/date/startOfUTC.js +3 -3
  48. package/date/toUTC.d.ts +2 -1
  49. package/date/toUTC.js +3 -1
  50. package/date/toUnix.d.ts +2 -1
  51. package/date/toUnix.js +3 -1
  52. package/deep/freeze.d.ts +2 -2
  53. package/deep/freeze.js +2 -0
  54. package/deep/get.d.ts +2 -1
  55. package/deep/get.js +2 -0
  56. package/deep/index.d.ts +5 -0
  57. package/deep/index.js +15 -0
  58. package/deep/seal.d.ts +2 -2
  59. package/deep/seal.js +2 -0
  60. package/deep/set.d.ts +2 -1
  61. package/deep/set.js +2 -0
  62. package/equal.d.ts +1 -1
  63. package/equal.js +4 -2
  64. package/formdata/index.d.ts +2 -0
  65. package/formdata/index.js +6 -0
  66. package/formdata/is.d.ts +9 -0
  67. package/formdata/is.js +8 -0
  68. package/function/index.d.ts +7 -0
  69. package/function/index.js +19 -0
  70. package/function/is.d.ts +2 -1
  71. package/function/is.js +2 -0
  72. package/function/isAsync.d.ts +2 -1
  73. package/function/isAsync.js +2 -0
  74. package/function/noop.d.ts +2 -1
  75. package/function/noop.js +2 -0
  76. package/function/noopresolve.d.ts +2 -1
  77. package/function/noopresolve.js +2 -0
  78. package/function/noopreturn.d.ts +2 -1
  79. package/function/noopreturn.js +2 -0
  80. package/function/sleep.d.ts +2 -1
  81. package/function/sleep.js +2 -0
  82. package/hash/fnv1A.d.ts +2 -1
  83. package/hash/fnv1A.js +2 -0
  84. package/hash/guid.d.ts +2 -1
  85. package/hash/guid.js +2 -0
  86. package/hash/index.d.ts +3 -0
  87. package/hash/index.js +7 -0
  88. package/index.d.ts +386 -238
  89. package/is.d.ts +52 -66
  90. package/is.js +61 -73
  91. package/number/index.d.ts +18 -0
  92. package/number/index.js +57 -0
  93. package/number/is.d.ts +2 -1
  94. package/number/is.js +2 -0
  95. package/number/isAbove.d.ts +2 -1
  96. package/number/isAbove.js +2 -0
  97. package/number/isAboveOrEqual.d.ts +2 -1
  98. package/number/isAboveOrEqual.js +2 -0
  99. package/number/isBelow.d.ts +2 -1
  100. package/number/isBelow.js +2 -0
  101. package/number/isBelowOrEqual.d.ts +2 -1
  102. package/number/isBelowOrEqual.js +2 -0
  103. package/number/isBetween.d.ts +2 -1
  104. package/number/isBetween.js +2 -0
  105. package/number/isInteger.d.ts +2 -1
  106. package/number/isInteger.js +2 -0
  107. package/number/isIntegerAbove.d.ts +2 -1
  108. package/number/isIntegerAbove.js +2 -0
  109. package/number/isIntegerAboveOrEqual.d.ts +2 -1
  110. package/number/isIntegerAboveOrEqual.js +2 -0
  111. package/number/isIntegerBelow.d.ts +2 -1
  112. package/number/isIntegerBelow.js +2 -0
  113. package/number/isIntegerBelowOrEqual.d.ts +2 -1
  114. package/number/isIntegerBelowOrEqual.js +2 -0
  115. package/number/isIntegerBetween.d.ts +2 -1
  116. package/number/isIntegerBetween.js +2 -0
  117. package/number/isNumericalNaN.d.ts +2 -1
  118. package/number/isNumericalNaN.js +2 -0
  119. package/number/randomBetween.d.ts +2 -1
  120. package/number/randomBetween.js +2 -0
  121. package/number/randomIntBetween.d.ts +2 -1
  122. package/number/randomIntBetween.js +2 -0
  123. package/number/round.d.ts +2 -1
  124. package/number/round.js +2 -0
  125. package/number/toPercentage.d.ts +2 -1
  126. package/number/toPercentage.js +3 -1
  127. package/object/define.d.ts +2 -1
  128. package/object/define.js +2 -0
  129. package/object/index.d.ts +6 -0
  130. package/object/index.js +17 -0
  131. package/object/is.d.ts +2 -1
  132. package/object/is.js +2 -0
  133. package/object/isNotEmpty.d.ts +2 -1
  134. package/object/isNotEmpty.js +2 -0
  135. package/object/merge.d.ts +1 -1
  136. package/object/merge.js +2 -0
  137. package/object/pick.d.ts +2 -1
  138. package/object/pick.js +4 -2
  139. package/package.json +1 -1
  140. package/regexp/index.d.ts +3 -0
  141. package/regexp/index.js +9 -0
  142. package/regexp/is.d.ts +2 -1
  143. package/regexp/is.js +2 -0
  144. package/regexp/sanitize.d.ts +2 -1
  145. package/regexp/sanitize.js +2 -0
  146. package/string/humanizeBytes.d.ts +2 -2
  147. package/string/humanizeBytes.js +4 -3
  148. package/string/humanizeNumber.d.ts +2 -2
  149. package/string/humanizeNumber.js +3 -1
  150. package/string/index.d.ts +7 -0
  151. package/string/index.js +20 -0
  152. package/string/is.d.ts +2 -1
  153. package/string/is.js +2 -0
  154. package/string/isBetween.d.ts +2 -1
  155. package/string/isBetween.js +2 -0
  156. package/string/isNotEmpty.d.ts +2 -1
  157. package/string/isNotEmpty.js +2 -0
  158. package/string/shorten.d.ts +2 -1
  159. package/string/shorten.js +2 -0
package/README.md CHANGED
@@ -1,12 +1,15 @@
1
1
  # @valkyriestudios/utils
2
2
 
3
- [![codecov](https://codecov.io/gh/ValkyrieStudios/utils/branch/master/graph/badge.svg)](https://codecov.io/gh/ValkyrieStudios/utils)
4
- [![codeql](https://github.com/ValkyrieStudios/utils/actions/workflows/github-code-scanning/codeql/badge.svg)](https://github.com/ValkyrieStudios/utils/actions/workflows/github-code-scanning/codeql)
3
+ [![CodeCov](https://codecov.io/gh/ValkyrieStudios/utils/branch/master/graph/badge.svg)](https://codecov.io/gh/ValkyrieStudios/utils)
4
+ [![Test](https://github.com/ValkyrieStudios/utils/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/ValkyrieStudios/utils/actions/workflows/test.yml)
5
+ [![Lint](https://github.com/ValkyrieStudios/utils/actions/workflows/lint.yml/badge.svg?branch=master)](https://github.com/ValkyrieStudios/utils/actions/workflows/lint.yml)
6
+ [![CodeQL](https://github.com/ValkyrieStudios/utils/actions/workflows/github-code-scanning/codeql/badge.svg?branch=master)](https://github.com/ValkyrieStudios/utils/actions/workflows/github-code-scanning/codeql)
5
7
  [![npm](https://img.shields.io/npm/v/@valkyriestudios/utils.svg)](https://www.npmjs.com/package/@valkyriestudios/utils)
6
8
  [![npm](https://img.shields.io/npm/dm/@valkyriestudios/utils.svg)](https://www.npmjs.com/package/@valkyriestudios/utils)
7
9
 
8
10
  Zero-dependency collection of single-function utilities for common tasks
9
11
 
12
+ ## Installation
10
13
  `npm install @valkyriestudios/utils`
11
14
 
12
15
  ## Available Functions
@@ -275,7 +278,7 @@ const memoized_function = memoize((a) => {
275
278
  - **isDate(val:any)**
276
279
  Check if a variable is of type Date
277
280
  ```js
278
- isDate(new Date('December 17, 1995 03:24:00'); // TRUE
281
+ isDate(new Date('December 17, 1995 03:24:00')); // TRUE
279
282
  isDate('December 17, 1995 03:24:00'); // FALSE
280
283
  ```
281
284
 
@@ -542,6 +545,14 @@ An empty function that returns a promise that will immediately resolve itself an
542
545
  An empty function that returns a promise that will resolve after X milliseconds, default is set to 1000ms.
543
546
  **
544
547
 
548
+ ### formdata
549
+ - **isFormData(val:any)**
550
+ Check if a variable is of type FormData
551
+ ```js
552
+ isFormData(new FormData()); // TRUE
553
+ isFormData({hi: 'there'}); // FALSE
554
+ ```
555
+
545
556
  ### hash
546
557
  - **guid()**
547
558
  Generate a unique identifier (guid) according to RFC4122
@@ -847,4 +858,4 @@ humanizeNumber(47328748923747923479); // '47,328.75q'
847
858
  allows passing options to control the output, following options are possible:
848
859
 
849
860
  ## Contributors
850
- - [Peter Vermeulen](mailto:contact@valkyriestudios.be)
861
+ - [Peter Vermeulen](https://www.linkedin.com/in/petervermeulen1/)
package/array/dedupe.d.ts CHANGED
@@ -5,4 +5,5 @@
5
5
  *
6
6
  * @returns Deduped array
7
7
  */
8
- export default function dedupe<T>(val: T[]): T[];
8
+ declare function dedupe<T>(val: T[]): T[];
9
+ export { dedupe, dedupe as default };
package/array/dedupe.js CHANGED
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = exports.dedupe = void 0;
3
4
  const fnv1A_1 = require("../hash/fnv1A");
4
5
  function dedupe(val) {
5
6
  if (!Array.isArray(val))
@@ -7,7 +8,7 @@ function dedupe(val) {
7
8
  const set = new Set();
8
9
  const acc = [];
9
10
  for (const item of val) {
10
- const hash = (0, fnv1A_1.default)(item);
11
+ const hash = (0, fnv1A_1.fnv1A)(item);
11
12
  if (set.has(hash))
12
13
  continue;
13
14
  set.add(hash);
@@ -15,4 +16,5 @@ function dedupe(val) {
15
16
  }
16
17
  return acc;
17
18
  }
19
+ exports.dedupe = dedupe;
18
20
  exports.default = dedupe;
@@ -0,0 +1,10 @@
1
+ import { dedupe } from './dedupe';
2
+ import { isArray } from './is';
3
+ import { isNotEmptyArray } from './isNotEmpty';
4
+ import { join } from './join';
5
+ import { mapFn } from './mapFn';
6
+ import { mapKey } from './mapKey';
7
+ import { mapPrimitive } from './mapPrimitive';
8
+ import { shuffle } from './shuffle';
9
+ import { sort } from './sort';
10
+ export { dedupe, isArray, isArray as is, isNotEmptyArray, isNotEmptyArray as isNotEmpty, isNotEmptyArray as isNeArray, isNotEmptyArray as isNe, join, mapFn, mapKey, mapPrimitive, shuffle, sort };
package/array/index.js ADDED
@@ -0,0 +1,25 @@
1
+ 'use strict';
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sort = exports.shuffle = exports.mapPrimitive = exports.mapKey = exports.mapFn = exports.join = exports.isNe = exports.isNeArray = exports.isNotEmpty = exports.isNotEmptyArray = exports.is = exports.isArray = exports.dedupe = void 0;
4
+ const dedupe_1 = require("./dedupe");
5
+ Object.defineProperty(exports, "dedupe", { enumerable: true, get: function () { return dedupe_1.dedupe; } });
6
+ const is_1 = require("./is");
7
+ Object.defineProperty(exports, "isArray", { enumerable: true, get: function () { return is_1.isArray; } });
8
+ Object.defineProperty(exports, "is", { enumerable: true, get: function () { return is_1.isArray; } });
9
+ const isNotEmpty_1 = require("./isNotEmpty");
10
+ Object.defineProperty(exports, "isNotEmptyArray", { enumerable: true, get: function () { return isNotEmpty_1.isNotEmptyArray; } });
11
+ Object.defineProperty(exports, "isNotEmpty", { enumerable: true, get: function () { return isNotEmpty_1.isNotEmptyArray; } });
12
+ Object.defineProperty(exports, "isNeArray", { enumerable: true, get: function () { return isNotEmpty_1.isNotEmptyArray; } });
13
+ Object.defineProperty(exports, "isNe", { enumerable: true, get: function () { return isNotEmpty_1.isNotEmptyArray; } });
14
+ const join_1 = require("./join");
15
+ Object.defineProperty(exports, "join", { enumerable: true, get: function () { return join_1.join; } });
16
+ const mapFn_1 = require("./mapFn");
17
+ Object.defineProperty(exports, "mapFn", { enumerable: true, get: function () { return mapFn_1.mapFn; } });
18
+ const mapKey_1 = require("./mapKey");
19
+ Object.defineProperty(exports, "mapKey", { enumerable: true, get: function () { return mapKey_1.mapKey; } });
20
+ const mapPrimitive_1 = require("./mapPrimitive");
21
+ Object.defineProperty(exports, "mapPrimitive", { enumerable: true, get: function () { return mapPrimitive_1.mapPrimitive; } });
22
+ const shuffle_1 = require("./shuffle");
23
+ Object.defineProperty(exports, "shuffle", { enumerable: true, get: function () { return shuffle_1.shuffle; } });
24
+ const sort_1 = require("./sort");
25
+ Object.defineProperty(exports, "sort", { enumerable: true, get: function () { return sort_1.sort; } });
package/array/is.d.ts CHANGED
@@ -5,4 +5,5 @@
5
5
  *
6
6
  * @returns Whether or not the value is an array
7
7
  */
8
- export default function isArray(val: unknown): val is unknown[];
8
+ declare function isArray(val: unknown): val is unknown[];
9
+ export { isArray, isArray as default };
package/array/is.js CHANGED
@@ -1,6 +1,8 @@
1
1
  'use strict';
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = exports.isArray = void 0;
3
4
  function isArray(val) {
4
5
  return Array.isArray(val);
5
6
  }
7
+ exports.isArray = isArray;
6
8
  exports.default = isArray;
@@ -5,4 +5,5 @@
5
5
  *
6
6
  * @returns Whether or not the value is an array with content
7
7
  */
8
- export default function isNotEmptyArray(val: unknown): val is unknown[];
8
+ declare function isNotEmptyArray(val: unknown): val is unknown[];
9
+ export { isNotEmptyArray, isNotEmptyArray as default };
@@ -1,6 +1,8 @@
1
1
  'use strict';
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = exports.isNotEmptyArray = void 0;
3
4
  function isNotEmptyArray(val) {
4
5
  return Array.isArray(val) && val.length !== 0;
5
6
  }
7
+ exports.isNotEmptyArray = isNotEmptyArray;
6
8
  exports.default = isNotEmptyArray;
package/array/join.d.ts CHANGED
@@ -32,5 +32,5 @@ interface joinOptions {
32
32
  *
33
33
  * @returns Joined array as string
34
34
  */
35
- export default function join(val: unknown[], opts?: joinOptions): string;
36
- export {};
35
+ declare function join(val: unknown[], opts?: joinOptions): string;
36
+ export { join, join as default };
package/array/join.js CHANGED
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = exports.join = void 0;
3
4
  const round_1 = require("../number/round");
4
5
  function join(val, opts) {
5
6
  if (!Array.isArray(val) || !val.length)
@@ -24,9 +25,10 @@ function join(val, opts) {
24
25
  filtered.push(VALTRIM ? el.trim() : el);
25
26
  }
26
27
  else if (Number.isFinite(el)) {
27
- filtered.push(VALROUND !== false ? (0, round_1.default)(el, VALROUND) : el);
28
+ filtered.push(VALROUND !== false ? (0, round_1.round)(el, VALROUND) : el);
28
29
  }
29
30
  }
30
31
  return TRIM ? filtered.join(DELIM).trim() : filtered.join(DELIM);
31
32
  }
33
+ exports.join = join;
32
34
  exports.default = join;
package/array/mapFn.d.ts CHANGED
@@ -12,10 +12,7 @@ interface mapOptions {
12
12
  */
13
13
  merge?: boolean;
14
14
  }
15
- type mapFn = (entry: {
16
- [key: string]: any;
17
- }) => (string | number | boolean);
18
- type mapReturn = Record<string, Record<string, any>>;
15
+ type mapFn<T extends Record<string, any>> = (entry: T) => (string | number | boolean);
19
16
  /**
20
17
  * Map an object array into a kv-object through a function that generates a key. Returning a non-string,
21
18
  * non-numeric value from the function (eg: false) will filter out the object.
@@ -29,7 +26,7 @@ type mapReturn = Record<string, Record<string, any>>;
29
26
  * @param {mapFn} fn - Handler function which is run for each of the objects and should return a string or number
30
27
  * @param {mapOptions?} opts - Options object to override built-in defaults
31
28
  *
32
- * @returns {mapReturn} KV-Map object
29
+ * @returns {Record<string, T>} KV-Map object
33
30
  */
34
- export default function mapFn(arr: Record<string, any>[], fn: mapFn, opts?: mapOptions): mapReturn;
35
- export {};
31
+ declare function mapFn<T extends Record<string, any>>(arr: T[], fn: mapFn<T>, opts?: mapOptions): Record<string, T>;
32
+ export { mapFn, mapFn as default };
package/array/mapFn.js CHANGED
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = exports.mapFn = void 0;
3
4
  function mapFn(arr, fn, opts) {
4
5
  if ((!Array.isArray(arr) || !arr.length) ||
5
6
  typeof fn !== 'function')
@@ -18,4 +19,5 @@ function mapFn(arr, fn, opts) {
18
19
  }
19
20
  return map;
20
21
  }
22
+ exports.mapFn = mapFn;
21
23
  exports.default = mapFn;
package/array/mapKey.d.ts CHANGED
@@ -12,7 +12,6 @@ interface mapOptions {
12
12
  */
13
13
  merge?: boolean;
14
14
  }
15
- type kvMap = Record<string, Record<string, any>>;
16
15
  /**
17
16
  * Map an object array into a kv-object by passing a common key that exists on the objects. Objects for
18
17
  * which the key doesn't exist will be filtered out automatically
@@ -26,7 +25,7 @@ type kvMap = Record<string, Record<string, any>>;
26
25
  * @param {string} key - Key to map by
27
26
  * @param {mapOptions?} opts - Options object to override built-in defaults
28
27
  *
29
- * @returns {kvMap} KV-Map object
28
+ * @returns {Record<string, T>} KV-Map object
30
29
  */
31
- export default function mapKey(arr: Record<string, any>[], key: string, opts?: mapOptions): kvMap;
32
- export {};
30
+ declare function mapKey<T extends Record<string, any>>(arr: T[], key: string, opts?: mapOptions): Record<string, T>;
31
+ export { mapKey, mapKey as default };
package/array/mapKey.js CHANGED
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = exports.mapKey = void 0;
3
4
  function mapKey(arr, key, opts) {
4
5
  if ((!Array.isArray(arr) || !arr.length) ||
5
6
  typeof key !== 'string')
@@ -17,4 +18,5 @@ function mapKey(arr, key, opts) {
17
18
  }
18
19
  return map;
19
20
  }
21
+ exports.mapKey = mapKey;
20
22
  exports.default = mapKey;
@@ -34,5 +34,5 @@ type mapReturn = Record<string, string | number>;
34
34
  *
35
35
  * @returns {mapReturn} KV-Map object
36
36
  */
37
- export default function mapPrimitive(arr: unknown[], opts?: mapOptions): mapReturn;
38
- export {};
37
+ declare function mapPrimitive(arr: unknown[], opts?: mapOptions): mapReturn;
38
+ export { mapPrimitive, mapPrimitive as default };
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = exports.mapPrimitive = void 0;
3
4
  const round_1 = require("../number/round");
4
5
  function mapPrimitive(arr, opts) {
5
6
  if (!Array.isArray(arr) || !arr.length)
@@ -29,9 +30,10 @@ function mapPrimitive(arr, opts) {
29
30
  ? el
30
31
  : VALROUND === true
31
32
  ? Math.round(el)
32
- : (0, round_1.default)(el, VALROUND);
33
+ : (0, round_1.round)(el, VALROUND);
33
34
  }
34
35
  }
35
36
  return map;
36
37
  }
38
+ exports.mapPrimitive = mapPrimitive;
37
39
  exports.default = mapPrimitive;
@@ -6,4 +6,5 @@
6
6
  *
7
7
  * @param val - Array to shuffle
8
8
  */
9
- export default function shuffle(arr: unknown[]): void;
9
+ declare function shuffle(arr: unknown[]): void;
10
+ export { shuffle, shuffle as default };
package/array/shuffle.js CHANGED
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = exports.shuffle = void 0;
3
4
  function shuffle(arr) {
4
5
  if (!Array.isArray(arr))
5
6
  return;
@@ -8,4 +9,5 @@ function shuffle(arr) {
8
9
  [arr[i], arr[j]] = [arr[j], arr[i]];
9
10
  }
10
11
  }
12
+ exports.shuffle = shuffle;
11
13
  exports.default = shuffle;
package/array/sort.d.ts CHANGED
@@ -54,5 +54,5 @@ type sortByFunction = (el: sortObject) => string;
54
54
  * @returns Sorted array
55
55
  * @throws {Error}
56
56
  */
57
- export default function sort(arr: sortObject[], by: string | sortByFunction, dir?: 'asc' | 'desc', opts?: sortOptions): sortObject[];
58
- export {};
57
+ declare function sort(arr: sortObject[], by: string | sortByFunction, dir?: 'asc' | 'desc', opts?: sortOptions): sortObject[];
58
+ export { sort, sort as default };
package/array/sort.js CHANGED
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = exports.sort = void 0;
3
4
  const isNotEmpty_1 = require("../object/isNotEmpty");
4
5
  function partition(arr, start_ix, end_ix) {
5
6
  const pivot_val = arr[Math.floor((start_ix + end_ix) / 2)].t;
@@ -35,7 +36,7 @@ function sort(arr, by, dir = 'asc', opts) {
35
36
  throw new Error('Direction should be either asc or desc');
36
37
  let NOKEY_HIDE = false;
37
38
  let NOKEY_AT_END = true;
38
- let FILTER_FN = isNotEmpty_1.default;
39
+ let FILTER_FN = isNotEmpty_1.isNotEmptyObject;
39
40
  if (opts && Object.prototype.toString.call(opts) === '[object Object]') {
40
41
  if (opts.nokey_hide === true)
41
42
  NOKEY_HIDE = true;
@@ -43,7 +44,7 @@ function sort(arr, by, dir = 'asc', opts) {
43
44
  NOKEY_AT_END = false;
44
45
  if (typeof opts.filter_fn === 'function') {
45
46
  const fn = opts.filter_fn;
46
- FILTER_FN = (el => (0, isNotEmpty_1.default)(el) && fn(el));
47
+ FILTER_FN = (el => (0, isNotEmpty_1.isNotEmptyObject)(el) && fn(el));
47
48
  }
48
49
  }
49
50
  const prepared_arr = [];
@@ -102,4 +103,5 @@ function sort(arr, by, dir = 'asc', opts) {
102
103
  }
103
104
  return result;
104
105
  }
106
+ exports.sort = sort;
105
107
  exports.default = sort;
@@ -0,0 +1,2 @@
1
+ import { isBoolean } from './is';
2
+ export { isBoolean, isBoolean as is };
@@ -0,0 +1,6 @@
1
+ 'use strict';
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.is = exports.isBoolean = void 0;
4
+ const is_1 = require("./is");
5
+ Object.defineProperty(exports, "isBoolean", { enumerable: true, get: function () { return is_1.isBoolean; } });
6
+ Object.defineProperty(exports, "is", { enumerable: true, get: function () { return is_1.isBoolean; } });
package/boolean/is.d.ts CHANGED
@@ -5,4 +5,5 @@
5
5
  *
6
6
  * @returns Whether or not the value is a boolean
7
7
  */
8
- export default function isBoolean(val: unknown): val is boolean;
8
+ declare function isBoolean(val: unknown): val is boolean;
9
+ export { isBoolean, isBoolean as default };
package/boolean/is.js CHANGED
@@ -1,6 +1,8 @@
1
1
  'use strict';
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = exports.isBoolean = void 0;
3
4
  function isBoolean(val) {
4
5
  return val === true || val === false;
5
6
  }
7
+ exports.isBoolean = isBoolean;
6
8
  exports.default = isBoolean;
@@ -0,0 +1,2 @@
1
+ import { memoize } from './memoize';
2
+ export { memoize };
@@ -0,0 +1,5 @@
1
+ 'use strict';
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.memoize = void 0;
4
+ const memoize_1 = require("./memoize");
5
+ Object.defineProperty(exports, "memoize", { enumerable: true, get: function () { return memoize_1.memoize; } });
@@ -7,4 +7,5 @@
7
7
  * @param fn - Function to memoize
8
8
  * @param resolver - Optional resolver function to generate cache key. If not passed the first argument is used as map key
9
9
  */
10
- export default function memoize(fn: Function, resolver?: Function): Function;
10
+ declare function memoize(fn: Function, resolver?: Function): Function;
11
+ export { memoize, memoize as default };
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = exports.memoize = void 0;
3
4
  function memoize(fn, resolver) {
4
5
  const memoized = function () {
5
6
  const key = typeof resolver === 'function' ? resolver.apply(this, arguments) : arguments[0];
@@ -12,4 +13,5 @@ function memoize(fn, resolver) {
12
13
  memoized.cache = new Map();
13
14
  return memoized;
14
15
  }
16
+ exports.memoize = memoize;
15
17
  exports.default = memoize;
package/date/addUTC.d.ts CHANGED
@@ -7,4 +7,5 @@
7
7
  *
8
8
  * @returns New date with provided amount of key added
9
9
  */
10
- export default function addUTC(val: Date, amt?: number, key?: 'years' | 'year' | 'months' | 'month' | 'days' | 'day' | 'hours' | 'hour' | 'minutes' | 'minute' | 'seconds' | 'second' | 'milliseconds' | 'millisecond'): Date;
10
+ declare function addUTC(val: Date, amt?: number, key?: 'years' | 'year' | 'months' | 'month' | 'days' | 'day' | 'hours' | 'hour' | 'minutes' | 'minute' | 'seconds' | 'second' | 'milliseconds' | 'millisecond'): Date;
11
+ export { addUTC, addUTC as default };
package/date/addUTC.js CHANGED
@@ -1,13 +1,12 @@
1
1
  'use strict';
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = exports.addUTC = void 0;
3
4
  const is_1 = require("./is");
4
5
  function addUTC(val, amt = 0, key = 'millisecond') {
5
- if (!(0, is_1.default)(val))
6
+ if (!(0, is_1.isDate)(val))
6
7
  throw new TypeError('addUTC requires a date object');
7
8
  if (!Number.isInteger(amt))
8
9
  throw new TypeError('Amount needs to be an integer');
9
- if (typeof key !== 'string')
10
- throw new TypeError('Key needs to be a string with content');
11
10
  const year = val.getUTCFullYear();
12
11
  const month = val.getUTCMonth();
13
12
  const date = val.getUTCDate();
@@ -41,4 +40,5 @@ function addUTC(val, amt = 0, key = 'millisecond') {
41
40
  return new Date(Date.UTC(year, month, date, hour, min, sec, ms));
42
41
  }
43
42
  }
43
+ exports.addUTC = addUTC;
44
44
  exports.default = addUTC;
package/date/diff.d.ts CHANGED
@@ -7,4 +7,5 @@
7
7
  *
8
8
  * @returns Numerical diff between two dates
9
9
  */
10
- export default function diff(val_a: Date, val_b: Date, key?: 'week' | 'weeks' | 'day' | 'days' | 'hour' | 'hours' | 'minute' | 'minutes' | 'second' | 'seconds' | 'millisecond' | 'milliseconds'): number;
10
+ declare function diff(val_a: Date, val_b: Date, key?: 'week' | 'weeks' | 'day' | 'days' | 'hour' | 'hours' | 'minute' | 'minutes' | 'second' | 'seconds' | 'millisecond' | 'milliseconds'): number;
11
+ export { diff, diff as default };
package/date/diff.js CHANGED
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = exports.diff = void 0;
3
4
  const is_1 = require("./is");
4
5
  const SECOND_IN_MILLISECONDS = 1000;
5
6
  const MINUTE_IN_MILLISECONDS = SECOND_IN_MILLISECONDS * 60;
@@ -7,8 +8,8 @@ const HOUR_IN_MILLISECONDS = MINUTE_IN_MILLISECONDS * 60;
7
8
  const DAY_IN_MILLISECONDS = HOUR_IN_MILLISECONDS * 24;
8
9
  const WEEK_IN_MILLISECONDS = DAY_IN_MILLISECONDS * 7;
9
10
  function diff(val_a, val_b, key = 'millisecond') {
10
- if (!(0, is_1.default)(val_a) ||
11
- !(0, is_1.default)(val_b))
11
+ if (!(0, is_1.isDate)(val_a) ||
12
+ !(0, is_1.isDate)(val_b))
12
13
  throw new TypeError('Diff requires date objects for both values');
13
14
  if (typeof key !== 'string')
14
15
  throw new TypeError('Key needs to be a string');
@@ -33,4 +34,5 @@ function diff(val_a, val_b, key = 'millisecond') {
33
34
  return diff_in_ms;
34
35
  }
35
36
  }
37
+ exports.diff = diff;
36
38
  exports.default = diff;
@@ -6,4 +6,5 @@
6
6
  *
7
7
  * @returns New date set to end of key
8
8
  */
9
- export default function endOfUTC(val: Date, key?: 'year' | 'quarter' | 'month' | 'week' | 'week_sun' | 'week_mon' | 'week_tue' | 'week_wed' | 'week_thu' | 'week_fri' | 'week_sat' | 'day' | 'hour' | 'minute' | 'second' | 'millisecond'): Date;
9
+ declare function endOfUTC(val: Date, key?: 'year' | 'quarter' | 'month' | 'week' | 'week_sun' | 'week_mon' | 'week_tue' | 'week_wed' | 'week_thu' | 'week_fri' | 'week_sat' | 'day' | 'hour' | 'minute' | 'second' | 'millisecond'): Date;
10
+ export { endOfUTC, endOfUTC as default };
package/date/endOfUTC.js CHANGED
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = exports.endOfUTC = void 0;
3
4
  const is_1 = require("./is");
4
5
  const WEEK_END = new Map([
5
6
  ['week', 0],
@@ -12,10 +13,8 @@ const WEEK_END = new Map([
12
13
  ['week_sat', 5],
13
14
  ]);
14
15
  function endOfUTC(val, key = 'millisecond') {
15
- if (!(0, is_1.default)(val))
16
+ if (!(0, is_1.isDate)(val))
16
17
  throw new TypeError('endOfUTC requires a date object');
17
- if (typeof key !== 'string')
18
- throw new TypeError('Key needs to be a string with content');
19
18
  switch (key) {
20
19
  case 'year':
21
20
  return new Date(Date.UTC(val.getUTCFullYear(), 11, 31, 23, 59, 59, 999));
@@ -49,4 +48,5 @@ function endOfUTC(val, key = 'millisecond') {
49
48
  return new Date(Date.UTC(val.getUTCFullYear(), val.getUTCMonth(), val.getUTCDate(), val.getUTCHours(), val.getUTCMinutes(), val.getUTCSeconds(), val.getUTCMilliseconds()));
50
49
  }
51
50
  }
51
+ exports.endOfUTC = endOfUTC;
52
52
  exports.default = endOfUTC;
package/date/format.d.ts CHANGED
@@ -8,4 +8,5 @@
8
8
  * @returns {string} Formatted date as string
9
9
  * @throws {TypeError} When provided invalid payload
10
10
  */
11
- export default function format(val: Date, spec: string, locale?: string, zone?: string): string;
11
+ declare function format(val: Date, spec: string, locale?: string, zone?: string): string;
12
+ export { format, format as default };
package/date/format.js CHANGED
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = exports.format = void 0;
3
4
  const is_1 = require("./is");
4
5
  const DEFAULT_LOCALE = 'en-US';
5
6
  let DEFAULT_TZ = 'UTC';
@@ -91,7 +92,7 @@ function getSpecChain(spec) {
91
92
  return spec_chain;
92
93
  }
93
94
  function format(val, spec, locale = DEFAULT_LOCALE, zone = DEFAULT_TZ) {
94
- if (!(0, is_1.default)(val))
95
+ if (!(0, is_1.isDate)(val))
95
96
  throw new TypeError('format: val must be a Date');
96
97
  if (typeof spec !== 'string' || !spec.trim().length)
97
98
  throw new TypeError('format: spec must be a non-empty string');
@@ -122,4 +123,5 @@ function format(val, spec, locale = DEFAULT_LOCALE, zone = DEFAULT_TZ) {
122
123
  }
123
124
  return formatted_string;
124
125
  }
126
+ exports.format = format;
125
127
  exports.default = format;
@@ -0,0 +1,11 @@
1
+ import { addUTC } from './addUTC';
2
+ import { diff } from './diff';
3
+ import { endOfUTC } from './endOfUTC';
4
+ import { format } from './format';
5
+ import { isDate } from './is';
6
+ import { nowUnix } from './nowUnix';
7
+ import { nowUnixMs } from './nowUnixMs';
8
+ import { startOfUTC } from './startOfUTC';
9
+ import { toUnix } from './toUnix';
10
+ import { toUTC } from './toUTC';
11
+ export { addUTC, diff, endOfUTC, format, isDate, isDate as is, nowUnix, nowUnixMs, startOfUTC, toUnix, toUTC };
package/date/index.js ADDED
@@ -0,0 +1,24 @@
1
+ 'use strict';
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toUTC = exports.toUnix = exports.startOfUTC = exports.nowUnixMs = exports.nowUnix = exports.is = exports.isDate = exports.format = exports.endOfUTC = exports.diff = exports.addUTC = void 0;
4
+ const addUTC_1 = require("./addUTC");
5
+ Object.defineProperty(exports, "addUTC", { enumerable: true, get: function () { return addUTC_1.addUTC; } });
6
+ const diff_1 = require("./diff");
7
+ Object.defineProperty(exports, "diff", { enumerable: true, get: function () { return diff_1.diff; } });
8
+ const endOfUTC_1 = require("./endOfUTC");
9
+ Object.defineProperty(exports, "endOfUTC", { enumerable: true, get: function () { return endOfUTC_1.endOfUTC; } });
10
+ const format_1 = require("./format");
11
+ Object.defineProperty(exports, "format", { enumerable: true, get: function () { return format_1.format; } });
12
+ const is_1 = require("./is");
13
+ Object.defineProperty(exports, "isDate", { enumerable: true, get: function () { return is_1.isDate; } });
14
+ Object.defineProperty(exports, "is", { enumerable: true, get: function () { return is_1.isDate; } });
15
+ const nowUnix_1 = require("./nowUnix");
16
+ Object.defineProperty(exports, "nowUnix", { enumerable: true, get: function () { return nowUnix_1.nowUnix; } });
17
+ const nowUnixMs_1 = require("./nowUnixMs");
18
+ Object.defineProperty(exports, "nowUnixMs", { enumerable: true, get: function () { return nowUnixMs_1.nowUnixMs; } });
19
+ const startOfUTC_1 = require("./startOfUTC");
20
+ Object.defineProperty(exports, "startOfUTC", { enumerable: true, get: function () { return startOfUTC_1.startOfUTC; } });
21
+ const toUnix_1 = require("./toUnix");
22
+ Object.defineProperty(exports, "toUnix", { enumerable: true, get: function () { return toUnix_1.toUnix; } });
23
+ const toUTC_1 = require("./toUTC");
24
+ Object.defineProperty(exports, "toUTC", { enumerable: true, get: function () { return toUTC_1.toUTC; } });
package/date/is.d.ts CHANGED
@@ -5,4 +5,5 @@
5
5
  *
6
6
  * @returns Whether or not the value is a Date
7
7
  */
8
- export default function isDate(val: unknown): val is Date;
8
+ declare function isDate(val: unknown): val is Date;
9
+ export { isDate, isDate as default };
package/date/is.js CHANGED
@@ -1,6 +1,8 @@
1
1
  'use strict';
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = exports.isDate = void 0;
3
4
  function isDate(val) {
4
5
  return val instanceof Date && !isNaN(val);
5
6
  }
7
+ exports.isDate = isDate;
6
8
  exports.default = isDate;
package/date/nowUnix.d.ts CHANGED
@@ -3,4 +3,5 @@
3
3
  *
4
4
  * @returns Current unix timestamp in seconds
5
5
  */
6
- export default function nowUnix(): number;
6
+ declare function nowUnix(): number;
7
+ export { nowUnix, nowUnix as default };
package/date/nowUnix.js CHANGED
@@ -1,6 +1,8 @@
1
1
  'use strict';
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = exports.nowUnix = void 0;
3
4
  function nowUnix() {
4
5
  return Math.floor(Date.now() / 1000);
5
6
  }
7
+ exports.nowUnix = nowUnix;
6
8
  exports.default = nowUnix;
@@ -3,4 +3,5 @@
3
3
  *
4
4
  * @returns Current unix timestamp in milliseconds
5
5
  */
6
- export default function nowUnixMs(): number;
6
+ declare function nowUnixMs(): number;
7
+ export { nowUnixMs, nowUnixMs as default };
package/date/nowUnixMs.js CHANGED
@@ -1,6 +1,8 @@
1
1
  'use strict';
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = exports.nowUnixMs = void 0;
3
4
  function nowUnixMs() {
4
5
  return Math.floor(Date.now());
5
6
  }
7
+ exports.nowUnixMs = nowUnixMs;
6
8
  exports.default = nowUnixMs;