{"version":3,"sources":["jsdelivr-header.js","/npm/oe-promise@1.5.0/index.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,ACYA,SAAS,QACL,IAAI,EAAS,EAOT,EAAW,CACX,QANI,IAAI,SAAQ,CAAC,EAAK,KACtB,EAAU,EACV,EAAS,CAAG,KAehB,OARA,OAAO,eAAe,EAAU,UAAW,CACvC,IAAK,IAAK,IAGd,OAAO,eAAe,EAAU,SAAU,CACtC,IAAK,IAAK,IAGP,CACX,CAQA,SAAS,SAAS,GACd,IACI,EADK,EAAK,QACH,MAAM,KAAM,GAEvB,OAAO,IAAI,SAAQ,IACf,QAAQ,UAAS,IAAI,EAAQ,IAAE,GAEvC,CAQA,SAAS,WAAW,GAEhB,IAAI,EAAO,EAAS,KAAI,GAAK,QAAQ,QAAQ,GACxC,MACG,IAAO,CAAG,MAAO,YAAa,MAAO,MACrC,IAAO,CAAG,MAAO,WAAY,OAAQ,QAC7C,OAAO,QAAQ,IAAI,EACvB,CAEA,OAAO,QAAU,CACb,MAAO,MACP,WAAY,WACZ,MAAO","file":"/npm/oe-promise@1.5.0/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/oe-promise@1.5.0/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/*\r\n©2015-2016 EdgeVerve Systems Limited (a fully owned Infosys subsidiary), Bangalore, India. All Rights Reserved.\r\nThe EdgeVerve proprietary software program (\"Program\"), is protected by copyrights laws, international treaties and other pending or existing intellectual property rights in India, the United States and other countries.\r\nThe Program may contain/reference third party or open source components, the rights to which continue to remain with the applicable third party licensors or the open source community as the case may be and nothing here transfers the rights to the third party and open source components, except as expressly permitted.\r\nAny unauthorized reproduction, storage, transmission in any form or by any means (including without limitation to electronic, mechanical, printing, photocopying, recording or  otherwise), or any distribution of this Program, or any portion of it, may result in severe civil and criminal penalties, and will be prosecuted to the maximum extent possible under the law.\r\n*/\r\n/**\r\n * This file implements three promise related functions - defer, fcall and allSettled.\r\n *\r\n * @author Dipayan Aich, Arun Jayapal\r\n * @module oe-promise\r\n */\r\n\r\n/**\r\n   * This function return a {promise, resolve, reject} object\r\n   * @returns {Object} - a object with promise resolve and reject functions\r\n   * @function\r\n   */\r\nfunction defer(){\r\n    var resolve, reject;\r\n\r\n    var p = new Promise((res, rej)=>{\r\n        resolve = res;\r\n        reject = rej;\r\n    });\r\n\r\n    var deferred = { \r\n        promise : p \r\n    }\r\n\r\n    Object.defineProperty(deferred, 'resolve', {\r\n        get: ()=> resolve\r\n    });\r\n\r\n    Object.defineProperty(deferred, 'reject', {\r\n        get: ()=> reject\r\n    });\r\n\r\n    return deferred;\r\n}\r\n\r\n/**\r\n   * This function return a {promise, resolve, reject} object\r\n   * @param {Array} - array of arguments which are functions\r\n   * @returns {Object} - resolved value\r\n   * @function\r\n   */\r\nfunction fcall(...args){\r\n    var fn = args.shift();\r\n    var r = fn.apply(this, args);\r\n    //return Promise.resolve(r);\r\n    return new Promise(resolve=>{\r\n        process.nextTick(()=>resolve(r))\r\n    });\r\n}\r\n\r\n/**\r\n   * This function return a {promise, resolve, reject} object\r\n   * @param {Array} - array of promises\r\n   * @returns {Object} - a object with promise resolve and reject state. returns when all are resolved\r\n   * @function\r\n   */\r\nfunction allSettled(promises){\r\n\r\n    let wrap = promises.map(p => Promise.resolve(p)\r\n        .then(\r\n            val => ({ state: 'fulfilled', value: val }),\r\n            err => ({ state: 'rejected', reason: err })));\r\n    return Promise.all(wrap);\r\n}\r\n\r\nmodule.exports = {\r\n    defer: defer,\r\n    allSettled: allSettled,\r\n    fcall: fcall\r\n}"]}