Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

consola

Package Overview
Dependencies
Maintainers
3
Versions
91
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

consola - npm Package Compare versions

Comparing version 2.6.1 to 2.6.2

9

CHANGELOG.md

@@ -5,2 +5,11 @@ # Changelog

### [2.6.2](https://github.com/nuxt/consola/compare/v2.6.1...v2.6.2) (2019-05-15)
### Bug Fixes
* transpile browser dist to ES5 ([1f81eea](https://github.com/nuxt/consola/commit/1f81eea)), closes [nuxt/nuxt.js#5743](https://github.com/nuxt/consola/issues/5743)
### [2.6.1](https://github.com/nuxt/consola/compare/v2.6.0...v2.6.1) (2019-05-08)

@@ -7,0 +16,0 @@

2

dist/consola.browser.js

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).consola=t()}(this,function(){"use strict";var e={fatal:{level:0},error:{level:0},warn:{level:1},log:{level:2},info:{level:3},success:{level:3},debug:{level:4},trace:{level:5},silent:{level:1/0},ready:{level:3},start:{level:3}};function t(e){return t=e,"[object Object]"===Object.prototype.toString.call(t)&&(!(!e.message&&!e.args)&&!e.stack);var t}let s=!1;const r=[];class o{constructor(t={}){this._reporters=t.reporters||[],this._types=t.types||e,this._level=null!=t.level?t.level:3,this._defaults=t.defaults||{},this._async=void 0!==t.async?t.async:null,this._stdout=t.stdout,this._stderr=t.stdout,this._mockFn=t.mockFn;for(const e in this._types)this[e]=this._wrapLogFn(Object.assign({type:e},this._types[e],this._defaults));this._mockFn&&this.mockTypes()}get level(){return this._level}set level(e){let t=0,s=0;for(const e in this._types){const r=this._types[e];r.level>s?s=r.level:r.level<t&&(t=r.level)}this._level=Math.min(s,Math.max(t,e))}get stdout(){return this._stdout||console._stdout}get stderr(){return this._stderr||console._stderr}create(e){return new o(Object.assign({reporters:this._reporters,level:this._level,types:this._types,defaults:this._defaults,stdout:this._stdout,stderr:this._stderr,mockFn:this._mockFn},e))}withDefaults(e){return this.create({defaults:Object.assign({},this._defaults,e)})}withTag(e){return this.withDefaults({tag:this._defaults.tag?this._defaults.tag+":"+e:e})}addReporter(e){return this._reporters.push(e),this}removeReporter(e){if(e){const t=this._reporters.indexOf(e);if(t>=0)return this._reporters.splice(t,1)}else this._reporters.splice(0);return this}setReporters(e){return this._reporters=Array.isArray(e)?e:[e],this}wrapAll(){this.wrapConsole(),this.wrapStd()}restoreAll(){this.restoreConsole(),this.restoreStd()}wrapConsole(){for(const e in this._types)console["__"+e]||(console["__"+e]=console[e]),console[e]=this[e]}restoreConsole(){for(const e in this._types)console["__"+e]&&(console[e]=console["__"+e],delete console["__"+e])}wrapStd(){this._wrapStream(this.stdout,"log"),this._wrapStream(this.stderr,"log")}_wrapStream(e,t){e&&(e.__write||(e.__write=e.write),e.write=(e=>{this[t](String(e).trim())}))}restoreStd(){this._restoreStream(this.stdout),this._restoreStream(this.stderr)}_restoreStream(e){e&&e.__write&&(e.write=e.__write,delete e.__write)}pauseLogs(){s=!0}resumeLogs(){s=!1;const e=r.splice(0);for(const t of e)t[0]._logFn(t[1],t[2])}mockTypes(e){if(this._mockFn=e||this._mockFn,"function"==typeof this._mockFn)for(const e in this._types)this[e]=this._mockFn(e,this._types[e])||this[e]}_wrapLogFn(e){return function(){if(!s)return this._logFn(e,arguments);r.push([this,e,arguments])}.bind(this)}_logFn(e,s){if(e.level>this._level)return!!this._async&&Promise.resolve(!1);const r=Object.assign({date:new Date,args:[]},e);if(1===s.length&&t(s[0])?Object.assign(r,s[0]):r.args=Array.from(s),r.message&&(r.args.unshift(r.message),delete r.message),r.additional&&(Array.isArray(r.additional)||(r.additional=r.additional.split("\n")),r.args.push("\n"+r.additional.join("\n")),delete r.additional),this._async)return this._logAsync(r);this._log(r)}_log(e){for(const t of this._reporters)t.log(e,{async:!1,stdout:this.stdout,stderr:this.stderr})}_logAsync(e){return Promise.all(this._reporters.map(t=>t.log(e,{async:!0,stdout:this.stdout,stderr:this.stderr})))}}o.prototype.add=o.prototype.addReporter,o.prototype.remove=o.prototype.removeReporter,o.prototype.clear=o.prototype.removeReporter,o.prototype.withScope=o.prototype.withTag,o.prototype.mock=o.prototype.mockTypes,o.prototype.pause=o.prototype.pauseLogs,o.prototype.resume=o.prototype.resumeLogs;const i={info:"cyan"},l={0:"red",1:"yellow",2:"white",3:"green"};class n{constructor(e){this.options=Object.assign({},e)}log(e){const t=e.level<1?console.__error||console.error:1===e.level&&console.warn?console.__warn||console.warn:console.__log||console.log,s="log"!==e.type?`[${e.type.toUpperCase()}]`:"",r=e.tag?`[${e.tag.toUpperCase()}]`:"",o=`[${new Date(e.date).toLocaleTimeString()}]`,n=`color: ${i[e.type]||l[e.level]}; background-color: inherit;`;t("%c"+o+r+"%c"+s,`color: ${e.additionalColor||"grey"}; background-color: inherit;`,n,...e.args)}}return"undefined"!=typeof window&&window.consola||function(){const e=new o({reporters:[new n]});return e.Consola=o,e.BrowserReporter=n,e}()});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).consola=t()}(this,function(){"use strict";function e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function t(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 r(e,r,o){return r&&t(e.prototype,r),o&&t(e,o),e}function o(e){return function(e){if(Array.isArray(e)){for(var t=0,r=new Array(e.length);t<e.length;t++)r[t]=e[t];return r}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}var n={fatal:{level:0},error:{level:0},warn:{level:1},log:{level:2},info:{level:3},success:{level:3},debug:{level:4},trace:{level:5},silent:{level:1/0},ready:{level:3},start:{level:3}};function s(e){return t=e,"[object Object]"===Object.prototype.toString.call(t)&&(!(!e.message&&!e.args)&&!e.stack);var t}var i=!1,l=[],a=function(){function t(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};for(var o in e(this,t),this._reporters=r.reporters||[],this._types=r.types||n,this._level=null!=r.level?r.level:3,this._defaults=r.defaults||{},this._async=void 0!==r.async?r.async:null,this._stdout=r.stdout,this._stderr=r.stdout,this._mockFn=r.mockFn,this._types)this[o]=this._wrapLogFn(Object.assign({type:o},this._types[o],this._defaults));this._mockFn&&this.mockTypes()}return r(t,[{key:"create",value:function(e){return new t(Object.assign({reporters:this._reporters,level:this._level,types:this._types,defaults:this._defaults,stdout:this._stdout,stderr:this._stderr,mockFn:this._mockFn},e))}},{key:"withDefaults",value:function(e){return this.create({defaults:Object.assign({},this._defaults,e)})}},{key:"withTag",value:function(e){return this.withDefaults({tag:this._defaults.tag?this._defaults.tag+":"+e:e})}},{key:"addReporter",value:function(e){return this._reporters.push(e),this}},{key:"removeReporter",value:function(e){if(e){var t=this._reporters.indexOf(e);if(t>=0)return this._reporters.splice(t,1)}else this._reporters.splice(0);return this}},{key:"setReporters",value:function(e){return this._reporters=Array.isArray(e)?e:[e],this}},{key:"wrapAll",value:function(){this.wrapConsole(),this.wrapStd()}},{key:"restoreAll",value:function(){this.restoreConsole(),this.restoreStd()}},{key:"wrapConsole",value:function(){for(var e in this._types)console["__"+e]||(console["__"+e]=console[e]),console[e]=this[e]}},{key:"restoreConsole",value:function(){for(var e in this._types)console["__"+e]&&(console[e]=console["__"+e],delete console["__"+e])}},{key:"wrapStd",value:function(){this._wrapStream(this.stdout,"log"),this._wrapStream(this.stderr,"log")}},{key:"_wrapStream",value:function(e,t){var r=this;e&&(e.__write||(e.__write=e.write),e.write=function(e){r[t](String(e).trim())})}},{key:"restoreStd",value:function(){this._restoreStream(this.stdout),this._restoreStream(this.stderr)}},{key:"_restoreStream",value:function(e){e&&e.__write&&(e.write=e.__write,delete e.__write)}},{key:"pauseLogs",value:function(){i=!0}},{key:"resumeLogs",value:function(){i=!1;var e=l.splice(0),t=!0,r=!1,o=void 0;try{for(var n,s=e[Symbol.iterator]();!(t=(n=s.next()).done);t=!0){var a=n.value;a[0]._logFn(a[1],a[2])}}catch(e){r=!0,o=e}finally{try{t||null==s.return||s.return()}finally{if(r)throw o}}}},{key:"mockTypes",value:function(e){if(this._mockFn=e||this._mockFn,"function"==typeof this._mockFn)for(var t in this._types)this[t]=this._mockFn(t,this._types[t])||this[t]}},{key:"_wrapLogFn",value:function(e){return function(){if(!i)return this._logFn(e,arguments);l.push([this,e,arguments])}.bind(this)}},{key:"_logFn",value:function(e,t){if(e.level>this._level)return!!this._async&&Promise.resolve(!1);var r=Object.assign({date:new Date,args:[]},e);if(1===t.length&&s(t[0])?Object.assign(r,t[0]):r.args=Array.from(t),r.message&&(r.args.unshift(r.message),delete r.message),r.additional&&(Array.isArray(r.additional)||(r.additional=r.additional.split("\n")),r.args.push("\n"+r.additional.join("\n")),delete r.additional),this._async)return this._logAsync(r);this._log(r)}},{key:"_log",value:function(e){var t=!0,r=!1,o=void 0;try{for(var n,s=this._reporters[Symbol.iterator]();!(t=(n=s.next()).done);t=!0){n.value.log(e,{async:!1,stdout:this.stdout,stderr:this.stderr})}}catch(e){r=!0,o=e}finally{try{t||null==s.return||s.return()}finally{if(r)throw o}}}},{key:"_logAsync",value:function(e){var t=this;return Promise.all(this._reporters.map(function(r){return r.log(e,{async:!0,stdout:t.stdout,stderr:t.stderr})}))}},{key:"level",get:function(){return this._level},set:function(e){var t=0,r=0;for(var o in this._types){var n=this._types[o];n.level>r?r=n.level:n.level<t&&(t=n.level)}this._level=Math.min(r,Math.max(t,e))}},{key:"stdout",get:function(){return this._stdout||console._stdout}},{key:"stderr",get:function(){return this._stderr||console._stderr}}]),t}();a.prototype.add=a.prototype.addReporter,a.prototype.remove=a.prototype.removeReporter,a.prototype.clear=a.prototype.removeReporter,a.prototype.withScope=a.prototype.withTag,a.prototype.mock=a.prototype.mockTypes,a.prototype.pause=a.prototype.pauseLogs,a.prototype.resume=a.prototype.resumeLogs;var u,c={info:"cyan"},p={0:"red",1:"yellow",2:"white",3:"green"},h=function(){function t(r){e(this,t),this.options=Object.assign({},r)}return r(t,[{key:"log",value:function(e){var t=e.level<1?console.__error||console.error:1===e.level&&console.warn?console.__warn||console.warn:console.__log||console.log,r="log"!==e.type?"[".concat(e.type.toUpperCase(),"]"):"",n=e.tag?"[".concat(e.tag.toUpperCase(),"]"):"",s="[".concat(new Date(e.date).toLocaleTimeString(),"]"),i=c[e.type]||p[e.level],l="color: ".concat(i,"; background-color: inherit;"),a="color: ".concat(e.additionalColor||"grey","; background-color: inherit;");t.apply(void 0,["%c"+s+n+"%c"+r,a,l].concat(o(e.args)))}}]),t}();return"undefined"!=typeof window&&window.consola||((u=new a({reporters:[new h]})).Consola=a,u.BrowserReporter=h,u)});
{
"name": "consola",
"version": "2.6.1",
"version": "2.6.2",
"description": "Elegant Console Logger for Node.js and Browser",

@@ -12,4 +12,4 @@ "license": "MIT",

"build": "rm -rf dist && yarn build:node && yarn build:browser",
"build:node": "bili src/node.js --file-name consola.js --format cjs --bundle-node-modules --minify --no-map",
"build:browser": "bili src/browser.js --file-name consola.browser.js --format umd --module-name consola --bundle-node-modules --minify --no-map",
"build:node": "NODE_ENV=node bili src/node.js --file-name consola.js --format cjs --bundle-node-modules --minify --no-map",
"build:browser": "NODE_ENV=browser bili src/browser.js --file-name consola.browser.js --format umd --module-name consola --bundle-node-modules --minify --no-map",
"demo": "node demo",

@@ -50,3 +50,3 @@ "browser": "serve",

"benchmark": "^2.1.4",
"bili": "^4.4.0",
"bili": "^4.8.0",
"chalk": "^2.4.2",

@@ -53,0 +53,0 @@ "dayjs": "^1.8.6",

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