@oscarpalmer/atoms 0.80.0 → 0.81.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.
@@ -1,17 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const number = require("../number.cjs");
4
- function chunk(array, size) {
5
- const chunkSize = number.clamp(size ?? 5e3, 1, 5e3);
3
+ function chunk(array) {
6
4
  const { length } = array;
7
- if (length <= chunkSize) {
5
+ if (length <= 5e3) {
8
6
  return [array];
9
7
  }
10
8
  const chunks = [];
11
- let remaining = Number(length);
12
- while (remaining > 0) {
13
- chunks.push(array.splice(0, chunkSize));
14
- remaining -= chunkSize;
9
+ let index = 0;
10
+ while (index < length) {
11
+ chunks.push(array.slice(index, index + 5e3));
12
+ index += 5e3;
15
13
  }
16
14
  return chunks;
17
15
  }
@@ -1,15 +1,13 @@
1
- import { clamp } from "../number.js";
2
- function chunk(array, size) {
3
- const chunkSize = clamp(size ?? 5e3, 1, 5e3);
1
+ function chunk(array) {
4
2
  const { length } = array;
5
- if (length <= chunkSize) {
3
+ if (length <= 5e3) {
6
4
  return [array];
7
5
  }
8
6
  const chunks = [];
9
- let remaining = Number(length);
10
- while (remaining > 0) {
11
- chunks.push(array.splice(0, chunkSize));
12
- remaining -= chunkSize;
7
+ let index = 0;
8
+ while (index < length) {
9
+ chunks.push(array.slice(index, index + 5e3));
10
+ index += 5e3;
13
11
  }
14
12
  return chunks;
15
13
  }
@@ -1,6 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  function compact(array, strict) {
4
- return strict === true ? array.filter((item) => !!item) : array.filter((item) => item != null);
4
+ const isStrict = strict ?? false;
5
+ const { length } = array;
6
+ const compacted = [];
7
+ for (let index = 0; index < length; index += 1) {
8
+ const item = array[index];
9
+ if (isStrict && !!item || !isStrict && item != null) {
10
+ compacted.push(item);
11
+ }
12
+ }
13
+ return compacted;
5
14
  }
6
15
  exports.compact = compact;
@@ -1,5 +1,14 @@
1
1
  function compact(array, strict) {
2
- return strict === true ? array.filter((item) => !!item) : array.filter((item) => item != null);
2
+ const isStrict = strict ?? false;
3
+ const { length } = array;
4
+ const compacted = [];
5
+ for (let index = 0; index < length; index += 1) {
6
+ const item = array[index];
7
+ if (isStrict && !!item || !isStrict && item != null) {
8
+ compacted.push(item);
9
+ }
10
+ }
11
+ return compacted;
3
12
  }
4
13
  export {
5
14
  compact
package/dist/math.cjs CHANGED
@@ -1,13 +1,33 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- function average(values) {
4
- return values.length > 0 ? sum(values) / values.length : Number.NaN;
3
+ function average(array, key) {
4
+ return array.length === 0 ? Number.NaN : sum(array, key) / array.length;
5
5
  }
6
- function max(values) {
7
- return values.length > 0 ? Math.max(...values) : Number.NaN;
6
+ function max(array, key) {
7
+ const isCallback = typeof key === "function";
8
+ const { length } = array;
9
+ let max2;
10
+ for (let index = 0; index < length; index += 1) {
11
+ const item = array[index];
12
+ const value = isCallback ? key(item, index, array) : item[key] ?? item;
13
+ if (max2 == null || value > max2) {
14
+ max2 = value;
15
+ }
16
+ }
17
+ return max2 ?? Number.NaN;
8
18
  }
9
- function min(values) {
10
- return values.length > 0 ? Math.min(...values) : Number.NaN;
19
+ function min(array, key) {
20
+ const isCallback = typeof key === "function";
21
+ const { length } = array;
22
+ let min2;
23
+ for (let index = 0; index < length; index += 1) {
24
+ const item = array[index];
25
+ const value = isCallback ? key(item, index, array) : item[key] ?? item;
26
+ if (min2 == null || value < min2) {
27
+ min2 = value;
28
+ }
29
+ }
30
+ return min2 ?? Number.NaN;
11
31
  }
12
32
  function round(value, decimals) {
13
33
  if (typeof decimals !== "number" || decimals < 1) {
@@ -16,8 +36,15 @@ function round(value, decimals) {
16
36
  const mod = 10 ** decimals;
17
37
  return Math.round((value + Number.EPSILON) * mod) / mod;
18
38
  }
19
- function sum(values) {
20
- return values.reduce((previous, current) => previous + current, 0);
39
+ function sum(array, key) {
40
+ const isCallback = typeof key === "function";
41
+ const { length } = array;
42
+ let sum2 = 0;
43
+ for (let index = 0; index < length; index += 1) {
44
+ const value = array[index];
45
+ sum2 += isCallback ? key(value, index, array) : value[key] ?? value;
46
+ }
47
+ return sum2;
21
48
  }
22
49
  exports.average = average;
23
50
  exports.max = max;
package/dist/math.js CHANGED
@@ -1,11 +1,31 @@
1
- function average(values) {
2
- return values.length > 0 ? sum(values) / values.length : Number.NaN;
1
+ function average(array, key) {
2
+ return array.length === 0 ? Number.NaN : sum(array, key) / array.length;
3
3
  }
4
- function max(values) {
5
- return values.length > 0 ? Math.max(...values) : Number.NaN;
4
+ function max(array, key) {
5
+ const isCallback = typeof key === "function";
6
+ const { length } = array;
7
+ let max2;
8
+ for (let index = 0; index < length; index += 1) {
9
+ const item = array[index];
10
+ const value = isCallback ? key(item, index, array) : item[key] ?? item;
11
+ if (max2 == null || value > max2) {
12
+ max2 = value;
13
+ }
14
+ }
15
+ return max2 ?? Number.NaN;
6
16
  }
7
- function min(values) {
8
- return values.length > 0 ? Math.min(...values) : Number.NaN;
17
+ function min(array, key) {
18
+ const isCallback = typeof key === "function";
19
+ const { length } = array;
20
+ let min2;
21
+ for (let index = 0; index < length; index += 1) {
22
+ const item = array[index];
23
+ const value = isCallback ? key(item, index, array) : item[key] ?? item;
24
+ if (min2 == null || value < min2) {
25
+ min2 = value;
26
+ }
27
+ }
28
+ return min2 ?? Number.NaN;
9
29
  }
10
30
  function round(value, decimals) {
11
31
  if (typeof decimals !== "number" || decimals < 1) {
@@ -14,8 +34,15 @@ function round(value, decimals) {
14
34
  const mod = 10 ** decimals;
15
35
  return Math.round((value + Number.EPSILON) * mod) / mod;
16
36
  }
17
- function sum(values) {
18
- return values.reduce((previous, current) => previous + current, 0);
37
+ function sum(array, key) {
38
+ const isCallback = typeof key === "function";
39
+ const { length } = array;
40
+ let sum2 = 0;
41
+ for (let index = 0; index < length; index += 1) {
42
+ const value = array[index];
43
+ sum2 += isCallback ? key(value, index, array) : value[key] ?? value;
44
+ }
45
+ return sum2;
19
46
  }
20
47
  export {
21
48
  average,
@@ -65,7 +65,10 @@ function getDiffs(first, second, prefix) {
65
65
  if (!nested || nested && diffs.length > 0) {
66
66
  changes.push(change);
67
67
  }
68
- changes.push(...diffs);
68
+ const diffsLength = diffs.length;
69
+ for (let diffIndex = 0; diffIndex < diffsLength; diffIndex += 1) {
70
+ changes.push(diffs[diffIndex]);
71
+ }
69
72
  }
70
73
  checked.add(key);
71
74
  }
@@ -63,7 +63,10 @@ function getDiffs(first, second, prefix) {
63
63
  if (!nested || nested && diffs.length > 0) {
64
64
  changes.push(change);
65
65
  }
66
- changes.push(...diffs);
66
+ const diffsLength = diffs.length;
67
+ for (let diffIndex = 0; diffIndex < diffsLength; diffIndex += 1) {
68
+ changes.push(diffs[diffIndex]);
69
+ }
67
70
  }
68
71
  checked.add(key);
69
72
  }
package/package.json CHANGED
@@ -179,15 +179,8 @@
179
179
  }
180
180
  }
181
181
  },
182
- "files": [
183
- "dist",
184
- "src",
185
- "types"
186
- ],
187
- "keywords": [
188
- "helper",
189
- "utility"
190
- ],
182
+ "files": ["dist", "src", "types"],
183
+ "keywords": ["helper", "utility"],
191
184
  "license": "MIT",
192
185
  "main": "./dist/index.cjs",
193
186
  "module": "./dist/index.js",
@@ -205,5 +198,5 @@
205
198
  },
206
199
  "type": "module",
207
200
  "types": "./types/index.d.cts",
208
- "version": "0.80.0"
201
+ "version": "0.81.0"
209
202
  }
@@ -1,24 +1,21 @@
1
- import {clamp} from '../number';
2
-
3
1
  /**
4
- * Chunk an array _(into smaller arrays of a specified size)_
2
+ * Chunk an array _(into smaller arrays)_
5
3
  */
6
- export function chunk<Item>(array: Item[], size?: number): Item[][] {
7
- const chunkSize = clamp(size ?? 5_000, 1, 5_000);
4
+ export function chunk<Item>(array: Item[]): Item[][] {
8
5
  const {length} = array;
9
6
 
10
- if (length <= chunkSize) {
7
+ if (length <= 5_000) {
11
8
  return [array];
12
9
  }
13
10
 
14
11
  const chunks: Item[][] = [];
15
12
 
16
- let remaining = Number(length);
13
+ let index = 0;
17
14
 
18
- while (remaining > 0) {
19
- chunks.push(array.splice(0, chunkSize));
15
+ while (index < length) {
16
+ chunks.push(array.slice(index, index + 5_000));
20
17
 
21
- remaining -= chunkSize;
18
+ index += 5_000;
22
19
  }
23
20
 
24
21
  return chunks;
@@ -12,7 +12,17 @@ export function compact<Item>(
12
12
  ): Exclude<Item, 0 | '' | false | null | undefined>[];
13
13
 
14
14
  export function compact<Item>(array: Item[], strict?: boolean): Item[] {
15
- return strict === true
16
- ? array.filter(item => !!item)
17
- : array.filter(item => item != null);
15
+ const isStrict = strict ?? false;
16
+ const {length} = array;
17
+ const compacted: Item[] = [];
18
+
19
+ for (let index = 0; index < length; index += 1) {
20
+ const item = array[index];
21
+
22
+ if ((isStrict && !!item) || (!isStrict && item != null)) {
23
+ compacted.push(item);
24
+ }
25
+ }
26
+
27
+ return compacted;
18
28
  }
package/src/math.ts CHANGED
@@ -1,22 +1,98 @@
1
+ import type {GenericCallback, PlainObject} from './models';
2
+
3
+ type OnlyNumericalKeys<Item> = {
4
+ [Key in keyof Item as Item[Key] extends number ? Key : never]: Item[Key];
5
+ };
6
+
1
7
  /**
2
8
  * Get the average value from a list of numbers
3
9
  */
4
- export function average(values: number[]): number {
5
- return values.length > 0 ? sum(values) / values.length : Number.NaN;
10
+ export function average(values: number[]): number;
11
+
12
+ export function average<Item extends PlainObject>(
13
+ array: Item[],
14
+ key: keyof OnlyNumericalKeys<Item>,
15
+ ): number;
16
+
17
+ export function average<Item extends PlainObject>(
18
+ array: Item[],
19
+ callback: (item: Item, index: number, array: Item[]) => number,
20
+ ): number;
21
+
22
+ export function average(array: unknown[], key?: unknown): number {
23
+ return array.length === 0
24
+ ? Number.NaN
25
+ : sum(array as never[], key as never) / array.length;
6
26
  }
7
27
 
8
28
  /**
9
29
  * Get the maximum value from a list of numbers
10
30
  */
11
- export function max(values: number[]): number {
12
- return values.length > 0 ? Math.max(...values) : Number.NaN;
31
+ export function max(values: number[]): number;
32
+
33
+ export function max<Item extends PlainObject>(
34
+ array: Item[],
35
+ key: keyof OnlyNumericalKeys<Item>,
36
+ ): number;
37
+
38
+ export function max<Item extends PlainObject>(
39
+ array: Item[],
40
+ callback: (item: Item, index: number, array: Item[]) => number,
41
+ ): number;
42
+
43
+ export function max(array: unknown[], key?: unknown): number {
44
+ const isCallback = typeof key === 'function';
45
+ const {length} = array;
46
+ let max: number | undefined;
47
+
48
+ for (let index = 0; index < length; index += 1) {
49
+ const item = array[index];
50
+
51
+ const value = isCallback
52
+ ? (key as GenericCallback)(item, index, array)
53
+ : ((item as PlainObject)[key as never] ?? item);
54
+
55
+ if (max == null || value > max) {
56
+ max = value;
57
+ }
58
+ }
59
+
60
+ return max ?? Number.NaN;
13
61
  }
14
62
 
15
63
  /**
16
64
  * Get the minimum value from a list of numbers
17
65
  */
18
- export function min(values: number[]): number {
19
- return values.length > 0 ? Math.min(...values) : Number.NaN;
66
+ export function min(values: number[]): number;
67
+
68
+ export function min<Item extends PlainObject>(
69
+ array: Item[],
70
+ key: keyof OnlyNumericalKeys<Item>,
71
+ ): number;
72
+
73
+ export function min<Item extends PlainObject>(
74
+ array: Item[],
75
+ callback: (item: Item, index: number, array: Item[]) => number,
76
+ ): number;
77
+
78
+ export function min(array: unknown[], key?: unknown): number {
79
+ const isCallback = typeof key === 'function';
80
+ const {length} = array;
81
+ let min: number | undefined;
82
+
83
+ for (let index = 0; index < length; index += 1) {
84
+ const item = array[index];
85
+
86
+ const value = isCallback
87
+ ? (key as GenericCallback)(item, index, array)
88
+ : ((item as PlainObject)[key as never] ?? item);
89
+
90
+ if (min == null || value < min) {
91
+ min = value;
92
+ }
93
+ }
94
+
95
+ return min ?? Number.NaN;
20
96
  }
21
97
 
22
98
  /**
@@ -35,6 +111,30 @@ export function round(value: number, decimals?: number): number {
35
111
  /**
36
112
  * Get the sum of a list of numbers
37
113
  */
38
- export function sum(values: number[]): number {
39
- return values.reduce((previous, current) => previous + current, 0);
114
+ export function sum(values: number[]): number;
115
+
116
+ export function sum<Item extends PlainObject>(
117
+ array: Item[],
118
+ key: keyof OnlyNumericalKeys<Item>,
119
+ ): number;
120
+
121
+ export function sum<Item extends PlainObject>(
122
+ array: Item[],
123
+ callback: (item: Item, index: number, array: Item[]) => number,
124
+ ): number;
125
+
126
+ export function sum(array: unknown[], key?: unknown): number {
127
+ const isCallback = typeof key === 'function';
128
+ const {length} = array;
129
+ let sum = 0;
130
+
131
+ for (let index = 0; index < length; index += 1) {
132
+ const value = array[index];
133
+
134
+ sum += isCallback
135
+ ? (key as GenericCallback)(value, index, array)
136
+ : ((value as PlainObject)[key as never] ?? value);
137
+ }
138
+
139
+ return sum;
40
140
  }
package/src/value/diff.ts CHANGED
@@ -125,7 +125,11 @@ function getDiffs(
125
125
  changes.push(change);
126
126
  }
127
127
 
128
- changes.push(...diffs);
128
+ const diffsLength = diffs.length;
129
+
130
+ for (let diffIndex = 0; diffIndex < diffsLength; diffIndex += 1) {
131
+ changes.push(diffs[diffIndex]);
132
+ }
129
133
  }
130
134
 
131
135
  checked.add(key);
@@ -1,8 +1,8 @@
1
1
  // Generated by dts-bundle-generator v9.5.1
2
2
 
3
3
  /**
4
- * Chunk an array _(into smaller arrays of a specified size)_
4
+ * Chunk an array _(into smaller arrays)_
5
5
  */
6
- export declare function chunk<Item>(array: Item[], size?: number): Item[][];
6
+ export declare function chunk<Item>(array: Item[]): Item[][];
7
7
 
8
8
  export {};
@@ -1,4 +1,4 @@
1
1
  /**
2
- * Chunk an array _(into smaller arrays of a specified size)_
2
+ * Chunk an array _(into smaller arrays)_
3
3
  */
4
- export declare function chunk<Item>(array: Item[], size?: number): Item[][];
4
+ export declare function chunk<Item>(array: Item[]): Item[][];
@@ -96,9 +96,9 @@ export type NestedArrayType<Value> = Value extends Array<infer NestedValue> ? Ne
96
96
  export type Key = number | string;
97
97
  export type PlainObject = UnknownRecord;
98
98
  /**
99
- * Chunk an array _(into smaller arrays of a specified size)_
99
+ * Chunk an array _(into smaller arrays)_
100
100
  */
101
- export declare function chunk<Item>(array: Item[], size?: number): Item[][];
101
+ export declare function chunk<Item>(array: Item[]): Item[][];
102
102
  /**
103
103
  * Compact an array _(removing all `null` and `undefined` values)_
104
104
  */
package/types/index.d.cts CHANGED
@@ -1574,18 +1574,45 @@ export declare function clamp(
1574
1574
  * - Based on Lodash :-)
1575
1575
  */
1576
1576
  export declare function getNumber(value: unknown): number;
1577
+ export type OnlyNumericalKeys<Item> = {
1578
+ [Key in keyof Item as Item[Key] extends number ? Key : never]: Item[Key];
1579
+ };
1577
1580
  /**
1578
1581
  * Get the average value from a list of numbers
1579
1582
  */
1580
1583
  export declare function average(values: number[]): number;
1584
+ export declare function average<Item extends PlainObject>(
1585
+ array: Item[],
1586
+ key: keyof OnlyNumericalKeys<Item>,
1587
+ ): number;
1588
+ export declare function average<Item extends PlainObject>(
1589
+ array: Item[],
1590
+ callback: (item: Item, index: number, array: Item[]) => number,
1591
+ ): number;
1581
1592
  /**
1582
1593
  * Get the maximum value from a list of numbers
1583
1594
  */
1584
1595
  export declare function max(values: number[]): number;
1596
+ export declare function max<Item extends PlainObject>(
1597
+ array: Item[],
1598
+ key: keyof OnlyNumericalKeys<Item>,
1599
+ ): number;
1600
+ export declare function max<Item extends PlainObject>(
1601
+ array: Item[],
1602
+ callback: (item: Item, index: number, array: Item[]) => number,
1603
+ ): number;
1585
1604
  /**
1586
1605
  * Get the minimum value from a list of numbers
1587
1606
  */
1588
1607
  export declare function min(values: number[]): number;
1608
+ export declare function min<Item extends PlainObject>(
1609
+ array: Item[],
1610
+ key: keyof OnlyNumericalKeys<Item>,
1611
+ ): number;
1612
+ export declare function min<Item extends PlainObject>(
1613
+ array: Item[],
1614
+ callback: (item: Item, index: number, array: Item[]) => number,
1615
+ ): number;
1589
1616
  /**
1590
1617
  * Round a number to a specific number of decimal places _(defaults to 0)_
1591
1618
  */
@@ -1594,6 +1621,14 @@ export declare function round(value: number, decimals?: number): number;
1594
1621
  * Get the sum of a list of numbers
1595
1622
  */
1596
1623
  export declare function sum(values: number[]): number;
1624
+ export declare function sum<Item extends PlainObject>(
1625
+ array: Item[],
1626
+ key: keyof OnlyNumericalKeys<Item>,
1627
+ ): number;
1628
+ export declare function sum<Item extends PlainObject>(
1629
+ array: Item[],
1630
+ callback: (item: Item, index: number, array: Item[]) => number,
1631
+ ): number;
1597
1632
  declare class Logger {
1598
1633
  /**
1599
1634
  * Log any number of values at the "debug" log level
@@ -1733,9 +1768,9 @@ export declare function isPlainObject(value: unknown): value is PlainObject;
1733
1768
  */
1734
1769
  export declare function isPrimitive(value: unknown): value is Primitive;
1735
1770
  /**
1736
- * Chunk an array _(into smaller arrays of a specified size)_
1771
+ * Chunk an array _(into smaller arrays)_
1737
1772
  */
1738
- export declare function chunk<Item>(array: Item[], size?: number): Item[][];
1773
+ export declare function chunk<Item>(array: Item[]): Item[][];
1739
1774
  /**
1740
1775
  * Compact an array _(removing all `null` and `undefined` values)_
1741
1776
  */
package/types/math.d.cts CHANGED
@@ -1,17 +1,58 @@
1
1
  // Generated by dts-bundle-generator v9.5.1
2
2
 
3
+ /**
4
+ Represents an object with `unknown` value. You probably want this instead of `{}`.
5
+
6
+ Use case: You have an object whose keys and values are unknown to you.
7
+
8
+ @example
9
+ ```
10
+ import type {UnknownRecord} from 'type-fest';
11
+
12
+ function toJson(object: UnknownRecord) {
13
+ return JSON.stringify(object);
14
+ }
15
+
16
+ toJson({hello: 'world'});
17
+ //=> '{"hello":"world"}'
18
+
19
+ function isObject(value: unknown): value is UnknownRecord {
20
+ return typeof value === 'object' && value !== null;
21
+ }
22
+
23
+ isObject({hello: 'world'});
24
+ //=> true
25
+
26
+ isObject('hello');
27
+ //=> false
28
+ ```
29
+
30
+ @category Type
31
+ @category Object
32
+ */
33
+ export type UnknownRecord = Record<PropertyKey, unknown>;
34
+ export type PlainObject = UnknownRecord;
35
+ export type OnlyNumericalKeys<Item> = {
36
+ [Key in keyof Item as Item[Key] extends number ? Key : never]: Item[Key];
37
+ };
3
38
  /**
4
39
  * Get the average value from a list of numbers
5
40
  */
6
41
  export declare function average(values: number[]): number;
42
+ export declare function average<Item extends PlainObject>(array: Item[], key: keyof OnlyNumericalKeys<Item>): number;
43
+ export declare function average<Item extends PlainObject>(array: Item[], callback: (item: Item, index: number, array: Item[]) => number): number;
7
44
  /**
8
45
  * Get the maximum value from a list of numbers
9
46
  */
10
47
  export declare function max(values: number[]): number;
48
+ export declare function max<Item extends PlainObject>(array: Item[], key: keyof OnlyNumericalKeys<Item>): number;
49
+ export declare function max<Item extends PlainObject>(array: Item[], callback: (item: Item, index: number, array: Item[]) => number): number;
11
50
  /**
12
51
  * Get the minimum value from a list of numbers
13
52
  */
14
53
  export declare function min(values: number[]): number;
54
+ export declare function min<Item extends PlainObject>(array: Item[], key: keyof OnlyNumericalKeys<Item>): number;
55
+ export declare function min<Item extends PlainObject>(array: Item[], callback: (item: Item, index: number, array: Item[]) => number): number;
15
56
  /**
16
57
  * Round a number to a specific number of decimal places _(defaults to 0)_
17
58
  */
@@ -20,5 +61,7 @@ export declare function round(value: number, decimals?: number): number;
20
61
  * Get the sum of a list of numbers
21
62
  */
22
63
  export declare function sum(values: number[]): number;
64
+ export declare function sum<Item extends PlainObject>(array: Item[], key: keyof OnlyNumericalKeys<Item>): number;
65
+ export declare function sum<Item extends PlainObject>(array: Item[], callback: (item: Item, index: number, array: Item[]) => number): number;
23
66
 
24
67
  export {};
package/types/math.d.ts CHANGED
@@ -1,15 +1,25 @@
1
+ import type { PlainObject } from './models';
2
+ type OnlyNumericalKeys<Item> = {
3
+ [Key in keyof Item as Item[Key] extends number ? Key : never]: Item[Key];
4
+ };
1
5
  /**
2
6
  * Get the average value from a list of numbers
3
7
  */
4
8
  export declare function average(values: number[]): number;
9
+ export declare function average<Item extends PlainObject>(array: Item[], key: keyof OnlyNumericalKeys<Item>): number;
10
+ export declare function average<Item extends PlainObject>(array: Item[], callback: (item: Item, index: number, array: Item[]) => number): number;
5
11
  /**
6
12
  * Get the maximum value from a list of numbers
7
13
  */
8
14
  export declare function max(values: number[]): number;
15
+ export declare function max<Item extends PlainObject>(array: Item[], key: keyof OnlyNumericalKeys<Item>): number;
16
+ export declare function max<Item extends PlainObject>(array: Item[], callback: (item: Item, index: number, array: Item[]) => number): number;
9
17
  /**
10
18
  * Get the minimum value from a list of numbers
11
19
  */
12
20
  export declare function min(values: number[]): number;
21
+ export declare function min<Item extends PlainObject>(array: Item[], key: keyof OnlyNumericalKeys<Item>): number;
22
+ export declare function min<Item extends PlainObject>(array: Item[], callback: (item: Item, index: number, array: Item[]) => number): number;
13
23
  /**
14
24
  * Round a number to a specific number of decimal places _(defaults to 0)_
15
25
  */
@@ -18,3 +28,6 @@ export declare function round(value: number, decimals?: number): number;
18
28
  * Get the sum of a list of numbers
19
29
  */
20
30
  export declare function sum(values: number[]): number;
31
+ export declare function sum<Item extends PlainObject>(array: Item[], key: keyof OnlyNumericalKeys<Item>): number;
32
+ export declare function sum<Item extends PlainObject>(array: Item[], callback: (item: Item, index: number, array: Item[]) => number): number;
33
+ export {};