UNPKG

miniprogram-downloader

Version:
51 lines 2.13 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.Downloader = void 0; var miniprogram_network_life_cycle_1 = require("miniprogram-network-life-cycle"); var transform_1 = require("./transform"); /** * 下载封装 * @template T 扩展参数类型 */ var Downloader = /** @class */ (function (_super) { __extends(Downloader, _super); /** * 新建 Http实列 * @param config 全局默认配置 * @param downloader 下载处理方法,默认使用下载队列处理 * @param listeners 下载事件监听回调 */ function Downloader(config, downloader, listeners) { return _super.call(this, // tslint:disable-next-line: no-use-before-declare downloader || wx.downloadFile, // tslint:disable-next-line: no-object-literal-type-assertion config || { transformSend: transform_1.transfomDownloadSendDefault }, listeners) || this; } Downloader.prototype.download = function () { var isMultiParam = typeof arguments[0] === 'string'; // tslint:disable-next-line: no-unsafe-any var options = isMultiParam ? (arguments[2] || {}) : arguments[0]; if (isMultiParam) { options.url = arguments[0]; options.filePath = arguments[1]; } return this.process(options); }; return Downloader; }(miniprogram_network_life_cycle_1.LifeCycle)); exports.Downloader = Downloader; //# sourceMappingURL=downloader.js.map