@koine/utils 2.0.0-beta.164 → 2.0.0-beta.166
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/addOrReplaceAtIdx.cjs.js +1 -1
- package/addOrReplaceAtIdx.d.ts +4 -0
- package/addOrReplaceAtIdx.esm.js +1 -1
- package/arrayUniqueByProperties.cjs.js +1 -1
- package/arrayUniqueByProperties.d.ts +1 -1
- package/arrayUniqueByProperties.esm.js +1 -1
- package/moveSortableArrayItemByKey.cjs.js +1 -1
- package/moveSortableArrayItemByKey.esm.js +1 -1
- package/package.json +1 -1
package/addOrReplaceAtIdx.cjs.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
let addOrReplaceAtIdx=(e,d,
|
|
5
|
+
let addOrReplaceAtIdx=(e,d,l)=>void 0!==l&&l>=0&&l<e.length?[...e.slice(0,l),d,...e.slice(l+1)]:[...e,d];
|
|
6
6
|
|
|
7
7
|
exports.addOrReplaceAtIdx = addOrReplaceAtIdx;
|
|
8
8
|
exports.default = addOrReplaceAtIdx;
|
package/addOrReplaceAtIdx.d.ts
CHANGED
|
@@ -4,6 +4,10 @@
|
|
|
4
4
|
* array, therefore the `newItem` must match the type of the `list` items.
|
|
5
5
|
*
|
|
6
6
|
* @category array
|
|
7
|
+
* @param list The original array to modify.
|
|
8
|
+
* @param newItem The item to add or replace.
|
|
9
|
+
* @param newIdx The index at which to replace the item (if defined).
|
|
10
|
+
* @returns A new array with the item added or replaced.
|
|
7
11
|
*/
|
|
8
12
|
export declare let addOrReplaceAtIdx: <T>(list: T[], newItem: T, newIdx?: number) => T[];
|
|
9
13
|
export default addOrReplaceAtIdx;
|
package/addOrReplaceAtIdx.esm.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
let addOrReplaceAtIdx=(e,d,
|
|
1
|
+
let addOrReplaceAtIdx=(e,d,l)=>void 0!==l&&l>=0&&l<e.length?[...e.slice(0,l),d,...e.slice(l+1)]:[...e,d];
|
|
2
2
|
|
|
3
3
|
export { addOrReplaceAtIdx, addOrReplaceAtIdx as default };
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
const arrayUniqueByProperties=(e,r)=>{let t=new Set;return e.filter(e=>{let a=r.map(r=>e[r]).join("|");return !t.has(a)&&(t.add(a),!0)})};
|
|
6
6
|
|
|
7
7
|
exports.arrayUniqueByProperties = arrayUniqueByProperties;
|
|
8
8
|
exports.default = arrayUniqueByProperties;
|
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
* @param keys The keys to compare in each array item
|
|
7
7
|
* @returns The filtered array
|
|
8
8
|
*/
|
|
9
|
-
export declare
|
|
9
|
+
export declare const arrayUniqueByProperties: <T>(array: T[], keys: (keyof T)[]) => T[];
|
|
10
10
|
export default arrayUniqueByProperties;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
const arrayUniqueByProperties=(e,r)=>{let t=new Set;return e.filter(e=>{let a=r.map(r=>e[r]).join("|");return !t.has(a)&&(t.add(a),!0)})};
|
|
2
2
|
|
|
3
3
|
export { arrayUniqueByProperties, arrayUniqueByProperties as default };
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
let moveSortableArrayItemByKey=(e,r,t,l)=>{let a=e.map(e=>e[r]),o=a.indexOf(t[r]),y=a.indexOf(l[r]),[
|
|
5
|
+
let moveSortableArrayItemByKey=(e,r,t,l)=>{let a=e.map(e=>e[r]),o=a.indexOf(t[r]),y=a.indexOf(l[r]);if(o>=0&&y>=0){let r=[...e],[t]=r.splice(o,1);return r.splice(y,0,t),r}return e};
|
|
6
6
|
|
|
7
7
|
exports.default = moveSortableArrayItemByKey;
|
|
8
8
|
exports.moveSortableArrayItemByKey = moveSortableArrayItemByKey;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
let moveSortableArrayItemByKey=(e,r,t,l)=>{let a=e.map(e=>e[r]),o=a.indexOf(t[r]),y=a.indexOf(l[r]),[
|
|
1
|
+
let moveSortableArrayItemByKey=(e,r,t,l)=>{let a=e.map(e=>e[r]),o=a.indexOf(t[r]),y=a.indexOf(l[r]);if(o>=0&&y>=0){let r=[...e],[t]=r.splice(o,1);return r.splice(y,0,t),r}return e};
|
|
2
2
|
|
|
3
3
|
export { moveSortableArrayItemByKey as default, moveSortableArrayItemByKey };
|
package/package.json
CHANGED