utiller 1.0.92 → 1.0.93

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.
@@ -21,16 +21,16 @@ var _wrapNativeSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/w
21
21
 
22
22
  var _configerer = require("configerer");
23
23
 
24
- var _index = _interopRequireDefault(require("../utiller/index.js"));
25
-
26
24
  var _ERRORs = _interopRequireDefault(require("./ERRORs"));
27
25
 
26
+ var _index = require("../index.js");
27
+
28
+ var _lodash = _interopRequireDefault(require("lodash"));
29
+
28
30
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
29
31
 
30
32
  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; } }
31
33
 
32
- var utiller = new _index["default"]();
33
-
34
34
  var MyException = /*#__PURE__*/function (_Error) {
35
35
  (0, _inherits2["default"])(MyException, _Error);
36
36
 
@@ -47,7 +47,7 @@ var MyException = /*#__PURE__*/function (_Error) {
47
47
  }
48
48
 
49
49
  _this = _super.call(this, "".concat(error.message));
50
- _this.uid = utiller.getRandomValue(0, 100000000000);
50
+ _this.uid = _index.utiller.getRandomValue(0, 100000000000);
51
51
  _this.code = code;
52
52
  _this.infos = '';
53
53
  _this._msg = error.message;
@@ -58,11 +58,11 @@ var MyException = /*#__PURE__*/function (_Error) {
58
58
 
59
59
  for (var _i = 0, _infos = infos; _i < _infos.length; _i++) {
60
60
  var info = _infos[_i];
61
- if (info !== undefined) _this.infos += '##' + ' ' + utiller.getAttrValueInSequence(info, 'message', 'msg');
61
+ if (info !== undefined) _this.infos += '##' + ' ' + _index.utiller.getAttrValueInSequence(info, 'message', 'msg');
62
62
  }
63
63
 
64
64
  _this.message = "UID:".concat(_this.uid, " CODE:").concat(_this.code, " REASON:").concat(_this._msg, " INFO:").concat(_this.infos);
65
- if (_configerer.configerer.MODULE_MSG.SHOW_ERROR) utiller.appendError(_this.message);
65
+ if (_configerer.configerer.MODULE_MSG.SHOW_ERROR) _index.utiller.appendError(_this.message);
66
66
  return _this;
67
67
  }
68
68
 
@@ -546,6 +546,11 @@ var Utiller = /*#__PURE__*/function () {
546
546
 
547
547
  return result;
548
548
  }
549
+ }, {
550
+ key: "getArrayOfSize",
551
+ value: function getArrayOfSize(array, n) {
552
+ return _lodash["default"].slice(array, 0, n);
553
+ }
549
554
  }, {
550
555
  key: "getShuffledArrayWithLimitCount",
551
556
  value: function getShuffledArrayWithLimitCount(arr, n) {
@@ -1796,6 +1801,51 @@ var Utiller = /*#__PURE__*/function () {
1796
1801
 
1797
1802
  return object;
1798
1803
  }
1804
+ /** others returns [{logic:true|false,message:'oops'}]
1805
+ * */
1806
+
1807
+ }, {
1808
+ key: "constraintOfParam",
1809
+ value: function constraintOfParam(collection, type) {
1810
+ var result = false;
1811
+
1812
+ for (var _len16 = arguments.length, others = new Array(_len16 > 2 ? _len16 - 2 : 0), _key17 = 2; _key17 < _len16; _key17++) {
1813
+ others[_key17 - 2] = arguments[_key17];
1814
+ }
1815
+
1816
+ var validOfOthersCondition = _lodash["default"].isEmpty(others) ? true : this.and.apply(this, (0, _toConsumableArray2["default"])(others.map(function (each) {
1817
+ return each.logic;
1818
+ })));
1819
+
1820
+ switch (type) {
1821
+ case "array":
1822
+ if (_lodash["default"].isArray(collection) && validOfOthersCondition) result = true;
1823
+ break;
1824
+
1825
+ case "object":
1826
+ if (_lodash["default"].isObject(collection) && validOfOthersCondition) result = true;
1827
+ break;
1828
+
1829
+ case "string":
1830
+ if (_lodash["default"].isString(collection) && validOfOthersCondition) result = true;
1831
+ break;
1832
+
1833
+ case "number":
1834
+ if (_lodash["default"].isNumber(collection) && validOfOthersCondition) result = true;
1835
+ break;
1836
+
1837
+ case "other":
1838
+ if (validOfOthersCondition) return true;
1839
+ }
1840
+
1841
+ var stringOfRules = _lodash["default"].isEmpty(others) ? "" : ", ".concat(others.map(function (each) {
1842
+ return each.message;
1843
+ }).join(" | "));
1844
+
1845
+ if (result === false) {
1846
+ throw new _exceptioner["default"](9999, "7474423 type should be ".concat(type, " but get '").concat((0, _typeof2["default"])(type), "' ").concat(stringOfRules, " "));
1847
+ }
1848
+ }
1799
1849
  }]);
1800
1850
  return Utiller;
1801
1851
  }();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "utiller",
3
- "version": "1.0.92",
3
+ "version": "1.0.93",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -11,7 +11,7 @@
11
11
  "license": "ISC",
12
12
  "dependencies": {
13
13
  "configerer": "^1.0.11",
14
- "utiller": "^1.0.91",
14
+ "utiller": "^1.0.92",
15
15
  "linepayer": "^1.0.4",
16
16
  "databazer": "^1.0.9",
17
17
  "lodash": "^4.17.20",