Last active
March 11, 2019 17:17
-
-
Save danielskapunk/65e394ff1ca577be710295fddc2207ef to your computer and use it in GitHub Desktop.
Console log wrapper with line numbers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * console wrapper with line numbers | |
| * Usage: | |
| * import * as c from 'console' | |
| * c.log('abc'); | |
| * | |
| * Ref: https://matthewspencer.github.io/console-log/ | |
| */ | |
| /*eslint-disable */ | |
| const slice = [].slice; | |
| const enabled = window.location.hostname.indexOf('localhost') !== -1; | |
| export const log = function log() { | |
| if (!window.console || !console.log) { | |
| return function() {}; | |
| } | |
| if (!enabled) return function() {}; | |
| return Function.prototype.bind.call(console.log, console); | |
| }(); | |
| export const clear = function clear() { | |
| if (!window.console || !console.clear) { | |
| return function() {}; | |
| } | |
| if (!enabled) return function() {}; | |
| return Function.prototype.bind.call(console.clear, console); | |
| }(); | |
| export const debug = function debug() { | |
| if (!window.console || !console.debug) { | |
| return function() {}; | |
| } | |
| if (!enabled) return function() {}; | |
| return Function.prototype.bind.call(console.debug, console); | |
| }(); | |
| export const info = function info() { | |
| if (!window.console || !console.info) { | |
| return function() {}; | |
| } | |
| if (!enabled) return function() {}; | |
| return Function.prototype.bind.call(console.info, console); | |
| }(); | |
| export const warn = function warn() { | |
| if (!window.console || !console.warn) { | |
| return function() {}; | |
| } | |
| if (!enabled) return function() {}; | |
| return Function.prototype.bind.call(console.warn, console); | |
| }(); | |
| export const error = function error() { | |
| if (!window.console || !console.error) { | |
| return function() {}; | |
| } | |
| if (!enabled) return function() {}; | |
| return Function.prototype.bind.call(console.error, console); | |
| }(); | |
| /*eslint-enable */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "name": "dconsole.js", | |
| "version": "0.1.0" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment