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B,MAAM,+BACN,IAAI,EAAI,UAAU,GAQlB,OAHA,EAAE,UAAY,EAAG,UAEjB,MAAM,GACC,CACT,CAEA,OAAO,CACT","file":"/npm/promisify-lite@2.0.0/lib/promisify.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.37.0.\n * Original file: /npm/promisify-lite@2.0.0/lib/promisify.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","\"use strict\";\n\nmodule.exports = promisify;\n\nconst denodeify = require('denodeify');\nconst debug = require('debug')('promisify');\nconst functionHelper = require('./function-helper');\nconst promisifiableTypes = new Set(['function', 'object']);\n\n/**\n * Analyze and possibly promisify the thing argument.\n * If it's a function that takes a callback, it will be converted to a promise.\n * If it's an object, it will be recursively processed until all functions\n * have been analyzed and converted.\n *\n * @param {*} thing the function or object to analyze and potentially (recursively) promisify\n * @param {Set} cache for caching promisified objects\n * @return {*} promisified function or object.\n */\nfunction promisify(thing, cache, path) {\n  debug('promisifying => ', thing);\n\n  cache = cache || new Set();\n  path = path || '';\n\n  debug(path);\n\n  // thing has already been promisified and cached\n  if (cache.has(thing)) {\n    debug('returning cached promise');\n    return thing;\n  }\n\n  // only promisify functions or the member functions of objects, just return anything else\n  let type = typeof thing;\n  if (!thing || !promisifiableTypes.has(type)) {\n    debug('%s is not promisifiable', type);\n    return thing;\n  }\n\n  // cache thing to avoid lookup cycles\n  cache.add(thing);\n\n  if (type == 'function') {\n    thing = promisifyFunction(thing, cache, path);\n  } else {\n    Object.keys(thing).map(function(key) {\n      return [key, thing[key]];\n    }).filter(function(prop) {\n      let key = prop[0];\n      let val = prop[1];\n      let type = typeof val;\n\n      debug('analyzing member property %s', key);\n\n      if (type == 'object') {\n        debug('recursing for member object property');\n        promisify(val, cache, path + '$' + key);\n        return false;\n      }\n\n      return type == 'function';\n\n    }).forEach(function(prop) {\n      debug('entry: ' + prop.toString());\n      let key = prop[0],\n        val = prop[1];\n\n      let asyncKey = key + 'Async';\n      thing[asyncKey] = promisifyFunction(val, cache, path);\n    });\n  }\n\n  return thing;\n}\n\n/**\n * Examine not just the function, but all of its members (for exammple,\n * the function might be a module).\n * 1. For each property, recursively call promisify\n * 2. If the property value is a function, call promisify on the prototype\n * 3. Finally, promisify the function itself\n *\n * @param fn\n * @param cache\n * @returns {*}\n */\nfunction promisifyFunction(fn, cache, path) {\n  debug('analyzing function ', fn);\n\n  // recursively process and promisify the function's properties, including inherited ones\n  Object.keys(fn).forEach(function(key) {\n    debug('processing %s', key);\n    //if (fn[key].prototype != fn && fn[key].prototype != fn.prototype) {\n    //if (Object.getPrototypeOf(fn[key]) != fn) {\n    if (fn[key]) {\n      fn[key] = promisify(fn[key], cache, path + '%' + key);\n    }\n  });\n\n  // process the function's prototype and attach to the promisified version\n  if (fn.prototype) {\n    debug('processing prototype');\n    promisify(fn.prototype, cache, path + '#');\n  }\n\n  // promisify the function\n  if (functionHelper.isAsync(fn)) {\n    debug('denodeifying async function');\n    let p = denodeify(fn);\n\n    // make sure the promisified function has access to the original function's properties\n    // by adding it to the prototype chain\n    //Object.setPrototypeOf(p, thing);\n    p.prototype = fn.prototype;\n\n    debug(p);\n    return p;\n  }\n\n  return fn;\n}\n"]}