@augment-vir/common 23.3.2 → 23.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.
- package/dist/cjs/augments/{array.js → array/array.js} +1 -1
- package/dist/cjs/augments/array/remove-duplicates.js +17 -0
- package/dist/cjs/index.js +2 -1
- package/dist/esm/augments/{array.js → array/array.js} +1 -1
- package/dist/esm/augments/array/remove-duplicates.js +13 -0
- package/dist/esm/index.js +2 -1
- package/dist/types/augments/{array.d.ts → array/array.d.ts} +2 -2
- package/dist/types/augments/array/remove-duplicates.d.ts +1 -0
- package/dist/types/augments/object/matches-object-shape.d.ts +1 -1
- package/dist/types/index.d.ts +2 -1
- package/package.json +2 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.filterMap = exports.arrayToObject = exports.groupArrayBy = exports.repeatArray = exports.typedMap = exports.typedArrayIncludes = exports.trimArrayStrings = exports.flatten2dArray = exports.filterOutIndexes = void 0;
|
|
4
|
-
const object_entries_1 = require("
|
|
4
|
+
const object_entries_1 = require("../object/object-entries");
|
|
5
5
|
function filterOutIndexes(array, indexes) {
|
|
6
6
|
return array.filter((_, index) => !indexes.includes(index));
|
|
7
7
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.removeDuplicates = void 0;
|
|
4
|
+
function removeDuplicates(originalArray, calculateUniqueIdCallback) {
|
|
5
|
+
const grouped = new Map();
|
|
6
|
+
return originalArray.filter((entry) => {
|
|
7
|
+
const uniqueId = calculateUniqueIdCallback(entry);
|
|
8
|
+
if (grouped.get(uniqueId)) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
grouped.set(uniqueId, entry);
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
exports.removeDuplicates = removeDuplicates;
|
package/dist/cjs/index.js
CHANGED
|
@@ -15,7 +15,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./augments/ansi"), exports);
|
|
18
|
-
__exportStar(require("./augments/array"), exports);
|
|
18
|
+
__exportStar(require("./augments/array/array"), exports);
|
|
19
|
+
__exportStar(require("./augments/array/remove-duplicates"), exports);
|
|
19
20
|
__exportStar(require("./augments/async"), exports);
|
|
20
21
|
__exportStar(require("./augments/boolean"), exports);
|
|
21
22
|
__exportStar(require("./augments/common-number"), exports);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function removeDuplicates(originalArray, calculateUniqueIdCallback) {
|
|
2
|
+
const grouped = new Map();
|
|
3
|
+
return originalArray.filter((entry) => {
|
|
4
|
+
const uniqueId = calculateUniqueIdCallback(entry);
|
|
5
|
+
if (grouped.get(uniqueId)) {
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
else {
|
|
9
|
+
grouped.set(uniqueId, entry);
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from './augments/ansi';
|
|
2
|
-
export * from './augments/array';
|
|
2
|
+
export * from './augments/array/array';
|
|
3
|
+
export * from './augments/array/remove-duplicates';
|
|
3
4
|
export * from './augments/async';
|
|
4
5
|
export * from './augments/boolean';
|
|
5
6
|
export * from './augments/common-number';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AtLeastTuple } from '
|
|
2
|
-
import { ArrayElement } from '
|
|
1
|
+
import { AtLeastTuple } from '../tuple';
|
|
2
|
+
import { ArrayElement } from '../type';
|
|
3
3
|
export declare function filterOutIndexes<T>(array: ReadonlyArray<T>, indexes: ReadonlyArray<number>): T[];
|
|
4
4
|
export declare function flatten2dArray<T>(array2d: ReadonlyArray<ReadonlyArray<T>>): T[];
|
|
5
5
|
export type AtLeastOneEntryArray<ArrayGeneric extends ReadonlyArray<any>> = AtLeastTuple<ArrayElement<ArrayGeneric>, 1>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function removeDuplicates<Entry, UniqueId>(originalArray: ReadonlyArray<Readonly<Entry>>, calculateUniqueIdCallback: (entry: Readonly<Entry>) => UniqueId): Readonly<Entry>[];
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from './augments/ansi';
|
|
2
|
-
export * from './augments/array';
|
|
2
|
+
export * from './augments/array/array';
|
|
3
|
+
export * from './augments/array/remove-duplicates';
|
|
3
4
|
export * from './augments/async';
|
|
4
5
|
export * from './augments/boolean';
|
|
5
6
|
export * from './augments/common-number';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@augment-vir/common",
|
|
3
|
-
"version": "23.
|
|
3
|
+
"version": "23.4.0",
|
|
4
4
|
"homepage": "https://github.com/electrovir/augment-vir/tree/main/packages/common",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/electrovir/augment-vir/issues"
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"browser-or-node": "^2.1.1",
|
|
28
|
-
"run-time-assertions": "^0.
|
|
28
|
+
"run-time-assertions": "^1.0.0",
|
|
29
29
|
"type-fest": "^4.10.2"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|