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ACR,CACF","file":"/npm/qn-cnpm@1.0.3/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/qn-cnpm@1.0.3/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","/*!\n * qn-cnpm - index.js\n *\n * Copyright(c) cnpmjs.org and other contributors.\n * MIT Licensed\n *\n * Authors:\n *  fengmk2 <fengmk2@gmail.com> (http://fengmk2.github.com)\n *  dead_horse <dead_horse@qq.com> (https://github.com/dead-horse)\n */\n\n'use strict';\n\n/**\n * Module dependencies.\n */\n\nvar thunkify = require('thunkify-wrap');\nvar qn = require('qn');\nvar fs = require('fs');\n\n/**\n * Expose `Client`\n */\n\nmodule.exports = Client;\n\n/**\n * qn cnpm wrapper\n * @param {Object} options for qn client\n */\nfunction Client(options) {\n  if (!(this instanceof Client)) {\n    return new Client(options);\n  }\n\n  this.client = qn.create(options);\n  thunkify(this.client, ['delete', 'uploadFile', 'upload', 'download']);\n}\n\n/**\n * Upload file\n *\n * @param {String} filepath\n * @param {Object} options\n *  - {String} key\n *  - {Number} size\n */\nClient.prototype.upload = function* (filepath, options) {\n  try {\n    yield this.client.delete(options.key);\n  } catch (err) {\n    // ignore error here\n  }\n\n  var res = yield this.client.uploadFile(filepath, {\n    key: options.key,\n    size: options.size\n  });\n\n  return { url: parseUrl(res) };\n};\n\nClient.prototype.uploadBuffer = function* (buf, options) {\n  try {\n    yield this.client.delete(options.key);\n  } catch (err) {\n    // ignore error here\n  }\n\n  var res = yield this.client.upload(buf, {key: options.key});\n  return { url: parseUrl(res) };\n};\n\nfunction parseUrl(res) {\n  if (!res || !res[0] || !res[0].url) {\n    return null;\n  }\n  var url = res[0].url;\n  if (url.indexOf('http') !== 0) {\n    url = 'http://' + url;\n  }\n  return url;\n}\n\nClient.prototype.url = function (key) {\n  return this.client.resourceURL(key);\n};\n\nClient.prototype.download = function* (key, filepath, options) {\n  var writeStream = fs.createWriteStream(filepath);\n  yield this.client.download(key, {\n    timeout: options.timeout,\n    writeStream: writeStream\n  });\n};\n\nClient.prototype.remove = function* (key) {\n  try {\n    return yield this.client.delete(key);\n  } catch (err) {\n    if (err.name === 'QiniuFileNotExistsError') {\n      return;\n    }\n    throw err;\n  }\n};\n"]}