custom-log
Advanced tools
Comparing version 0.2.3 to 0.2.4
@@ -1,46 +0,102 @@ | ||
// Generated by CoffeeScript 1.10.0 | ||
(function() { | ||
"use strict"; | ||
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } | ||
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."); } | ||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } | ||
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); } | ||
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } | ||
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; } | ||
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 | ||
(function () { | ||
// custom-log.coffee - A tiny console.log wrapper, written in Coffeescript. | ||
// MIT License | ||
// Copyright (c) 2015 Dennis Raymondo van der Sluis | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// The above copyright notice and this permission notice shall be included in all | ||
// copies or substantial portions of the Software. | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
// SOFTWARE. | ||
"use strict"; | ||
var customLog, intoArray, | ||
bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, | ||
slice = [].slice; | ||
intoArray = function(args) { | ||
var _customLog, intoArray; // taken from types.js | ||
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]; | ||
} | ||
} | ||
return args; | ||
}; | ||
customLog = function(init) { | ||
var CUSTOM_LOG, Log, enact, fn, level, log, logInstance, prefix, prefixMsg; | ||
_customLog = function customLog(init) { | ||
var CUSTOM_LOG, Log, enact, level, log, logInstance, prefix, prefixMsg; | ||
CUSTOM_LOG = 'custom-log: '; | ||
Log = (function() { | ||
Log = /*#__PURE__*/function () { | ||
function Log(level, prefix) { | ||
this.assert = bind(this.assert, this); | ||
this.enable = bind(this.enable, this); | ||
this.disable = bind(this.disable, this); | ||
var prop, value; | ||
var _arguments = arguments, | ||
_this = this; | ||
_classCallCheck(this, Log); | ||
var prop, ref, value; | ||
this.disable = this.disable.bind(this); | ||
this.enable = this.enable.bind(this); // this was a bad idea, it sucks and will be removed.. | ||
this.assert = this.assert.bind(this); | ||
this.enabled = true; | ||
this.level = level || 'log'; | ||
this.prefix = prefix || ''; | ||
this.log = (function(_this) { | ||
return function() { | ||
var message, ref; | ||
if (_this.enabled) { | ||
message = arguments; | ||
if (_this.prefix) { | ||
message = (ref = [_this.prefix]).concat.apply(ref, arguments); | ||
} | ||
return console.log.apply(console, message); | ||
this.log = function () { | ||
var message; | ||
if (_this.enabled) { | ||
message = _arguments; | ||
if (_this.prefix) { | ||
var _ref; | ||
message = (_ref = [_this.prefix]).concat.apply(_ref, _toConsumableArray(_arguments)); | ||
} | ||
}; | ||
})(this); | ||
for (prop in this) { | ||
value = this[prop]; | ||
if ((this.hasOwnProperty(prop)) && (prop !== 'log')) { | ||
return console.log.apply(console, message); | ||
} | ||
}; | ||
ref = this; | ||
for (prop in ref) { | ||
value = ref[prop]; | ||
if (this.hasOwnProperty(prop) && prop !== 'log') { | ||
this.log[prop] = value; | ||
@@ -51,48 +107,64 @@ } | ||
Log.prototype.disable = function() { | ||
this.enabled = false; | ||
return console.log(CUSTOM_LOG + '.' + this.level + ' is disabled'); | ||
}; | ||
_createClass(Log, [{ | ||
key: "disable", | ||
value: function disable() { | ||
this.enabled = false; | ||
return console.log(CUSTOM_LOG + '.' + this.level + ' is disabled'); | ||
} | ||
}, { | ||
key: "enable", | ||
value: function enable() { | ||
this.enabled = true; | ||
return console.log(CUSTOM_LOG + '.' + this.level + ' is enabled'); | ||
} | ||
}, { | ||
key: "assert", | ||
value: function assert(predicate) { | ||
var description = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; | ||
Log.prototype.enable = function() { | ||
this.enabled = true; | ||
return console.log(CUSTOM_LOG + '.' + this.level + ' is enabled'); | ||
}; | ||
if (typeof predicate === 'string') { | ||
description = predicate; | ||
} | ||
Log.prototype.assert = function(predicate, description) { | ||
if (description == null) { | ||
description = ''; | ||
if (description) { | ||
description = '(' + description + ') == '; | ||
} | ||
if (typeof predicate === 'string') { | ||
predicate = eval(predicate); | ||
} | ||
if (predicate) { | ||
predicate = 'TRUE'; | ||
} else { | ||
predicate = 'FALSE'; | ||
} | ||
return this.log('\n\t' + _customLog.assertMessage + description + predicate + '\n'); | ||
} | ||
if (typeof predicate === 'string') { | ||
description = predicate; | ||
} | ||
if (description) { | ||
description = '(' + description + ') == '; | ||
} | ||
if (typeof predicate === 'string') { | ||
predicate = eval(predicate); | ||
} | ||
if (predicate) { | ||
predicate = 'TRUE'; | ||
} else { | ||
predicate = 'FALSE'; | ||
} | ||
return this.log('\n\t' + customLog.assertMessage + description + predicate + '\n'); | ||
}; | ||
}]); | ||
return Log; | ||
}(); | ||
})(); | ||
if (typeof init === 'string') { | ||
// end of Log | ||
prefixMsg = init; | ||
} | ||
logInstance = new Log('log', prefixMsg); | ||
log = logInstance.log; | ||
enact = function() { | ||
var i, len, level, levels, method, results; | ||
method = arguments[0], levels = 2 <= arguments.length ? slice.call(arguments, 1) : []; | ||
log = logInstance.log; // one function for enable and disable | ||
enact = function enact(method) { | ||
for (var _len = arguments.length, levels = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
levels[_key - 1] = arguments[_key]; | ||
} | ||
var i, len, level, results; | ||
levels = intoArray(levels); | ||
results = []; | ||
for (i = 0, len = levels.length; i < len; i++) { | ||
level = levels[i]; | ||
if (level === 'log') { | ||
@@ -106,41 +178,47 @@ results.push(logInstance[method]()); | ||
} | ||
return results; | ||
}; | ||
log.enable = function() { | ||
return enact.apply(null, ['enable'].concat(slice.call(arguments))); | ||
log.enable = function () { | ||
return enact.apply(void 0, ['enable'].concat(Array.prototype.slice.call(arguments))); | ||
}; | ||
log.disable = function() { | ||
return enact.apply(null, ['disable'].concat(slice.call(arguments))); | ||
log.disable = function () { | ||
return enact.apply(void 0, ['disable'].concat(Array.prototype.slice.call(arguments))); | ||
}; | ||
if (typeof init === 'object') { | ||
fn = function(level, prefix) { | ||
switch (level) { | ||
case 'log': | ||
return logInstance.prefix = prefix; | ||
case 'assert': | ||
return customLog.assertMessage = prefix; | ||
default: | ||
return log[level] = new Log(level, prefix).log; | ||
} | ||
}; | ||
if (_typeof(init) === 'object') { | ||
for (level in init) { | ||
prefix = init[level]; | ||
fn(level, prefix); | ||
(function (level, prefix) { | ||
switch (level) { | ||
case 'log': | ||
return logInstance.prefix = prefix; | ||
case 'assert': | ||
return _customLog.assertMessage = prefix; | ||
default: | ||
return log[level] = new Log(level, prefix).log; | ||
} | ||
})(level, prefix); | ||
} | ||
} | ||
return log; | ||
}; | ||
customLog.assertMessage = 'Assert: '; | ||
_customLog.assertMessage = 'Assert: '; // end of customLog | ||
if ((typeof define !== "undefined" && define !== null) && ('function' === typeof define) && define.amd) { | ||
define('customLog', [], function() { | ||
return customLog; | ||
if (typeof define !== "undefined" && define !== null && 'function' === typeof define && define.amd) { | ||
define('customLog', [], function () { | ||
return _customLog; | ||
}); | ||
} else if (typeof module !== 'undefined') { | ||
module.exports = customLog; | ||
module.exports = _customLog; | ||
} else if (typeof window !== 'undefined') { | ||
window.customLog = customLog; | ||
window.customLog = _customLog; | ||
} | ||
}).call(this); | ||
}).call(void 0); |
@@ -1,1 +0,1 @@ | ||
(function(){"use strict";var customLog,intoArray,bind=function(e,t){return function(){return e.apply(t,arguments)}},slice=[].slice;intoArray=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},customLog=function(init){var CUSTOM_LOG,Log,enact,fn,level,log,logInstance,prefix,prefixMsg;if(CUSTOM_LOG="custom-log: ",Log=function(){function Log(e,t){this.assert=bind(this.assert,this),this.enable=bind(this.enable,this),this.disable=bind(this.disable,this);var n,i;this.enabled=!0,this.level=e||"log",this.prefix=t||"",this.log=function(e){return function(){var t,n;return e.enabled?(t=arguments,e.prefix&&(t=(n=[e.prefix]).concat.apply(n,arguments)),console.log.apply(console,t)):void 0}}(this);for(n in this)i=this[n],this.hasOwnProperty(n)&&"log"!==n&&(this.log[n]=i)}return Log.prototype.disable=function(){return this.enabled=!1,console.log(CUSTOM_LOG+"."+this.level+" is disabled")},Log.prototype.enable=function(){return this.enabled=!0,console.log(CUSTOM_LOG+"."+this.level+" is enabled")},Log.prototype.assert=function(predicate,description){return null==description&&(description=""),"string"==typeof predicate&&(description=predicate),description&&(description="("+description+") == "),"string"==typeof predicate&&(predicate=eval(predicate)),predicate=predicate?"TRUE":"FALSE",this.log("\n "+customLog.assertMessage+description+predicate+"\n")},Log}(),"string"==typeof init&&(prefixMsg=init),logInstance=new Log("log",prefixMsg),log=logInstance.log,enact=function(){var e,t,n,i,o,s;for(o=arguments[0],i=2<=arguments.length?slice.call(arguments,1):[],i=intoArray(i),s=[],e=0,t=i.length;t>e;e++)n=i[e],s.push("log"===n?logInstance[o]():null!=log[n]?log[n][o]():void 0);return s},log.enable=function(){return enact.apply(null,["enable"].concat(slice.call(arguments)))},log.disable=function(){return enact.apply(null,["disable"].concat(slice.call(arguments)))},"object"==typeof init){fn=function(e,t){switch(e){case"log":return logInstance.prefix=t;case"assert":return customLog.assertMessage=t;default:return log[e]=new Log(e,t).log}};for(level in init)prefix=init[level],fn(level,prefix)}return log},customLog.assertMessage="Assert: ","undefined"!=typeof define&&null!==define&&"function"==typeof define&&define.amd?define("customLog",[],function(){return customLog}):"undefined"!=typeof module?module.exports=customLog:"undefined"!=typeof window&&(window.customLog=customLog)}).call(this); | ||
"use strict";function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}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.")}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(r):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function _iterableToArray(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,o=new Array(t);r<t;r++)o[r]=e[r];return o}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),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 _customLog,intoArray;intoArray=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},_customLog=function customLog(init){var CUSTOM_LOG,Log,enact,level,log,logInstance,prefix,prefixMsg;if(CUSTOM_LOG="custom-log: ",Log=function(){function Log(e,t){var r,o,n=arguments,i=this;for(r in _classCallCheck(this,Log),this.disable=this.disable.bind(this),this.enable=this.enable.bind(this),this.assert=this.assert.bind(this),this.enabled=!0,this.level=e||"log",this.prefix=t||"",this.log=function(){var e;if(i.enabled){var t;if(e=n,i.prefix)e=(t=[i.prefix]).concat.apply(t,_toConsumableArray(n));return console.log.apply(console,e)}},this)o=this[r],this.hasOwnProperty(r)&&"log"!==r&&(this.log[r]=o)}return _createClass(Log,[{key:"disable",value:function(){return this.enabled=!1,console.log(CUSTOM_LOG+"."+this.level+" is disabled")}},{key:"enable",value:function(){return this.enabled=!0,console.log(CUSTOM_LOG+"."+this.level+" is enabled")}},{key:"assert",value:function assert(predicate){var description=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"";return"string"==typeof predicate&&(description=predicate),description=description&&"("+description+") == ","string"==typeof predicate&&(predicate=eval(predicate)),predicate=predicate?"TRUE":"FALSE",this.log("\n\t"+_customLog.assertMessage+description+predicate+"\n")}}]),Log}(),"string"==typeof init&&(prefixMsg=init),logInstance=new Log("log",prefixMsg),log=logInstance.log,enact=function(e){for(var t=arguments.length,r=new Array(1<t?t-1:0),o=1;o<t;o++)r[o-1]=arguments[o];var n,i,a,s;for(s=[],n=0,i=(r=intoArray(r)).length;n<i;n++)"log"===(a=r[n])?s.push(logInstance[e]()):null!=log[a]?s.push(log[a][e]()):s.push(void 0);return s},log.enable=function(){return enact.apply(void 0,["enable"].concat(Array.prototype.slice.call(arguments)))},log.disable=function(){return enact.apply(void 0,["disable"].concat(Array.prototype.slice.call(arguments)))},"object"===_typeof(init))for(level in init)prefix=init[level],function(e,t){switch(e){case"log":return logInstance.prefix=t;case"assert":return _customLog.assertMessage=t;default:log[e]=new Log(e,t).log}}(level,prefix);return log},_customLog.assertMessage="Assert: ","undefined"!=typeof define&&null!==define&&"function"==typeof define&&define.amd?define("customLog",[],function(){return _customLog}):"undefined"!=typeof module?module.exports=_customLog:"undefined"!=typeof window&&(window.customLog=_customLog)}).call(void 0); |
{ | ||
"name": "custom-log", | ||
"version": "0.2.3", | ||
"version": "0.2.4", | ||
"description": "A tiny flexible logger", | ||
"main": "custom-log.min.js", | ||
"scripts": { | ||
"uglify": "uglifyjs custom-log.js -c -m -o custom-log.min.js", | ||
"build": "coffee -c --transpile custom-log.coffee && npm run uglify", | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "latest", | ||
"@babel/preset-env": "latest" | ||
}, | ||
"repository": { | ||
@@ -24,2 +30,2 @@ "type": "git", | ||
"homepage": "https://github.com/phazelift/custom-log" | ||
} | ||
} |
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
20629
175
2