UNPKG

@bredele/reconcile

Version:

Reconcile data from multiple async sources.

29 lines (28 loc) 824 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "default", { enumerable: true, get: function() { return reconcile; } }); async function reconcile(sources) { const results = await Promise.allSettled(sources.map((source)=>source())); const result = {}; for(let i = results.length - 1; i >= 0; i--){ if (results[i].status === 'fulfilled') { const data = results[i].value; if (data && typeof data === 'object') { for(const key in data){ if (data.hasOwnProperty(key) && data[key] != null) { result[key] = data[key]; } } } } } return result; } //# sourceMappingURL=index.js.map