"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

/*
 * @Author: codingfly
 * @Description:
 * @Date: 2021-08-04 14:54:41
 * @LastEditTime: 2021-08-26 15:15:24
 * @FilePath: \young\src\_utils\to.ts
 */
var to = function to(promise) {
  // eslint-disable-next-line no-prototype-builtins
  if (!promise || !Promise.prototype.isPrototypeOf(promise)) {
    return new Promise(function (resolve, reject) {
      reject(new Error('requires promises as the param'));
    }).catch(function (err) {
      return [err, null];
    });
  }

  return promise.then(function () {
    for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }

    return [null].concat(args);
  }).catch(function (err) {
    return [err];
  });
};

var _default = to;
exports.default = _default;