xprogress 0.17.3 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +32 -30
  2. package/package.json +2 -4
package/dist/index.js CHANGED
@@ -24,35 +24,35 @@ var _speedometer = _interopRequireDefault(require("speedometer"));
24
24
 
25
25
  var _progressStream = _interopRequireDefault(require("progress-stream"));
26
26
 
27
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
27
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
28
28
 
29
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
29
+ 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); }
30
30
 
31
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
31
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
32
32
 
33
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
33
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
34
34
 
35
35
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
36
36
 
37
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
37
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
38
38
 
39
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
39
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
40
40
 
41
41
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
42
42
 
43
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
43
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
44
44
 
45
45
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
46
46
 
47
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
47
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
48
48
 
49
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
49
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
50
50
 
51
51
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
52
52
 
53
53
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
54
54
 
55
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
55
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
56
56
 
57
57
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
58
58
 
@@ -64,13 +64,13 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
64
64
 
65
65
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
66
66
 
67
- function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
67
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
68
68
 
69
69
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
70
70
 
71
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
71
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
72
72
 
73
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
73
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
74
74
 
75
75
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
76
76
 
@@ -259,7 +259,7 @@ var ProgressGen = /*#__PURE__*/function (_EventEmitter) {
259
259
  return _super.apply(this, arguments);
260
260
  }
261
261
 
262
- return ProgressGen;
262
+ return _createClass(ProgressGen);
263
263
  }(_events["default"]);
264
264
 
265
265
  var ProgressBar = /*#__PURE__*/function () {
@@ -611,14 +611,16 @@ var ProgressBar = /*#__PURE__*/function () {
611
611
  var cleanWrite = function cleanWrite(arr, dontClean) {
612
612
  var addons = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
613
613
  var ending = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
614
+ var normie = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
614
615
 
615
616
  if (!dontClean) {
617
+ // check https://github.com/freeall/single-line-log/blob/515b3b99b699396c2ad5f937e4b490b6f9fbff0e/index.js#L1-L3
616
618
  self.cores.stdout.moveCursor(0, -addons);
617
619
  self.cores.stdout.cursorTo(0);
618
620
  self.cores.stdout.clearScreenDown();
619
621
  }
620
622
 
621
- self.cores.stdout.write("".concat(dontClean && ending && addons ? '\n' : '').concat(self.parseString(_util.format.apply(void 0, _toConsumableArray(arr))).replace(self.opts.bar.colorize ? '' : /\x1b\[\d+m/g, '')));
623
+ (normie ? process.stdout : self.cores.stdout).write("".concat(dontClean && ending && addons ? '\n' : '').concat(self.parseString(_util.format.apply(void 0, _toConsumableArray(arr))).replace(self.opts.bar.colorize ? '' : /\x1b\[\d+m/g, '')));
622
624
  };
623
625
 
624
626
  var addonPack;
@@ -628,7 +630,7 @@ var ProgressBar = /*#__PURE__*/function () {
628
630
  content[_key - 1] = arguments[_key];
629
631
  }
630
632
 
631
- this.justLogged = type === 'bar' && content.length === 1 ? !!cleanWrite(content, this.justLogged, addons) : (addonPack = type.match(/^bar\+(\d+)/)) !== null ? !!cleanWrite(content, this.justLogged, this.hasBarredOnce ? addonPack[1] : addons) : type === 'end' ? !!cleanWrite(content, !this.opts.clean, addons, true) : !cleanWrite([type.startsWith(':') && "".concat(type.slice(1)) || type].concat(content, ['\n']), this.justLogged, addons);
633
+ this.justLogged = type === 'bar' && content.length === 1 ? !!cleanWrite(content, this.justLogged, addons) : (addonPack = type.match(/^bar\+(\d+)/)) !== null ? !!cleanWrite(content, this.justLogged, this.hasBarredOnce ? addonPack[1] : addons) : type === 'end' ? !!cleanWrite(content, !this.opts.clean, addons, true, true) : !cleanWrite([type.startsWith(':') && "".concat(type.slice(1)) || type].concat(content, ['\n']), this.justLogged, addons, false, true);
632
634
  if (this.justLogged && this.hasBarredOnce) this.draw(this.oldBar);
633
635
  return this;
634
636
  }
@@ -704,20 +706,6 @@ var ProgressBar = /*#__PURE__*/function () {
704
706
  * Find out the progressbar is appended to another
705
707
  */
706
708
 
707
- }, {
708
- key: "slotStreamify",
709
-
710
- /**
711
- * Prepare a raw generator for use
712
- * @param {(slots:Number, total?:Number) => String} actor The performing function
713
- * @returns {Generator} New ProgressBar Generator
714
- * @yields The through instance or a cache model of the ProgressBar
715
- */
716
- value: function* slotStreamify(actor, args) {
717
- for (var level = -1; (level += 1) <= (this.opts.progress.infinite ? Infinity : this.slots.length);) {
718
- args = yield !level ? this : ((0, _lodash.merge)(this.opts, args[1]), actor(Math.floor(level - 1), args[0], this.opts.progress.infinite));
719
- }
720
- }
721
709
  }, {
722
710
  key: "isChild",
723
711
  get: function get() {
@@ -748,6 +736,20 @@ var ProgressBar = /*#__PURE__*/function () {
748
736
  * @param {ProgressBar} bar The progressbar to be checked
749
737
  */
750
738
 
739
+ }, {
740
+ key: "slotStreamify",
741
+ value:
742
+ /**
743
+ * Prepare a raw generator for use
744
+ * @param {(slots:Number, total?:Number) => String} actor The performing function
745
+ * @returns {Generator} New ProgressBar Generator
746
+ * @yields The through instance or a cache model of the ProgressBar
747
+ */
748
+ function* slotStreamify(actor, args) {
749
+ for (var level = -1; (level += 1) <= (this.opts.progress.infinite ? Infinity : this.slots.length);) {
750
+ args = yield !level ? this : ((0, _lodash.merge)(this.opts, args[1]), actor(Math.floor(level - 1), args[0], this.opts.progress.infinite));
751
+ }
752
+ }
751
753
  }], [{
752
754
  key: "isBar",
753
755
  value: function isBar(bar) {
package/package.json CHANGED
@@ -1,14 +1,12 @@
1
1
  {
2
2
  "name": "xprogress",
3
- "version": "0.17.3",
3
+ "version": "0.18.0",
4
4
  "description": "Dynamic, Flexible, extensible progressive CLI bar for the terminal built with NodeJS",
5
5
  "main": "dist/index.js",
6
6
  "types": "typings/index.d.ts",
7
7
  "scripts": {
8
- "push": "git push github master && git push gitlab master",
9
8
  "build": "babel lib -d dist",
10
- "version": "npm run build",
11
- "postversion": "npm run push"
9
+ "version": "npm run build"
12
10
  },
13
11
  "engines": {
14
12
  "node": ">=6"