mirror of https://github.com/webpack/webpack.git
Merge pull request #7331 from dev-drprasad/add-jsdoc-annotations-cached-merge
📝 Add JSDoc annotations for cached merge util function
This commit is contained in:
commit
2f3e7d4bd7
|
|
@ -6,6 +6,19 @@
|
|||
|
||||
const mergeCache = new WeakMap();
|
||||
|
||||
/**
|
||||
* Merges two given objects and caches the result to avoid computation if same objects passed as arguements again.
|
||||
* @example
|
||||
* // performs Object.assign(first, second), stores the result in WeakMap and returns result
|
||||
* cachedMerge({a: 1}, {a: 2})
|
||||
* {a: 2}
|
||||
* // when same arguments passed, gets the result from WeakMap and returns it.
|
||||
* cachedMerge({a: 1}, {a: 2})
|
||||
* {a: 2}
|
||||
* @param {object} first first object
|
||||
* @param {object} second second object
|
||||
* @returns {object} merged object of first and second object
|
||||
*/
|
||||
const cachedMerge = (first, second) => {
|
||||
let innerCache = mergeCache.get(first);
|
||||
if (innerCache === undefined) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue