Comparing version 0.2.3 to 0.2.4
import { Config } from "./interfaces/config.interface"; | ||
import { Part } from "./interfaces/part.interface"; | ||
export declare class Achorn { | ||
export default class Achorn { | ||
globalConfig: Config; | ||
@@ -13,3 +13,3 @@ private get longestPrefixLength(); | ||
} | ||
export declare class Timer { | ||
declare class Timer { | ||
achorn: Achorn; | ||
@@ -27,1 +27,2 @@ startTime: number; | ||
} | ||
export {}; |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.achorn=e():t.achorn=e()}(window,(function(){return function(t){var e={};function o(r){if(e[r])return e[r].exports;var s=e[r]={i:r,l:!1,exports:{}};return t[r].call(s.exports,s,s.exports,o),s.l=!0,s.exports}return o.m=t,o.c=e,o.d=function(t,e,r){o.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.t=function(t,e){if(1&e&&(t=o(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(o.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var s in t)o.d(r,s,function(e){return t[e]}.bind(null,s));return r},o.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(e,"a",e),e},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.p="",o(o.s=0)}([function(t,e,o){const r=o(1).Achorn;t.exports=r},function(t,e,o){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Timer=e.Achorn=void 0;const r=o(2);class s{constructor(t){this.globalConfig={},this.config(t||{});r.prefixes.concat(t&&t.prefixes||[]).map(t=>{t.keys.map(t=>{this[t]=(...e)=>{this.consoleLog(t,e)}})})}get longestPrefixLength(){return r.prefixes.map(t=>t.parts[1].string).reduce((t,e)=>t.length>e.length?t:e).length}config(t){this.globalConfig=t}joinParts(t,e){let o=""+" ".repeat(e||0),r=[];return t.map(t=>{o+="%c"+t.string,r.push(t.style)}),[o].concat(r)}calcAdditionalWhitespace(t){const e=t[1].string.length;return this.longestPrefixLength-e+1}consoleLog(t,e){const o=r.prefixes.find(e=>e.keys.includes(t))||r.prefixes.find(t=>t.keys.includes("info"));let s=[].concat(o.parts);switch(s.push({string:" ".repeat(this.calcAdditionalWhitespace(s)),style:"color: unset;"}),this.globalConfig.showTimestamp&&s.unshift({string:`[${(new Date).getHours()}:${(new Date).getMinutes()}:${(new Date).getSeconds()}] `,style:"color: unset;"}),this.globalConfig.globalPrefix&&(s=this.globalConfig.globalPrefix.concat(s)),o.logType){case"warn":return void console.warn(...this.joinParts(s,1),...e.length>0?e:[e[0]]);case"error":return void console.error(...this.joinParts(s,1),...e.length>0?e:[e[0]]);default:console.log(...this.joinParts(s,2),...e.length>0?e:[e[0]])}}timer(t){return new n(t)}}e.Achorn=s;class n{constructor(t){this.achorn=new s,this.key=t,this.start()}start(){this.startTime=+new Date;const t=[{string:"‣ ",style:"color: #2EB6CB;"},{string:this.key?this.key:"timer",style:"color: #2EB6CB; font-weight: bold;"}];t.push({string:" ".repeat(this.achorn.calcAdditionalWhitespace(t)),style:"color: unset;"}),console.log(...this.achorn.joinParts(t,2),"Timer started")}end(){this.endTime=+new Date,this.duration=this.endTime-this.startTime;const t=[{string:"‣ ",style:"color: #2EB6CB;"},{string:this.key?this.key:"timer",style:"color: #2EB6CB; font-weight: bold;"}];t.push({string:" ".repeat(this.achorn.calcAdditionalWhitespace(t)),style:"color: unset;"}),console.log(...this.achorn.joinParts(t,2),`Timer ended after ${this.duration}ms`)}success(...t){this.endTime=+new Date,this.duration=this.endTime-this.startTime;const e=[{string:"✔️ ",style:"color: #7EB507;"},{string:this.key?this.key:"success",style:"color: #7EB507; font-weight: bold;"}];e.push({string:" ".repeat(this.achorn.calcAdditionalWhitespace(e)),style:"color: unset;"}),console.log(...this.achorn.joinParts(e,2),...t&&t.length>0?t:[`Timer succeeded after ${this.duration}ms`])}error(...t){this.endTime=+new Date,this.duration=this.endTime-this.startTime;const e=[{string:"× ",style:"color: #FF312D;"},{string:this.key?this.key:"aborted",style:"color: #FF312D; font-weight: bold;"}];e.push({string:" ".repeat(this.achorn.calcAdditionalWhitespace(e)),style:"color: unset;"}),console.error(...this.achorn.joinParts(e,1),...t&&t.length>0?t:[`Timer errored after ${this.duration}ms`])}abort(...t){this.endTime=+new Date,this.duration=this.endTime-this.startTime;const e=[{string:"⚠️ ",style:"color: #DBA02A;"},{string:this.key?this.key:"error",style:"color: #DBA02A; font-weight: bold;"}];e.push({string:" ".repeat(this.achorn.calcAdditionalWhitespace(e)),style:"color: unset;"}),console.warn(...this.achorn.joinParts(e,1),...t&&t.length>0?t:[`Timer aborted after ${this.duration}ms`])}}e.Timer=n},function(t,e,o){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.prefixes=void 0,e.prefixes=[{keys:["success"],parts:[{string:"✔️ ",style:"color: #7EB507;"},{string:"success",style:"color: #7EB507; font-weight: bold;"}]},{keys:["error"],logType:"error",parts:[{string:"× ",style:"color: #FF312D;"},{string:"error",style:"color: #FF312D; font-weight: bold;"}]},{keys:["warn","warning"],logType:"warn",parts:[{string:"⚠️ ",style:"color: #DBA02A;"},{string:"warning",style:"color: #DBA02A; font-weight: bold;"}]},{keys:["await","awaiting"],parts:[{string:"… ",style:"color: #2EB6CB;"},{string:"awaiting",style:"color: #2EB6CB; font-weight: bold;"}]},{keys:["start"],parts:[{string:"► ",style:"color: #7EB507;"},{string:"start",style:"color: #7EB507; font-weight: bold;"}]},{keys:["pause"],parts:[{string:"‖ ",style:"color: #DBA02A;"},{string:"pause",style:"color: #DBA02A; font-weight: bold;"}]},{keys:["debug"],parts:[{string:"● ",style:"color: #2EB6CB;"},{string:"debug",style:"color: #2EB6CB; font-weight: bold;"}]},{keys:["info"],parts:[{string:"i ",style:"color: #2EB6CB;"},{string:"info",style:"color: #2EB6CB; font-weight: bold;"}]},{keys:["fatal"],logType:"error",parts:[{string:"◆ ",style:"color: #FF312D;"},{string:"fatal",style:"color: #FF312D; font-weight: bold;"}]},{keys:["timerStart"],parts:[{string:"‣ ",style:"color: #2EB6CB;"},{string:"timer",style:"color: #2EB6CB; font-weight: bold;"}]}]}])})); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.achorn=e():t.achorn=e()}(window,(function(){return function(t){var e={};function o(r){if(e[r])return e[r].exports;var s=e[r]={i:r,l:!1,exports:{}};return t[r].call(s.exports,s,s.exports,o),s.l=!0,s.exports}return o.m=t,o.c=e,o.d=function(t,e,r){o.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.t=function(t,e){if(1&e&&(t=o(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(o.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var s in t)o.d(r,s,function(e){return t[e]}.bind(null,s));return r},o.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(e,"a",e),e},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.p="",o(o.s=0)}([function(t,e,o){const r=o(1).Achorn;t.exports=r},function(t,e,o){"use strict";Object.defineProperty(e,"__esModule",{value:!0});const r=o(2);class s{constructor(t){this.globalConfig={},this.config(t||{});r.prefixes.concat(t&&t.prefixes||[]).map(t=>{t.keys.map(t=>{this[t]=(...e)=>{this.consoleLog(t,e)}})})}get longestPrefixLength(){return r.prefixes.map(t=>t.parts[1].string).reduce((t,e)=>t.length>e.length?t:e).length}config(t){this.globalConfig=t}joinParts(t,e){let o=""+" ".repeat(e||0),r=[];return t.map(t=>{o+="%c"+t.string,r.push(t.style)}),[o].concat(r)}calcAdditionalWhitespace(t){const e=t[1].string.length;return this.longestPrefixLength-e+1}consoleLog(t,e){const o=r.prefixes.find(e=>e.keys.includes(t))||r.prefixes.find(t=>t.keys.includes("info"));let s=[].concat(o.parts);switch(s.push({string:" ".repeat(this.calcAdditionalWhitespace(s)),style:"color: unset;"}),this.globalConfig.showTimestamp&&s.unshift({string:`[${(new Date).getHours()}:${(new Date).getMinutes()}:${(new Date).getSeconds()}] `,style:"color: unset;"}),this.globalConfig.globalPrefix&&(s=this.globalConfig.globalPrefix.concat(s)),o.logType){case"warn":return void console.warn(...this.joinParts(s,1),...e.length>0?e:[e[0]]);case"error":return void console.error(...this.joinParts(s,1),...e.length>0?e:[e[0]]);default:console.log(...this.joinParts(s,2),...e.length>0?e:[e[0]])}}timer(t){return new n(t)}}e.default=s;class n{constructor(t){this.achorn=new s,this.key=t,this.start()}start(){this.startTime=+new Date;const t=[{string:"‣ ",style:"color: #2EB6CB;"},{string:this.key?this.key:"timer",style:"color: #2EB6CB; font-weight: bold;"}];t.push({string:" ".repeat(this.achorn.calcAdditionalWhitespace(t)),style:"color: unset;"}),console.log(...this.achorn.joinParts(t,2),"Timer started")}end(){this.endTime=+new Date,this.duration=this.endTime-this.startTime;const t=[{string:"‣ ",style:"color: #2EB6CB;"},{string:this.key?this.key:"timer",style:"color: #2EB6CB; font-weight: bold;"}];t.push({string:" ".repeat(this.achorn.calcAdditionalWhitespace(t)),style:"color: unset;"}),console.log(...this.achorn.joinParts(t,2),`Timer ended after ${this.duration}ms`)}success(...t){this.endTime=+new Date,this.duration=this.endTime-this.startTime;const e=[{string:"✔️ ",style:"color: #7EB507;"},{string:this.key?this.key:"success",style:"color: #7EB507; font-weight: bold;"}];e.push({string:" ".repeat(this.achorn.calcAdditionalWhitespace(e)),style:"color: unset;"}),console.log(...this.achorn.joinParts(e,2),...t&&t.length>0?t:[`Timer succeeded after ${this.duration}ms`])}error(...t){this.endTime=+new Date,this.duration=this.endTime-this.startTime;const e=[{string:"× ",style:"color: #FF312D;"},{string:this.key?this.key:"aborted",style:"color: #FF312D; font-weight: bold;"}];e.push({string:" ".repeat(this.achorn.calcAdditionalWhitespace(e)),style:"color: unset;"}),console.error(...this.achorn.joinParts(e,1),...t&&t.length>0?t:[`Timer errored after ${this.duration}ms`])}abort(...t){this.endTime=+new Date,this.duration=this.endTime-this.startTime;const e=[{string:"⚠️ ",style:"color: #DBA02A;"},{string:this.key?this.key:"error",style:"color: #DBA02A; font-weight: bold;"}];e.push({string:" ".repeat(this.achorn.calcAdditionalWhitespace(e)),style:"color: unset;"}),console.warn(...this.achorn.joinParts(e,1),...t&&t.length>0?t:[`Timer aborted after ${this.duration}ms`])}}},function(t,e,o){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.prefixes=void 0,e.prefixes=[{keys:["success"],parts:[{string:"✔️ ",style:"color: #7EB507;"},{string:"success",style:"color: #7EB507; font-weight: bold;"}]},{keys:["error"],logType:"error",parts:[{string:"× ",style:"color: #FF312D;"},{string:"error",style:"color: #FF312D; font-weight: bold;"}]},{keys:["warn","warning"],logType:"warn",parts:[{string:"⚠️ ",style:"color: #DBA02A;"},{string:"warning",style:"color: #DBA02A; font-weight: bold;"}]},{keys:["await","awaiting"],parts:[{string:"… ",style:"color: #2EB6CB;"},{string:"awaiting",style:"color: #2EB6CB; font-weight: bold;"}]},{keys:["start"],parts:[{string:"► ",style:"color: #7EB507;"},{string:"start",style:"color: #7EB507; font-weight: bold;"}]},{keys:["pause"],parts:[{string:"‖ ",style:"color: #DBA02A;"},{string:"pause",style:"color: #DBA02A; font-weight: bold;"}]},{keys:["debug"],parts:[{string:"● ",style:"color: #2EB6CB;"},{string:"debug",style:"color: #2EB6CB; font-weight: bold;"}]},{keys:["info"],parts:[{string:"i ",style:"color: #2EB6CB;"},{string:"info",style:"color: #2EB6CB; font-weight: bold;"}]},{keys:["fatal"],logType:"error",parts:[{string:"◆ ",style:"color: #FF312D;"},{string:"fatal",style:"color: #FF312D; font-weight: bold;"}]},{keys:["timerStart"],parts:[{string:"‣ ",style:"color: #2EB6CB;"},{string:"timer",style:"color: #2EB6CB; font-weight: bold;"}]}]}])})); |
{ | ||
"name": "achorn", | ||
"version": "0.2.3", | ||
"version": "0.2.4", | ||
"description": "🌰 A colourful, good looking, fully customisable logger for the browser", | ||
@@ -5,0 +5,0 @@ "publishConfig": { |
46
12182