--
This commit is contained in:
parent
24f3d27984
commit
6b60015c02
9588 changed files with 1149251 additions and 49 deletions
3
node_modules/better-console/.npmignore
generated
vendored
Normal file
3
node_modules/better-console/.npmignore
generated
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
node_modules
|
||||
.DS_Store
|
||||
npm-debug.log
|
||||
66
node_modules/better-console/README.md
generated
vendored
Normal file
66
node_modules/better-console/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
# Better Console
|
||||
|
||||

|
||||
|
||||
## Installation
|
||||
|
||||
Use NPM
|
||||
|
||||
```shell
|
||||
$ npm install better-console
|
||||
```
|
||||
|
||||
## A better console for Node.js
|
||||
|
||||
|
||||
`better-console` is a drop-in replacement for node's default console which
|
||||
gives you colors and more methods in console.
|
||||
|
||||
## How to use it
|
||||
|
||||
You can override `console` object itself or assign better console to another variable. It's completely safe to override the native console object because better console calls native console methods for methods that are already available in it.
|
||||
|
||||
```
|
||||
var console = require('better-console');
|
||||
|
||||
console.log("This is a log information");
|
||||
console.warn("Warning!");
|
||||
console.info("Information");
|
||||
console.table([ [1,2], [3,4] ]);
|
||||
console.time("Timer");
|
||||
console.timeEnd("Timer");
|
||||
console.dir(myObject);
|
||||
|
||||
```
|
||||
|
||||
## Methods
|
||||
|
||||
### `console.log`, `console.warn`, `console.error`, `console.info`, `console.debug`, `console.dir`, `console.trace`
|
||||
These methods work exactly same as native console methods but with colors for `warn`, `info` or `error`
|
||||
|
||||
### `console.clear`
|
||||
|
||||
Clears the screen
|
||||
|
||||
### `console.table`
|
||||
|
||||
Draws a table of data if a 2d array or object passed to it
|
||||
|
||||
### `console.time`
|
||||
|
||||
Creates a new timer under the given name. Call console.timeEnd(name)`
|
||||
with the same name to stop the timer and print the time elapsed.
|
||||
|
||||
### `console.timeEnd`
|
||||
|
||||
Stops a timer created by a call to console.time(name) and write the time
|
||||
|
||||
|
||||
### `console.count`
|
||||
|
||||
Writes number of times each argument is called with blue color
|
||||
|
||||
## TODOs
|
||||
|
||||
* Use Unicode icons to mimic browser console icons in OSX
|
||||
* Make `console.trace` more detailed with V8 flags
|
||||
22
node_modules/better-console/demo.js
generated
vendored
Normal file
22
node_modules/better-console/demo.js
generated
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
var console = require('./index');
|
||||
|
||||
console.log('> console.info("This is information")');
|
||||
console.info("This is information");
|
||||
|
||||
console.log('');
|
||||
console.log('> console.error("Oops!")');
|
||||
console.error("Oops!");
|
||||
|
||||
console.log('');
|
||||
console.log("> var arr = [");
|
||||
console.log(" ['a','b','c','d'],");
|
||||
console.log(" ['e','f','h','j']");
|
||||
console.log(" ];");
|
||||
console.log("> console.table(arr);");
|
||||
|
||||
var arr = [
|
||||
['a','b','c','d'],
|
||||
['e','f','h','j']
|
||||
];
|
||||
console.table(arr);
|
||||
console.log('> ');
|
||||
107
node_modules/better-console/index.js
generated
vendored
Normal file
107
node_modules/better-console/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
var chalk = require('chalk');
|
||||
var util = require('util');
|
||||
var logTable = require('./log_table');
|
||||
var countBuffer = {};
|
||||
|
||||
function logWithColor(color, args, isError){
|
||||
var log = util.format.apply(this, args);
|
||||
if(isError)
|
||||
console.error(chalk[color](log));
|
||||
else
|
||||
console.log(chalk[color](log));
|
||||
}
|
||||
|
||||
|
||||
module.exports = {
|
||||
|
||||
// Writes a message to the console. You may pass as many arguments as
|
||||
// you'd like, and they will be joined together in a space-delimited line.
|
||||
// The first argument to log may be a string containing
|
||||
// printf-like string substitution patterns.
|
||||
log: function(){
|
||||
console.log.apply(this, arguments);
|
||||
},
|
||||
|
||||
// Writes a message to the console with blue color
|
||||
info: function(){
|
||||
logWithColor('blue', arguments);
|
||||
},
|
||||
|
||||
// Writes a message to the console with yellow color
|
||||
warn: function(){
|
||||
logWithColor('yellow', arguments, true);
|
||||
},
|
||||
|
||||
// Writes a message to the console with red color
|
||||
error: function(){
|
||||
logWithColor('red', arguments, true);
|
||||
},
|
||||
|
||||
// Writes a message to the console with regular color
|
||||
debug: function(){
|
||||
console.log.apply(this, arguments);
|
||||
},
|
||||
|
||||
// Prints an interactive listing of all properties of the object.
|
||||
dir: function(){
|
||||
console.dir.apply(this, arguments);
|
||||
},
|
||||
|
||||
// Clears the terminal buffer
|
||||
clear: function(){
|
||||
process.stdout.write('\u001B[2J\u001B[0;0f');
|
||||
},
|
||||
|
||||
// Prints a stack trace of JavaScript execution at the point
|
||||
// where it is called. The stack trace details the functions on the stack,
|
||||
// as well as the values that were passed as arguments to each function.
|
||||
trace: function(){
|
||||
console.trace.apply(this, arguments);
|
||||
},
|
||||
|
||||
// Does nothing if first argument is truly. If first argument is falsy
|
||||
// it Writes red warning and throws assertion error
|
||||
assert: function(assertion){
|
||||
// todo: for now we are cheating, it's just console.erroring and then
|
||||
// leave console.asset to do it's job. actual todo: print what
|
||||
// console.assert prints just make first line red
|
||||
if (!assertion){
|
||||
logWithColor('red', ['AssertionError: false == true']);
|
||||
console.assert(assertion);
|
||||
}
|
||||
},
|
||||
|
||||
// Writes number of times each argument is called with blue color
|
||||
count: function(toCount){
|
||||
var toCountString = toCount.toString && toCount.toString(),
|
||||
log;
|
||||
|
||||
if (countBuffer[toCountString] == null){
|
||||
countBuffer[toCountString] = 0;
|
||||
}else{
|
||||
countBuffer[toCountString] += 1;
|
||||
}
|
||||
|
||||
log = toCountString + ': ' + countBuffer[toCountString];
|
||||
logWithColor('blue', [log]);
|
||||
},
|
||||
|
||||
// Creates a new timer under the given name. Call console.timeEnd(name)
|
||||
// with the same name to stop the timer and print the time elapsed..
|
||||
time: function(){
|
||||
console.time.apply(this, arguments);
|
||||
},
|
||||
|
||||
// Stops a timer created by a call to console.time(name) and writes the time
|
||||
// elapsed.
|
||||
timeEnd: function(){
|
||||
console.timeEnd.apply(this, arguments);
|
||||
},
|
||||
|
||||
// draws a table of elements inside of a 2d array or object
|
||||
table: function(){
|
||||
logTable.apply(this, arguments);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
71
node_modules/better-console/log_table.js
generated
vendored
Normal file
71
node_modules/better-console/log_table.js
generated
vendored
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
var Table = require('cli-table');
|
||||
|
||||
module.exports = exports = function logTable(data){
|
||||
if(typeof data !== 'object' || data === null){
|
||||
console.log('');
|
||||
return;
|
||||
}
|
||||
|
||||
if(typeof data[Object.keys(data)[0]] !== 'object' || data[Object.keys(data)[0]] === null){
|
||||
console.log('');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
var firstKey = Object.keys(data)[0];
|
||||
var firstObject = data[firstKey];
|
||||
var thead = Object.keys(firstObject);
|
||||
thead.unshift('(index)');
|
||||
var colWidths = thead.map(calculateColWidth);
|
||||
|
||||
|
||||
Object.keys(data).forEach(function(rowKey){
|
||||
var row = data[rowKey];
|
||||
|
||||
if(typeof row == 'object'){
|
||||
Object.keys(row).forEach(function(k,i){
|
||||
var width = calculateColWidth (row[k]);
|
||||
if(colWidths[i+1] < width)
|
||||
colWidths[i+1] = width;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
var table = new Table({
|
||||
head: thead,
|
||||
colWidths: colWidths
|
||||
});
|
||||
|
||||
Object.keys(data).forEach(function(rowKey){
|
||||
var row = data[rowKey];
|
||||
var rowValues = [];
|
||||
|
||||
if(typeof row == 'object'){
|
||||
rowValues = Object.keys(row).map(function(k){
|
||||
return row[k];
|
||||
});
|
||||
}
|
||||
table.push([rowKey].concat(rowValues));
|
||||
});
|
||||
|
||||
console.log(table.toString());
|
||||
|
||||
function calculateColWidth (item) {
|
||||
var MAX_COL_WIDTH = 28;
|
||||
var MIN_COL_WIDTH = 3;
|
||||
var width = null;
|
||||
|
||||
if(item.toString){
|
||||
if(item.toString().length > MAX_COL_WIDTH)
|
||||
width = MAX_COL_WIDTH;
|
||||
if(item.toString().length < MIN_COL_WIDTH)
|
||||
width = MIN_COL_WIDTH;
|
||||
else if(!width)
|
||||
width = item.toString().length;
|
||||
}else{
|
||||
width = MAX_COL_WIDTH;
|
||||
}
|
||||
|
||||
return width + 2;
|
||||
}
|
||||
};
|
||||
89
node_modules/better-console/package.json
generated
vendored
Normal file
89
node_modules/better-console/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
{
|
||||
"_args": [
|
||||
[
|
||||
{
|
||||
"raw": "better-console@*",
|
||||
"scope": null,
|
||||
"escapedName": "better-console",
|
||||
"name": "better-console",
|
||||
"rawSpec": "*",
|
||||
"spec": "*",
|
||||
"type": "range"
|
||||
},
|
||||
"/Users/jose/Documents/GitHub/Mods/node_modules/semantic-ui"
|
||||
]
|
||||
],
|
||||
"_from": "better-console@*",
|
||||
"_id": "better-console@1.0.0",
|
||||
"_inCache": true,
|
||||
"_location": "/better-console",
|
||||
"_nodeVersion": "6.3.1",
|
||||
"_npmOperationalInternal": {
|
||||
"host": "packages-12-west.internal.npmjs.com",
|
||||
"tmp": "tmp/better-console-1.0.0.tgz_1483676014497_0.18242637277580798"
|
||||
},
|
||||
"_npmUser": {
|
||||
"name": "mohsen",
|
||||
"email": "me@azimi.me"
|
||||
},
|
||||
"_npmVersion": "3.10.3",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"raw": "better-console@*",
|
||||
"scope": null,
|
||||
"escapedName": "better-console",
|
||||
"name": "better-console",
|
||||
"rawSpec": "*",
|
||||
"spec": "*",
|
||||
"type": "range"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/semantic-ui"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/better-console/-/better-console-1.0.0.tgz",
|
||||
"_shasum": "cd696fa385eba396b8e0fdf54f75afddda6dd2a5",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "better-console@*",
|
||||
"_where": "/Users/jose/Documents/GitHub/Mods/node_modules/semantic-ui",
|
||||
"author": {
|
||||
"name": "Mohsen Azimi"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/mohsen1/better-console/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"chalk": "^1.1.3",
|
||||
"cli-table": "~0.3.1"
|
||||
},
|
||||
"description": "A better console for Node.js",
|
||||
"devDependencies": {},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "cd696fa385eba396b8e0fdf54f75afddda6dd2a5",
|
||||
"tarball": "https://registry.npmjs.org/better-console/-/better-console-1.0.0.tgz"
|
||||
},
|
||||
"gitHead": "f60aef580e95e1ab5649ec320b5f445279d74829",
|
||||
"homepage": "https://github.com/mohsen1/better-console#readme",
|
||||
"keywords": [
|
||||
"console"
|
||||
],
|
||||
"license": "BSD",
|
||||
"main": "index.js",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "mohsen",
|
||||
"email": "msnazi@gmail.com"
|
||||
}
|
||||
],
|
||||
"name": "better-console",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/mohsen1/better-console.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "node test.js"
|
||||
},
|
||||
"version": "1.0.0"
|
||||
}
|
||||
BIN
node_modules/better-console/screenshot.png
generated
vendored
Normal file
BIN
node_modules/better-console/screenshot.png
generated
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 66 KiB |
88
node_modules/better-console/test.js
generated
vendored
Normal file
88
node_modules/better-console/test.js
generated
vendored
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
var console = require('./index');
|
||||
|
||||
console.log('Something');
|
||||
console.clear();
|
||||
console.info('Console should be clean now');
|
||||
|
||||
console.log('Log');
|
||||
console.log('A string');
|
||||
console.log('A manipulated string (%s) with number: %d', 'apple', 42);
|
||||
console.log(1);
|
||||
console.log(true);
|
||||
console.log({ me: 1 });
|
||||
console.log([1, 2, 3]);
|
||||
console.log('');
|
||||
|
||||
|
||||
console.info('Information');
|
||||
console.info('A string');
|
||||
console.info('A manipulated string (%s) with number: %d', 'apple', 42);
|
||||
console.info(1);
|
||||
console.info(true);
|
||||
console.info({ me: 1 });
|
||||
console.info([1, 2, 3]);
|
||||
console.info('');
|
||||
|
||||
|
||||
console.warn('Warning');
|
||||
console.warn('A string');
|
||||
console.warn('A manipulated string (%s) with number: %d', 'apple', 42);
|
||||
console.warn(1);
|
||||
console.warn(true);
|
||||
console.warn({ me: 1 });
|
||||
console.warn([1, 2, 3]);
|
||||
console.warn('');
|
||||
|
||||
|
||||
console.error('Error');
|
||||
console.error('A string');
|
||||
console.error('A manipulated string (%s) with number: %d', 'apple', 42);
|
||||
console.error(1);
|
||||
console.error(true);
|
||||
console.error({ me: 1 });
|
||||
console.error([1, 2, 3]);
|
||||
console.error('');
|
||||
|
||||
|
||||
|
||||
console.count('me');
|
||||
console.count('me');
|
||||
|
||||
var arr = [
|
||||
['a', 'b', 'c', 'd'],
|
||||
['e', 'f', 'h', 'j']
|
||||
];
|
||||
console.table(arr);
|
||||
|
||||
var obj = {
|
||||
SF: { total_population: 1000 },
|
||||
LA: { total_population: 2000 },
|
||||
NY: { total_population: 3000 }
|
||||
};
|
||||
console.table(obj);
|
||||
|
||||
console.table([
|
||||
{ a: 1, b: 2, c: 3 },
|
||||
{ a: 1, b: 2, c: 3, d: 4 },
|
||||
{ k: 11, f: 22 },
|
||||
{ a: 1, b: 2, c: 3 }
|
||||
]);
|
||||
|
||||
var obj = {
|
||||
SF: { f: 300, m: 100 },
|
||||
LA: { f: 200, m: 200 },
|
||||
NY: { f: 400, m: 500 }
|
||||
};
|
||||
console.table(obj);
|
||||
|
||||
|
||||
var arr = [
|
||||
['a', 'b', 'c', 'd'],
|
||||
['e', 'f', 'hoooohoooohooooo', 'j']
|
||||
];
|
||||
console.table(arr);
|
||||
console.table(null);
|
||||
console.table([null]);
|
||||
|
||||
console.assert(true);
|
||||
console.assert(false);
|
||||
Loading…
Reference in a new issue