Skip to content

Commit

Permalink
default
Browse files Browse the repository at this point in the history
  • Loading branch information
flavioespinoza committed Mar 18, 2019
1 parent 5e7c86f commit c2e218a
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 174 deletions.
Empty file removed bundle.js
Empty file.
Empty file removed index.d.ts
Empty file.
158 changes: 75 additions & 83 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,155 +1,147 @@
'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }

var _ = _interopDefault(require('lodash'));
var util = _interopDefault(require('util'));
require('colors');
const _ = require('lodash')
const util = require('util')
require('colors')

const log = {
blue: (msg) => {
blue: msg => {
if (typeof msg === 'object') {
msg = _.toString(msg);
msg = _.toString(msg)
}
console.log(`${msg} `.blue);
console.log(`${msg} `.blue)
},
red: (msg) => {
red: msg => {
if (typeof msg === 'object') {
msg = _.toString(msg);
msg = _.toString(msg)
}
console.log(`${msg} `.red);
console.log(`${msg} `.red)
},
green: (msg) => {
green: msg => {
if (typeof msg === 'object') {
msg = _.toString(msg);
msg = _.toString(msg)
}
console.log(`${msg} `.green);
console.log(`${msg} `.green)
},
pink: (msg) => {
pink: msg => {
if (typeof msg === 'object') {
msg = _.toString(msg);
msg = _.toString(msg)
}
console.log(`${msg} `.red.dim);
console.log(`${msg} `.red.dim)
},
yellow: (msg) => {
yellow: msg => {
if (typeof msg === 'object') {
msg = _.toString(msg);
msg = _.toString(msg)
}
console.log(`${msg} `.yellow.bold);
console.log(`${msg} `.yellow.bold)
},
violet: (msg) => {
violet: msg => {
if (typeof msg === 'object') {
msg = _.toString(msg);
msg = _.toString(msg)
}
console.log(`${msg} `.magenta.dim);
console.log(`${msg} `.magenta.dim)
},
magenta: (msg) => {
magenta: msg => {
if (typeof msg === 'object') {
msg = _.toString(msg);
msg = _.toString(msg)
}
console.log(`${msg} `.magenta.bold);
console.log(`${msg} `.magenta.bold)
},
cyan: (msg) => {
cyan: msg => {
if (typeof msg === 'object') {
msg = _.toString(msg);
msg = _.toString(msg)
}
console.log(`${msg} `.cyan);
console.log(`${msg} `.cyan)
}
};
}
const _log = {
deep: (data) => {
deep: data => {
const options = {
showHidden: false,
depth: null,
colors: true
};
const inspect = util.inspect(data, options);
console.log(inspect);
}
const inspect = util.inspect(data, options)
console.log(inspect)
},
info: (msg) => {
info: msg => {
if (typeof msg === 'object') {
msg = _.toString(msg);
msg = _.toString(msg)
}
console.log(` Info: ${msg} `.bgBlue);
console.log(` Info: ${msg} `.bgBlue)
},
error: (msg) => {
error: msg => {
if (typeof msg === 'object') {
msg = _.toString(msg);
msg = _.toString(msg)
}
console.log(` ERROR: ${msg} `.yellow);
console.log(` ERROR: ${msg} `.yellow)
},
alert: (msg) => {
alert: msg => {
if (typeof msg === 'object') {
msg = _.toString(msg);
msg = _.toString(msg)
}
console.log(` Alert: ${msg} `.bgYellow);
console.log(` Alert: ${msg} `.bgYellow)
},
warn: (msg) => {
warn: msg => {
if (typeof msg === 'object') {
msg = _.toString(msg);
msg = _.toString(msg)
}
console.log(` Warn: ${msg} `.bgMagenta);
console.log(` Warn: ${msg} `.bgMagenta)
},
blue: (msg) => {
blue: msg => {
if (typeof msg === 'object') {
msg = _.toString(msg);
msg = _.toString(msg)
}
console.log(`${msg} `.bgBlue);
console.log(`${msg} `.bgBlue)
},
red: (msg) => {
red: msg => {
if (typeof msg === 'object') {
msg = _.toString(msg);
msg = _.toString(msg)
}
console.log(`${msg} `.bgRed);
console.log(`${msg} `.bgRed)
},
green: (msg) => {
green: msg => {
if (typeof msg === 'object') {
msg = _.toString(msg);
msg = _.toString(msg)
}
console.log(`${msg} `.bgGreen);
console.log(`${msg} `.bgGreen)
},
pink: (msg) => {
pink: msg => {
if (typeof msg === 'object') {
msg = _.toString(msg);
msg = _.toString(msg)
}
console.log(`${msg} `.bgRed);
console.log(`${msg} `.bgRed)
},
yellow: (msg) => {
yellow: msg => {
if (typeof msg === 'object') {
msg = _.toString(msg);
msg = _.toString(msg)
}
console.log(`${msg} `.bgYellow);
console.log(`${msg} `.bgYellow)
},
violet: (msg) => {
violet: msg => {
if (typeof msg === 'object') {
msg = _.toString(msg);
msg = _.toString(msg)
}
console.log(`${msg} `.bgMagenta);
console.log(`${msg} `.bgMagenta)
},
cyan: (msg) => {
cyan: msg => {
if (typeof msg === 'object') {
msg = _.toString(msg);
msg = _.toString(msg)
}
console.log(`${msg} `.bgCyan);
console.log(`${msg} `.bgCyan)
},
assert: (item, item_name) => {
if (item) {
let msg = ` SUCCESS: ${item_name} = ${item} `;
console.log(`ASSERT`, msg.bgCyan);
}
else {
let msg = ` FAIL: ${item_name} = ${item} `;
console.log(`ASSERT`, msg.bgRed);
let msg = ` SUCCESS: ${item_name} = ${item} `
console.log(`ASSERT`, msg.bgCyan)
} else {
let msg = ` FAIL: ${item_name} = ${item} `
console.log(`ASSERT`, msg.bgRed)
}
},
timer: (method, method_name) => {
console.time(`Timer ${method_name}()`);
method();
console.timeEnd(`Timer ${method_name}()`);
console.time(`Timer ${method_name}()`)
method()
console.timeEnd(`Timer ${method_name}()`)
}
};
}

exports.log = log;
exports.default = _log;
module.exports = _log
1 change: 0 additions & 1 deletion index.js.map

This file was deleted.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"main": "index.js",
"module": "index.js",
"scripts": {
"test": "node -r esm example.js",
"roll": "rollup src/rollup___.js -o index.js -f cjs"
"test": "node -r esm example.js",
"roll": "rollup src/rollup___.js -o index.js -f cjs"
},
"repository": "git+https://github.com/flavioespinoza/log_log.git",
"keywords": [
Expand Down
95 changes: 7 additions & 88 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,89 +1,8 @@
// rollup.config.js
import resolve from 'rollup-plugin-node-resolve'
import commonjs from 'rollup-plugin-commonjs'

export default {
input: `src/rollup___.js`,
output: {
dir: './',
format: 'cjs'
},
name: 'logdash',
plugins: [
resolve({
// use "module" field for ES6 module if possible
module: true, // Default: true

// use "jsnext:main" if possible
// legacy field pointing to ES6 module in third-party libraries,
// deprecated in favor of "pkg.module":
// - see: https://github.com/rollup/rollup/wiki/pkg.module
jsnext: true, // Default: false

// use "main" field or index.js, even if it's not an ES6 module
// (needs to be converted from CommonJS to ES6
// – see https://github.com/rollup/rollup-plugin-commonjs
main: true, // Default: true

// some package.json files have a `browser` field which
// specifies alternative files to load for people bundling
// for the browser. If that's you, use this option, otherwise
// pkg.browser will be ignored
browser: true, // Default: false

// not all files you want to resolve are .js files
extensions: ['.js'], // Default: [ '.mjs', '.js', '.json', '.node' ]

// whether to prefer built-in modules (e.g. `fs`, `path`) or
// local ones with the same names
preferBuiltins: false, // Default: true

// Lock the module search in this path (like a chroot). Module defined
// outside this path will be marked as external
jail: '/my/jail/path', // Default: '/'

// Set to an array of strings and/or regexps to lock the module search
// to modules that match at least one entry. Modules not matching any
// entry will be marked as external
only: ['some_module', /^@some_scope\/.*$/], // Default: null

// If true, inspect resolved files to check that they are
// ES2015 modules
modulesOnly: true, // Default: false

// Any additional options that should be passed through
// to node-resolve
customResolveOptions: {
moduleDirectory: 'js_modules'
}
}),
commonjs({
// non-CommonJS modules will be ignored, but you can also
// specifically include/exclude files
// include: 'node_modules/**', // Default: undefined
// exclude: ['node_modules/foo/**', 'node_modules/bar/**'], // Default: undefined
// these values can also be regular expressions
include: /node_modules/,

// search for files other than .js files (must already
// be transpiled by a previous plugin!)
extensions: ['.js'], // Default: [ '.js' ]

// if true then uses of `global` won't be dealt with by this plugin
ignoreGlobal: false, // Default: false

// if false then skip sourceMap generation for CommonJS modules
sourceMap: false, // Default: true

// explicitly specify unresolvable named exports
// (see below for more details)
// namedExports: { './module.js': ['foo', 'bar' ] }, // Default: undefined

// sometimes you have to leave require statements
// unconverted. Pass an array containing the IDs
// or a `id => boolean` function. Only use this
// option if you know what you're doing!
ignore: ['conditional-runtime-dependency']
})
]
}
name: 'log_log',
input: 'src/rollup___.js',
output: {
file: 'index.js',
format: 'cjs'
}
};

0 comments on commit c2e218a

Please sign in to comment.