New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

custom-log

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

custom-log - npm Package Compare versions

Comparing version 0.3.0 to 0.3.1

babel.config.js

99

custom-log.js

@@ -0,1 +1,11 @@

"use strict";
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
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); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
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); }
// Generated by CoffeeScript 2.5.1

@@ -31,7 +41,7 @@ (function () {

intoArray = function (args) {
intoArray = function intoArray(args) {
if (args.length < 2) {
if (typeof args[0] === 'string') {
args = args.join('').replace(/^\s+|\s+$/g, '').replace(/\s+/g, ' ').split(' ');
} else if (typeof args[0] === 'object' && args[0] instanceof Array) {
} else if (_typeof(args[0]) === 'object' && args[0] instanceof Array) {
args = args[0];

@@ -44,8 +54,8 @@ }

instanceOf = function (type, value) {
instanceOf = function instanceOf(type, value) {
return value instanceof type;
};
forceObject = function (value) {
if (typeof value === 'object' && value !== null && !instanceOf(Boolean, value) && !instanceOf(Number, value) && !instanceOf(Array, value) && !instanceOf(RegExp, value) && !instanceOf(Date, value)) {
forceObject = function forceObject(value) {
if (_typeof(value) === 'object' && value !== null && !instanceOf(Boolean, value) && !instanceOf(Number, value) && !instanceOf(Array, value) && !instanceOf(RegExp, value) && !instanceOf(Date, value)) {
return value;

@@ -58,3 +68,3 @@ } else {

customLog = function (prefixes, settings) {
customLog = function customLog(prefixes, settings) {
var Log, enact, level, log, logInstance, prefix, prefixMsg;

@@ -69,4 +79,9 @@

settings = forceObject(settings);
Log = class Log {
constructor(level, prefix) {
Log = /*#__PURE__*/function () {
function Log(level, prefix) {
var _this = this;
_classCallCheck(this, Log);
var prop, ref, value;

@@ -79,8 +94,14 @@ this.disable = this.disable.bind(this);

this.log = (...args) => {
this.log = function () {
var message;
if (this.enabled) {
prefix = typeof this.prefix === 'function' ? this.prefix(...args) : this.prefix;
message = this.prefix ? [prefix].concat(...args) : args;
if (_this.enabled) {
var _ref;
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
prefix = typeof _this.prefix === 'function' ? _this.prefix.apply(_this, args) : _this.prefix;
message = _this.prefix ? (_ref = [prefix]).concat.apply(_ref, args) : args;
return console.log.apply(console, message);

@@ -102,25 +123,35 @@ }

disable() {
this.enabled = false;
_createClass(Log, [{
key: "disable",
value: function disable() {
this.enabled = false;
if (!settings.silentDisable) {
return console.log(CUSTOM_LOG + '.' + this.level + ' is disabled');
if (!settings.silentDisable) {
return console.log(CUSTOM_LOG + '.' + this.level + ' is disabled');
}
}
}
}, {
key: "enable",
value: function enable() {
this.enabled = true;
enable() {
this.enabled = true;
if (!settings.silentEnable) {
return console.log(CUSTOM_LOG + '.' + this.level + ' is enabled');
if (!settings.silentEnable) {
return console.log(CUSTOM_LOG + '.' + this.level + ' is enabled');
}
}
}
}]);
}; // end of Log
return Log;
}(); // end of Log
// create a default log right away
logInstance = new Log('log', prefixMsg);
log = logInstance.log; // abstract function for enable and disable
enact = function (method, ...levels) {
enact = function enact(method) {
for (var _len2 = arguments.length, levels = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
levels[_key2 - 1] = arguments[_key2];
}
var i, len, level, results;

@@ -145,8 +176,16 @@ levels = intoArray(levels);

log.enable = function (...args) {
return enact('enable', ...args);
log.enable = function () {
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
args[_key3] = arguments[_key3];
}
return enact.apply(void 0, ['enable'].concat(args));
};
log.disable = function (...args) {
return enact('disable', ...args);
log.disable = function () {
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
args[_key4] = arguments[_key4];
}
return enact.apply(void 0, ['disable'].concat(args));
}; // create log levels/instances from prefixes object

@@ -183,2 +222,2 @@

}
}).call(this);
}).call(void 0);

@@ -1,1 +0,1 @@

(function(){"use strict";var e,n,t,i,o={}.hasOwnProperty;i=function(e){return e.length<2&&("string"==typeof e[0]?e=e.join("").replace(/^\s+|\s+$/g,"").replace(/\s+/g," ").split(" "):"object"==typeof e[0]&&e[0]instanceof Array&&(e=e[0])),e},t=function(e,n){return n instanceof e},n=function(e){return"object"!=typeof e||null===e||t(Boolean,e)||t(Number,e)||t(Array,e)||t(RegExp,e)||t(Date,e)?{}:e},e=function(e,t){var l,s,r,f,u,a;for(r in"string"==typeof e&&(a=e),e=n(e),t=n(t),u=new(l=class{constructor(e,n){var t,i;for(t in this.disable=this.disable.bind(this),this.enable=this.enable.bind(this),this.enabled=!0,this.level=e||"log",this.prefix=n||"",this.log=(...e)=>{var t;if(this.enabled)return n="function"==typeof this.prefix?this.prefix(...e):this.prefix,t=this.prefix?[n].concat(...e):e,console.log.apply(console,t)},this,this)o.call(this,t)&&(i=this[t],"log"!==t&&(this.log[t]=i))}disable(){if(this.enabled=!1,!t.silentDisable)return console.log("custom-log: ."+this.level+" is disabled")}enable(){if(this.enabled=!0,!t.silentEnable)return console.log("custom-log: ."+this.level+" is enabled")}})("log",a),f=u.log,s=function(e,...n){var t,o,l,s;for(s=[],t=0,o=(n=i(n)).length;t<o;t++)"log"===(l=n[t])?s.push(u[e]()):null!=f[l]?s.push(f[l][e]()):s.push(void 0);return s},f.enable=function(...e){return s("enable",...e)},f.disable=function(...e){return s("disable",...e)},e)!function(e,n){switch(e){case"log":return u.prefix=n;default:f[e]=new l(e,n).log}}(r,e[r]);return f},"undefined"!=typeof define&&null!==define&&"function"==typeof define&&define.amd?define("customLog",[],(function(){return e})):"undefined"!=typeof module?module.exports=e:"undefined"!=typeof window&&(window.customLog=e)}).call(this);
"use strict";function _classCallCheck(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,n){for(var t=0;t<n.length;t++){var o=n[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function _createClass(e,n,t){return n&&_defineProperties(e.prototype,n),t&&_defineProperties(e,t),e}function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}(function(){var e,n,t,o,i={}.hasOwnProperty;o=function(e){return e.length<2&&("string"==typeof e[0]?e=e.join("").replace(/^\s+|\s+$/g,"").replace(/\s+/g," ").split(" "):"object"===_typeof(e[0])&&e[0]instanceof Array&&(e=e[0])),e},t=function(e,n){return n instanceof e},n=function(e){return"object"!==_typeof(e)||null===e||t(Boolean,e)||t(Number,e)||t(Array,e)||t(RegExp,e)||t(Date,e)?{}:e},e=function(e,t){var r,l,a,f,s,u;for(a in"string"==typeof e&&(u=e),e=n(e),t=n(t),s=new(r=function(){function e(n,t){var o,r,l=this;for(o in _classCallCheck(this,e),this.disable=this.disable.bind(this),this.enable=this.enable.bind(this),this.enabled=!0,this.level=n||"log",this.prefix=t||"",this.log=function(){var e;if(l.enabled){for(var n,o=arguments.length,i=new Array(o),r=0;r<o;r++)i[r]=arguments[r];return t="function"==typeof l.prefix?l.prefix.apply(l,i):l.prefix,e=l.prefix?(n=[t]).concat.apply(n,i):i,console.log.apply(console,e)}},this,this)i.call(this,o)&&(r=this[o],"log"!==o&&(this.log[o]=r))}return _createClass(e,[{key:"disable",value:function(){if(this.enabled=!1,!t.silentDisable)return console.log("custom-log: ."+this.level+" is disabled")}},{key:"enable",value:function(){if(this.enabled=!0,!t.silentEnable)return console.log("custom-log: ."+this.level+" is enabled")}}]),e}())("log",u),f=s.log,l=function(e){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++)t[i-1]=arguments[i];var r,l,a,u;for(u=[],r=0,l=(t=o(t)).length;r<l;r++)"log"===(a=t[r])?u.push(s[e]()):null!=f[a]?u.push(f[a][e]()):u.push(void 0);return u},f.enable=function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return l.apply(void 0,["enable"].concat(n))},f.disable=function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return l.apply(void 0,["disable"].concat(n))},e)!function(e,n){switch(e){case"log":return s.prefix=n;default:f[e]=new r(e,n).log}}(a,e[a]);return f},"undefined"!=typeof define&&null!==define&&"function"==typeof define&&define.amd?define("customLog",[],(function(){return e})):"undefined"!=typeof module?module.exports=e:"undefined"!=typeof window&&(window.customLog=e)}).call(void 0);
{
"name": "custom-log",
"version": "0.3.0",
"version": "0.3.1",
"description": "A tiny flexible logger",

@@ -5,0 +5,0 @@ "main": "custom-log.min.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc