@cpmech/basic
Advanced tools
Comparing version 4.20.0 to 4.20.1
@@ -358,2 +358,23 @@ 'use strict'; | ||
const appendToMapOfList = (a, key, item) => { | ||
if (a[key]) { | ||
a[key].push(item); | ||
} | ||
else { | ||
a[key] = [item]; | ||
} | ||
}; | ||
const mergeMapList = (a, b) => { | ||
const results = cloneSimple(a); | ||
Object.keys(b).forEach((key) => { | ||
if (results[key]) { | ||
results[key] = results[key].concat(b[key]); | ||
} | ||
else { | ||
results[key] = b[key]; | ||
} | ||
}); | ||
return results; | ||
}; | ||
// maybeCopySimple (hierarchically) copies some data from origin | ||
@@ -396,2 +417,3 @@ // into destination, iff the origin data exists (not undefined / not null) | ||
exports.allFilled = allFilled; | ||
exports.appendToMapOfList = appendToMapOfList; | ||
exports.blank2empty = blank2empty; | ||
@@ -412,2 +434,3 @@ exports.camelize = camelize; | ||
exports.maybeCopySimple = maybeCopySimple; | ||
exports.mergeMapList = mergeMapList; | ||
exports.mlog = mlog; | ||
@@ -414,0 +437,0 @@ exports.numOnly = numOnly; |
@@ -17,2 +17,3 @@ export * from './allFilled'; | ||
export * from './makeSetField'; | ||
export * from './mapOfList'; | ||
export * from './maybeCopySimple'; | ||
@@ -19,0 +20,0 @@ export * from './numOnly'; |
@@ -354,2 +354,23 @@ const filled = (entry) => { | ||
const appendToMapOfList = (a, key, item) => { | ||
if (a[key]) { | ||
a[key].push(item); | ||
} | ||
else { | ||
a[key] = [item]; | ||
} | ||
}; | ||
const mergeMapList = (a, b) => { | ||
const results = cloneSimple(a); | ||
Object.keys(b).forEach((key) => { | ||
if (results[key]) { | ||
results[key] = results[key].concat(b[key]); | ||
} | ||
else { | ||
results[key] = b[key]; | ||
} | ||
}); | ||
return results; | ||
}; | ||
// maybeCopySimple (hierarchically) copies some data from origin | ||
@@ -390,2 +411,2 @@ // into destination, iff the origin data exists (not undefined / not null) | ||
export { Locales, allFilled, blank2empty, camelize, cloneSimple, copySimple, diffSimple, elog, email2key, empty2blank, filled, getObjectKeys, hasProp, limitNumDecimals, makeGetField, makeSetField, maybeCopySimple, mlog, numOnly, setElog, setElogPrefix, setMlog, shallowCompareArrays, sleep, unixTimeNow }; | ||
export { Locales, allFilled, appendToMapOfList, blank2empty, camelize, cloneSimple, copySimple, diffSimple, elog, email2key, empty2blank, filled, getObjectKeys, hasProp, limitNumDecimals, makeGetField, makeSetField, maybeCopySimple, mergeMapList, mlog, numOnly, setElog, setElogPrefix, setMlog, shallowCompareArrays, sleep, unixTimeNow }; |
@@ -1,5 +0,3 @@ | ||
export declare type IMapOfList = { | ||
[x: string]: any[]; | ||
}; | ||
import { IMapOfList } from './types'; | ||
export declare const appendToMapOfList: (a: IMapOfList, key: string, item: any) => void; | ||
export declare const mergeMapList: (a: IMapOfList, b: IMapOfList) => IMapOfList; |
{ | ||
"name": "@cpmech/basic", | ||
"version": "4.20.0", | ||
"version": "4.20.1", | ||
"license": "MIT", | ||
@@ -41,3 +41,3 @@ "author": { | ||
}, | ||
"gitHead": "dc8515567606c2065f6dc486638df7e185177abb" | ||
"gitHead": "224f97de2df1690bbfbd7713f6a178d967f5d9d7" | ||
} |
35563
887