json-table
Advanced tools
Comparing version 0.0.2 to 0.1.0
@@ -7,3 +7,8 @@ var fs = require('fs'); | ||
function JsonTb(item, config) { | ||
function JsonTb(item, config, cb) { | ||
if(arguments.length == 2) { | ||
cb = config; | ||
config = null; | ||
} | ||
var that = this; | ||
@@ -20,4 +25,7 @@ config = config || {}; | ||
this.mkbody(item, function(err, result) { | ||
if(err) throw new Error(err); | ||
that.whole(config, function(err_whole, table) { | ||
that.show(table); | ||
if(err) throw new Error(err_whole); | ||
that.table = table; | ||
cb(that) | ||
}) | ||
@@ -30,4 +38,7 @@ }); | ||
this.mkbody(parse, function(err, result) { | ||
if(err) throw new Error(err); | ||
that.whole(config, function(err_whole, table) { | ||
that.show(table); | ||
if(err) throw new Error(err_whole); | ||
that.table = table | ||
cb(that) | ||
}) | ||
@@ -104,4 +115,5 @@ }); | ||
JsonTb.prototype.show = function(table) { | ||
JsonTb.prototype.show = function() { | ||
var table = this.table; | ||
console.log(table.toString()); | ||
} |
{ | ||
"name": "json-table", | ||
"version": "0.0.2", | ||
"version": "0.1.0", | ||
"description": "Json table is an easy way to preview your json data in table", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "./node_modules/.bin/mocha" | ||
}, | ||
"keywords": [ | ||
"table", | ||
"json" | ||
], | ||
"repository": { | ||
@@ -22,3 +26,7 @@ "type": "git", | ||
"async": "~0.2.10" | ||
}, | ||
"devDependencies": { | ||
"should": "~3.1.2", | ||
"mocha": "~1.17.1" | ||
} | ||
} |
# json table | ||
[![Build Status](https://travis-ci.org/DataGarage/node-json-table.png?branch=master)](https://travis-ci.org/DataGarage/node-json-table) | ||
Json table is an easy way to preview your json data in table | ||
@@ -23,3 +25,3 @@ | ||
``` | ||
```javascript | ||
var json_tb_out = new json_tb('sample.json', { | ||
@@ -30,14 +32,18 @@ chars: { 'top': '═' , 'top-mid': '╤' , 'top-left': '╔' , 'top-right': '╗' | ||
, 'right': '║' , 'right-mid': '╢' , 'middle': '│' } | ||
}, function(table) { | ||
table.show() // **have to call show() function to print out the table** | ||
}) | ||
``` | ||
or | ||
```javascript | ||
var json_tb_out = new json_tb(<JSON object>, config, callback); | ||
``` | ||
var json_tb_out = new json_tb(<JSON object>); | ||
``` | ||
- Arguments: | ||
* json file, or json object (json): the first argument can be a json file or a json object | ||
* configure of the table (object): see detail in https://github.com/LearnBoost/cli-table | ||
* **json file, or json object (json)** : the first argument can be a json file or a json object | ||
* **configure of the table (object)** : `optional` see detail in https://github.com/LearnBoost/cli-table | ||
* **callback (function)** : callback function | ||
## Example | ||
@@ -47,3 +53,3 @@ | ||
``` | ||
```json | ||
[{ | ||
@@ -50,0 +56,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
38619
10
381
2
91
2