@wharfkit/abicache
Advanced tools
Comparing version 1.2.1 to 1.2.2
@@ -44,7 +44,7 @@ 'use strict'; | ||
action_results: mergeAndDeduplicate(existing.action_results, abi.action_results), | ||
types: mergeAndDeduplicate(existing.types, abi.types), | ||
types: mergeAndDeduplicate(existing.types, abi.types, 'new_type_name'), | ||
structs: mergeAndDeduplicate(existing.structs, abi.structs), | ||
actions: mergeAndDeduplicate(existing.actions, abi.actions), | ||
tables: mergeAndDeduplicate(existing.tables, abi.tables), | ||
ricardian_clauses: mergeAndDeduplicate(existing.ricardian_clauses, abi.ricardian_clauses), | ||
ricardian_clauses: mergeAndDeduplicate(existing.ricardian_clauses, abi.ricardian_clauses, 'id'), | ||
variants: mergeAndDeduplicate(existing.variants, abi.variants), | ||
@@ -59,9 +59,9 @@ version: abi.version, | ||
} | ||
function mergeAndDeduplicate(array1, array2) { | ||
return [...array1, ...array2].reduce((acc, current) => { | ||
if (!acc.some((obj) => String(obj.name) === String(current.name))) { | ||
function mergeAndDeduplicate(array1, array2, byField = 'name') { | ||
return array2.reduce((acc, current) => { | ||
if (!acc.some((obj) => String(obj[byField]) === String(current[byField]))) { | ||
acc.push(current); | ||
} | ||
return acc; | ||
}, []); | ||
}, array1.slice()); | ||
} | ||
@@ -68,0 +68,0 @@ |
@@ -37,7 +37,7 @@ import { ABI } from '@wharfkit/antelope'; | ||
action_results: mergeAndDeduplicate(existing.action_results, abi.action_results), | ||
types: mergeAndDeduplicate(existing.types, abi.types), | ||
types: mergeAndDeduplicate(existing.types, abi.types, 'new_type_name'), | ||
structs: mergeAndDeduplicate(existing.structs, abi.structs), | ||
actions: mergeAndDeduplicate(existing.actions, abi.actions), | ||
tables: mergeAndDeduplicate(existing.tables, abi.tables), | ||
ricardian_clauses: mergeAndDeduplicate(existing.ricardian_clauses, abi.ricardian_clauses), | ||
ricardian_clauses: mergeAndDeduplicate(existing.ricardian_clauses, abi.ricardian_clauses, 'id'), | ||
variants: mergeAndDeduplicate(existing.variants, abi.variants), | ||
@@ -52,9 +52,9 @@ version: abi.version, | ||
} | ||
function mergeAndDeduplicate(array1, array2) { | ||
return [...array1, ...array2].reduce((acc, current) => { | ||
if (!acc.some((obj) => String(obj.name) === String(current.name))) { | ||
function mergeAndDeduplicate(array1, array2, byField = 'name') { | ||
return array2.reduce((acc, current) => { | ||
if (!acc.some((obj) => String(obj[byField]) === String(current[byField]))) { | ||
acc.push(current); | ||
} | ||
return acc; | ||
}, []); | ||
}, array1.slice()); | ||
} | ||
@@ -61,0 +61,0 @@ |
{ | ||
"name": "@wharfkit/abicache", | ||
"description": "ABI Caching Mechanism for use in Session and Contract Kits", | ||
"version": "1.2.1", | ||
"version": "1.2.2", | ||
"homepage": "https://github.com/wharfkit/abicache", | ||
@@ -6,0 +6,0 @@ "license": "BSD-3-Clause", |
@@ -53,3 +53,3 @@ import {ABI, ABIDef, API, APIClient, NameType} from '@wharfkit/antelope' | ||
), | ||
types: mergeAndDeduplicate(existing.types, abi.types), | ||
types: mergeAndDeduplicate(existing.types, abi.types, 'new_type_name'), | ||
structs: mergeAndDeduplicate(existing.structs, abi.structs), | ||
@@ -60,3 +60,4 @@ actions: mergeAndDeduplicate(existing.actions, abi.actions), | ||
existing.ricardian_clauses, | ||
abi.ricardian_clauses | ||
abi.ricardian_clauses, | ||
'id' | ||
), | ||
@@ -73,9 +74,9 @@ variants: mergeAndDeduplicate(existing.variants, abi.variants), | ||
function mergeAndDeduplicate(array1, array2) { | ||
return [...array1, ...array2].reduce((acc, current) => { | ||
if (!acc.some((obj) => String(obj.name) === String(current.name))) { | ||
function mergeAndDeduplicate(array1, array2, byField = 'name') { | ||
return array2.reduce((acc: any[], current: any) => { | ||
if (!acc.some((obj: any) => String(obj[byField]) === String(current[byField]))) { | ||
acc.push(current) | ||
} | ||
return acc | ||
}, []) | ||
}, array1.slice()) | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
19082
230