moderndash 0.0.12 → 0.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "moderndash",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.13",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A lodash inspired utility framework for ESM/Typescript/ES2020",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "ctix create ----startAt src --overwrite --noBackup & tsup",
|
|
8
|
-
"prepublishOnly": "npm run build &&
|
|
9
|
-
"postpublish": "
|
|
8
|
+
"prepublishOnly": "npm run build && cp '../README.md' './README.md' && cp '../LICENSE' './LICENSE'",
|
|
9
|
+
"postpublish": "rm './README.md' && rm './LICENSE'",
|
|
10
10
|
"test": "vitest",
|
|
11
11
|
"test-ui": "vitest --ui"
|
|
12
12
|
},
|
|
@@ -11,13 +11,13 @@ import { isEqualWith } from '@lang/isEqualWith';
|
|
|
11
11
|
* determined by the first array. The iteratee is invoked with one argument:
|
|
12
12
|
* (value).
|
|
13
13
|
*
|
|
14
|
+
* @example
|
|
15
|
+
* intersectionBy(Math.floor, [2.1, 1.2], [2.3, 3.4])
|
|
16
|
+
* // => [2.1]
|
|
14
17
|
* @category Array
|
|
15
18
|
* @param iteratee - The iteratee invoked per element. Or property shorthand.
|
|
16
19
|
* @param arrays - The arrays to inspect.
|
|
17
20
|
* @returns Returns the new array of intersecting values.
|
|
18
|
-
* @example
|
|
19
|
-
* intersectionBy(Math.floor, [2.1, 1.2], [2.3, 3.4])
|
|
20
|
-
* // => [2.1]
|
|
21
21
|
*/
|
|
22
22
|
|
|
23
23
|
export function intersectionBy<TInput>(iteratee: IterateeFunction<TInput> | PropertyShorthand<TInput>, ...arrays: MinimumTwoArrays<TInput>): TInput[] {
|
|
@@ -6,16 +6,16 @@ import type { MinimumTwoArrays } from '../types';
|
|
|
6
6
|
* of result values are determined by the first array. The comparator is
|
|
7
7
|
* invoked with two arguments: (arrVal, othVal).
|
|
8
8
|
*
|
|
9
|
-
* @category Array
|
|
10
|
-
* @param comparator - The comparator invoked per element.
|
|
11
|
-
* @param arrays - The arrays to inspect.
|
|
12
|
-
* @returns Returns the new array of intersecting values.
|
|
13
9
|
* @example
|
|
14
10
|
* const objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
|
|
15
11
|
* const others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]
|
|
16
12
|
*
|
|
17
13
|
* intersectionWith(isEqual, objects, others)
|
|
18
14
|
* // => [{ 'x': 1, 'y': 2 }]
|
|
15
|
+
* @category Array
|
|
16
|
+
* @param comparator - The comparator invoked per element.
|
|
17
|
+
* @param arrays - The arrays to inspect.
|
|
18
|
+
* @returns Returns the new array of intersecting values.
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
21
|
export function intersectionWith<T>(comparator: (a: T, b: T) => boolean, ...arrays: MinimumTwoArrays<T>): T[] {
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Invokes the iteratee `n` times, returning an array of the results of
|
|
3
|
+
* each invocation. The function is invoked with one argument: (index).
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* times(3, index => console.log("Run", index)))
|
|
7
|
+
* // => "Run 0" | "Run 1" | "Run 2"
|
|
8
|
+
* times(3, Math.random)
|
|
9
|
+
* // => [0.123, 0.456, 0.789]
|
|
10
|
+
* times(4, () => 0)
|
|
11
|
+
* // => [0, 0, 0, 0]
|
|
12
|
+
* @category Function
|
|
13
|
+
* @param n - The number of times to invoke `func`.
|
|
14
|
+
* @param iteratee - The function invoked per iteration.
|
|
15
|
+
* @returns Returns the array of results.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
export function times<T>(n: number, func: (index: number) => T): T[] {
|
|
19
|
+
const result: T[] = [];
|
|
20
|
+
for (let i = 0; i < n; i++) {
|
|
21
|
+
result.push(func(i));
|
|
22
|
+
}
|
|
23
|
+
return result;
|
|
24
|
+
}
|