wrap.js 583 B

123456789101112131415
  1. 'use strict';
  2. function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
  3. module.exports = function wrap(value) {
  4. if (value instanceof this.constructor) {
  5. return value;
  6. }
  7. if (_typeof(value) === 'object') {
  8. return new this.constructor(value);
  9. }
  10. return new this.constructor([value]);
  11. };