@lskjs/utils
Advanced tools
Comparing version 2.5.3 to 2.6.0
@@ -5,2 +5,12 @@ "use strict"; | ||
var _toArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toArray")); | ||
var _log = _interopRequireDefault(require("@lskjs/log2")); | ||
var _debounce = _interopRequireDefault(require("lodash/debounce")); | ||
var _groupBy = _interopRequireDefault(require("lodash/groupBy")); | ||
var _mapValues = _interopRequireDefault(require("lodash/mapValues")); | ||
var _some = _interopRequireDefault(require("lodash/some")); | ||
@@ -11,14 +21,24 @@ | ||
/* eslint-disable no-console */ | ||
console.___error = console.error; | ||
var triggers = ['Warning: ', 'The pseudo class ', 'Error: <svg>']; | ||
var log = new _log["default"]({ | ||
name: 'React' | ||
}); | ||
var triggers = [function (s) { | ||
return s.startsWith('Warning: '); | ||
}, function (s) { | ||
return s.startsWith('The pseudo class '); | ||
} // (s) => s.indexOf('<svg> attribute') !== -1, | ||
// console.log(s, s.indexOf('<svg> attribute'), s.indexOf('<svg>')); | ||
]; | ||
var isTrigger = function isTrigger(str) { | ||
return typeof str === 'string' && (0, _some["default"])(triggers, function (t) { | ||
return str.startsWith(t); | ||
return t(str); | ||
}); | ||
}; | ||
console.error = function () { | ||
var _console; | ||
console.___error = console.error; | ||
console.___warn = console.warn; | ||
var stack = []; | ||
var addToStack = function addToStack() { | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
@@ -28,26 +48,50 @@ args[_key] = arguments[_key]; | ||
if (isTrigger(args[0])) { | ||
console.log('[e] React:', [args]); | ||
return; | ||
stack.push(args); | ||
(0, _debounce["default"])(function () { | ||
var groups = (0, _groupBy["default"])(stack, function (s) { | ||
return s[0]; | ||
}); // eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
var res = (0, _mapValues["default"])(groups, function (_ref) { | ||
var _ref2 = (0, _toArray2["default"])(_ref), | ||
_ = _ref2[0], | ||
g = _ref2.slice(1); | ||
return g; | ||
}); | ||
if (Object.keys(res).length) { | ||
log.warn(res); | ||
stack = []; | ||
} | ||
}, 1000)(); | ||
}; | ||
console.error = function () { | ||
var _console; | ||
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { | ||
args[_key2] = arguments[_key2]; | ||
} | ||
if (isTrigger(args[0])) return addToStack.apply(void 0, ['error'].concat(args)); | ||
(_console = console).___error.apply(_console, args); | ||
return null; | ||
}; | ||
console.___warn = console.warn; | ||
console.warn = function () { | ||
var _console2; | ||
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { | ||
args[_key2] = arguments[_key2]; | ||
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { | ||
args[_key3] = arguments[_key3]; | ||
} | ||
if (isTrigger(args[0])) { | ||
console.log('[w] React:', [args]); | ||
return; | ||
} | ||
if (isTrigger(args[0])) return addToStack.apply(void 0, ['warn'].concat(args)); | ||
(_console2 = console).___warn.apply(_console2, args); | ||
return null; | ||
}; | ||
//# sourceMappingURL=hide-react-console-logs.js.map |
{ | ||
"name": "@lskjs/utils", | ||
"version": "2.5.3", | ||
"version": "2.6.0", | ||
"description": "LSK.js – utils – helpers and functions", | ||
@@ -41,3 +41,3 @@ "keywords": [], | ||
}, | ||
"gitHead": "1cefc2cbcbb54ab3ffb098a7a21e78463e6fc92d" | ||
"gitHead": "bb90c053f16b888c165cc61a998c7f2e211a0fbb" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
360352
3642