@valkyriestudios/utils 12.3.0 → 12.4.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 (133) hide show
  1. package/README.md +6 -3
  2. package/array/dedupe.d.ts +2 -1
  3. package/array/dedupe.js +3 -1
  4. package/array/is.d.ts +2 -1
  5. package/array/is.js +2 -0
  6. package/array/isNotEmpty.d.ts +2 -1
  7. package/array/isNotEmpty.js +2 -0
  8. package/array/join.d.ts +2 -2
  9. package/array/join.js +3 -1
  10. package/array/mapFn.d.ts +4 -7
  11. package/array/mapFn.js +2 -0
  12. package/array/mapKey.d.ts +3 -4
  13. package/array/mapKey.js +2 -0
  14. package/array/mapPrimitive.d.ts +2 -2
  15. package/array/mapPrimitive.js +3 -1
  16. package/array/shuffle.d.ts +2 -1
  17. package/array/shuffle.js +2 -0
  18. package/array/sort.d.ts +2 -2
  19. package/array/sort.js +4 -2
  20. package/boolean/is.d.ts +2 -1
  21. package/boolean/is.js +2 -0
  22. package/caching/memoize.d.ts +2 -1
  23. package/caching/memoize.js +2 -0
  24. package/date/addUTC.d.ts +2 -1
  25. package/date/addUTC.js +3 -3
  26. package/date/diff.d.ts +2 -1
  27. package/date/diff.js +4 -2
  28. package/date/endOfUTC.d.ts +2 -1
  29. package/date/endOfUTC.js +3 -3
  30. package/date/format.d.ts +2 -1
  31. package/date/format.js +3 -1
  32. package/date/is.d.ts +2 -1
  33. package/date/is.js +2 -0
  34. package/date/nowUnix.d.ts +2 -1
  35. package/date/nowUnix.js +2 -0
  36. package/date/nowUnixMs.d.ts +2 -1
  37. package/date/nowUnixMs.js +2 -0
  38. package/date/startOfUTC.d.ts +2 -1
  39. package/date/startOfUTC.js +3 -3
  40. package/date/toUTC.d.ts +2 -1
  41. package/date/toUTC.js +3 -1
  42. package/date/toUnix.d.ts +2 -1
  43. package/date/toUnix.js +3 -1
  44. package/deep/freeze.d.ts +2 -2
  45. package/deep/freeze.js +2 -0
  46. package/deep/get.d.ts +2 -1
  47. package/deep/get.js +2 -0
  48. package/deep/seal.d.ts +2 -2
  49. package/deep/seal.js +2 -0
  50. package/deep/set.d.ts +2 -1
  51. package/deep/set.js +2 -0
  52. package/equal.d.ts +1 -1
  53. package/equal.js +4 -2
  54. package/function/is.d.ts +2 -1
  55. package/function/is.js +2 -0
  56. package/function/isAsync.d.ts +2 -1
  57. package/function/isAsync.js +2 -0
  58. package/function/noop.d.ts +2 -1
  59. package/function/noop.js +2 -0
  60. package/function/noopresolve.d.ts +2 -1
  61. package/function/noopresolve.js +2 -0
  62. package/function/noopreturn.d.ts +2 -1
  63. package/function/noopreturn.js +2 -0
  64. package/function/sleep.d.ts +2 -1
  65. package/function/sleep.js +2 -0
  66. package/hash/fnv1A.d.ts +2 -1
  67. package/hash/fnv1A.js +2 -0
  68. package/hash/guid.d.ts +2 -1
  69. package/hash/guid.js +2 -0
  70. package/index.d.ts +153 -95
  71. package/is.d.ts +26 -26
  72. package/is.js +51 -49
  73. package/number/is.d.ts +2 -1
  74. package/number/is.js +2 -0
  75. package/number/isAbove.d.ts +2 -1
  76. package/number/isAbove.js +2 -0
  77. package/number/isAboveOrEqual.d.ts +2 -1
  78. package/number/isAboveOrEqual.js +2 -0
  79. package/number/isBelow.d.ts +2 -1
  80. package/number/isBelow.js +2 -0
  81. package/number/isBelowOrEqual.d.ts +2 -1
  82. package/number/isBelowOrEqual.js +2 -0
  83. package/number/isBetween.d.ts +2 -1
  84. package/number/isBetween.js +2 -0
  85. package/number/isInteger.d.ts +2 -1
  86. package/number/isInteger.js +2 -0
  87. package/number/isIntegerAbove.d.ts +2 -1
  88. package/number/isIntegerAbove.js +2 -0
  89. package/number/isIntegerAboveOrEqual.d.ts +2 -1
  90. package/number/isIntegerAboveOrEqual.js +2 -0
  91. package/number/isIntegerBelow.d.ts +2 -1
  92. package/number/isIntegerBelow.js +2 -0
  93. package/number/isIntegerBelowOrEqual.d.ts +2 -1
  94. package/number/isIntegerBelowOrEqual.js +2 -0
  95. package/number/isIntegerBetween.d.ts +2 -1
  96. package/number/isIntegerBetween.js +2 -0
  97. package/number/isNumericalNaN.d.ts +2 -1
  98. package/number/isNumericalNaN.js +2 -0
  99. package/number/randomBetween.d.ts +2 -1
  100. package/number/randomBetween.js +2 -0
  101. package/number/randomIntBetween.d.ts +2 -1
  102. package/number/randomIntBetween.js +2 -0
  103. package/number/round.d.ts +2 -1
  104. package/number/round.js +2 -0
  105. package/number/toPercentage.d.ts +2 -1
  106. package/number/toPercentage.js +3 -1
  107. package/object/define.d.ts +2 -1
  108. package/object/define.js +2 -0
  109. package/object/is.d.ts +2 -1
  110. package/object/is.js +2 -0
  111. package/object/isNotEmpty.d.ts +2 -1
  112. package/object/isNotEmpty.js +2 -0
  113. package/object/merge.d.ts +1 -1
  114. package/object/merge.js +2 -0
  115. package/object/pick.d.ts +2 -1
  116. package/object/pick.js +4 -2
  117. package/package.json +1 -1
  118. package/regexp/is.d.ts +2 -1
  119. package/regexp/is.js +2 -0
  120. package/regexp/sanitize.d.ts +2 -1
  121. package/regexp/sanitize.js +2 -0
  122. package/string/humanizeBytes.d.ts +2 -2
  123. package/string/humanizeBytes.js +4 -3
  124. package/string/humanizeNumber.d.ts +2 -2
  125. package/string/humanizeNumber.js +3 -1
  126. package/string/is.d.ts +2 -1
  127. package/string/is.js +2 -0
  128. package/string/isBetween.d.ts +2 -1
  129. package/string/isBetween.js +2 -0
  130. package/string/isNotEmpty.d.ts +2 -1
  131. package/string/isNotEmpty.js +2 -0
  132. package/string/shorten.d.ts +2 -1
  133. 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
@@ -847,4 +850,4 @@ humanizeNumber(47328748923747923479); // '47,328.75q'
847
850
  allows passing options to control the output, following options are possible:
848
851
 
849
852
  ## Contributors
850
- - [Peter Vermeulen](mailto:contact@valkyriestudios.be)
853
+ - [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;
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;
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;
@@ -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;
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;
@@ -6,4 +6,5 @@
6
6
  *
7
7
  * @returns New date set to start of key
8
8
  */
9
- export default function startOfUTC(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 startOfUTC(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 { startOfUTC, startOfUTC as default };
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = exports.startOfUTC = void 0;
3
4
  const is_1 = require("./is");
4
5
  const WEEK_START = new Map([
5
6
  ['week', 1],
@@ -12,10 +13,8 @@ const WEEK_START = new Map([
12
13
  ['week_sat', 6],
13
14
  ]);
14
15
  function startOfUTC(val, key = 'millisecond') {
15
- if (!(0, is_1.default)(val))
16
+ if (!(0, is_1.isDate)(val))
16
17
  throw new TypeError('startOfUTC 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(), 0, 1, 0, 0, 0, 0));
@@ -49,4 +48,5 @@ function startOfUTC(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.startOfUTC = startOfUTC;
52
52
  exports.default = startOfUTC;
package/date/toUTC.d.ts CHANGED
@@ -5,4 +5,5 @@
5
5
  *
6
6
  * @returns New date object set to the UTC contents of the passed date
7
7
  */
8
- export default function toUTC(val: Date): Date;
8
+ declare function toUTC(val: Date): Date;
9
+ export { toUTC, toUTC as default };
package/date/toUTC.js CHANGED
@@ -1,9 +1,11 @@
1
1
  'use strict';
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = exports.toUTC = void 0;
3
4
  const is_1 = require("./is");
4
5
  function toUTC(val) {
5
- if (!(0, is_1.default)(val))
6
+ if (!(0, is_1.isDate)(val))
6
7
  throw new TypeError('toUTC requires a date object');
7
8
  return new Date(Date.UTC(val.getUTCFullYear(), val.getUTCMonth(), val.getUTCDate(), val.getUTCHours(), val.getUTCMinutes(), val.getUTCSeconds(), val.getUTCMilliseconds()));
8
9
  }
10
+ exports.toUTC = toUTC;
9
11
  exports.default = toUTC;
package/date/toUnix.d.ts CHANGED
@@ -5,4 +5,5 @@
5
5
  *
6
6
  * @returns Unix time in seconds
7
7
  */
8
- export default function toUnix(val: Date): number;
8
+ declare function toUnix(val: Date): number;
9
+ export { toUnix, toUnix as default };
package/date/toUnix.js CHANGED
@@ -1,9 +1,11 @@
1
1
  'use strict';
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = exports.toUnix = void 0;
3
4
  const is_1 = require("./is");
4
5
  function toUnix(val) {
5
- if (!(0, is_1.default)(val))
6
+ if (!(0, is_1.isDate)(val))
6
7
  throw new TypeError('toUnix requires a date object');
7
8
  return Math.floor(val.valueOf() / 1000);
8
9
  }
10
+ exports.toUnix = toUnix;
9
11
  exports.default = toUnix;
package/deep/freeze.d.ts CHANGED
@@ -13,5 +13,5 @@ type Frozen<T> = {
13
13
  *
14
14
  * @returns Deeply frozen object
15
15
  */
16
- export default function deepFreeze<T extends deepInput>(obj: T): Frozen<T>;
17
- export {};
16
+ declare function deepFreeze<T extends deepInput>(obj: T): Frozen<T>;
17
+ export { deepFreeze, deepFreeze as default };
package/deep/freeze.js CHANGED
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = exports.deepFreeze = void 0;
3
4
  function deep(obj) {
4
5
  if (Array.isArray(obj)) {
5
6
  for (const el of obj)
@@ -20,4 +21,5 @@ function deepFreeze(obj) {
20
21
  throw new TypeError('Only objects/arrays can be frozen');
21
22
  return deep(obj);
22
23
  }
24
+ exports.deepFreeze = deepFreeze;
23
25
  exports.default = deepFreeze;
package/deep/get.d.ts CHANGED
@@ -20,8 +20,9 @@
20
20
  * @returns Value stored at property or undefined
21
21
  * @throws {TypeError}
22
22
  */
23
- export default function deepGet(obj: {
23
+ declare function deepGet(obj: {
24
24
  [key: string]: any;
25
25
  } | {
26
26
  [key: string]: any;
27
27
  }[] | any[], path: string, get_parent?: boolean): any | undefined;
28
+ export { deepGet, deepGet as default };
package/deep/get.js CHANGED
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = exports.deepGet = void 0;
3
4
  function deepGet(obj, path, get_parent = false) {
4
5
  if (Object.prototype.toString.call(obj) !== '[object Object]' &&
5
6
  !Array.isArray(obj))
@@ -38,4 +39,5 @@ function deepGet(obj, path, get_parent = false) {
38
39
  }
39
40
  return cursor;
40
41
  }
42
+ exports.deepGet = deepGet;
41
43
  exports.default = deepGet;
package/deep/seal.d.ts CHANGED
@@ -13,5 +13,5 @@ type Sealed<T> = {
13
13
  *
14
14
  * @returns Deeply sealed object
15
15
  */
16
- export default function deepSeal<T extends deepInput>(obj: T): Sealed<T>;
17
- export {};
16
+ declare function deepSeal<T extends deepInput>(obj: T): Sealed<T>;
17
+ export { deepSeal, deepSeal as default };