Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"presets": ["es2015", "stage-2"],
"env": {
"production": {
"presets": ["babili"]
}
}
}
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist/
8 changes: 8 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
"extends": "airbnb",
"installedESLint": true,
"env": {
"node": false,
"browser": true,
}
};
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
node_modules
etc
test/*.json
test/*.rjson

coverage/
.nyc_output
51 changes: 26 additions & 25 deletions bin/rjson
Original file line number Diff line number Diff line change
@@ -1,46 +1,47 @@
#!/usr/bin/env node
/* eslint-env node */
const program = require('commander');
const assert = require('assert');
const RJSON = require('../dist');

var program = require('commander'), assert = require('assert'), RJSON = require('../rjson.js');

var data = [];
const data = [];

program
.option('-u, --unpack', 'Unpack RJSON data (default is pack).')
.option('-t, --test', 'Check that restored data is equal to original data.')
.option('-e, --encoding', 'Encoding [utf8]', 'utf8')
.option('-v, --verbose', 'Output debug info to stderr.')
.option('-d, --dry_run', 'Don\'t output packed/unpacked data.')
.on('--help', function() {
console.log(' Read JSON/RJSON from stdin and output RJSON/JSON to stdout.');
.on('--help', () => {
console.log(' Read JSON/RJSON from stdin and output RJSON/JSON to stdout.');
})
.parse(process.argv);

process.stdin.resume();

process.stdin.on('data', function(chunk) {
data.push(chunk);
process.stdin.on('data', (chunk) => {
data.push(chunk);
});

process.stdin.on('end', function () {
if (!data.length) return;
var start = +new Date(),
input = new Buffer.concat(data).toString(program.encoding),
parsed = JSON.parse(input),
rjsonTime = +new Date(),
res = RJSON[program.unpack ? 'unpack' : 'pack'](parsed),
rjsonTime = +new Date() - rjsonTime,
output = JSON.stringify(res);
if (!program.dry_run) process.stdout.write(output);
if (program.verbose) {
console.error('In: %d, Out: %d, In/Out=%d%, Time: %dms (RJSON: %dms).',
process.stdin.on('end', () => {
if (!data.length) return;
const start = +new Date();
const input = new Buffer.concat(data).toString(program.encoding);
const parsed = JSON.parse(input);
let rjsonTime = +new Date();
const res = RJSON[program.unpack ? 'unpack' : 'pack'](parsed);
rjsonTime = +new Date() - rjsonTime;
const output = JSON.stringify(res);
if (!program.dry_run) process.stdout.write(output);
if (program.verbose) {
console.error('In: %d, Out: %d, In/Out=%d%, Time: %dms (RJSON: %dms).',
input.length, output.length,
Math.round(100 * input.length / (output.length || 1)),
Math.round(100 * (input.length / (output.length || 1))),
(+new Date() - start), rjsonTime);
}
if (program.test) {
assert.deepEqual(parsed,
}
if (program.test) {
assert.deepEqual(parsed,
RJSON[program.unpack ? 'pack' : 'unpack'](
JSON.parse(output)));
}
}
});

1 change: 1 addition & 0 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 20 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "rjson",
"version": "0.2.4",
"version": "0.2.5",
"description": "RJSON (Recursive JSON) converts any JSON data collection into more compact recursive form.",
"main": "rjson.js",
"main": "dist/rjson.js",
"bin": {
"rjson": "./bin/rjson"
},
Expand All @@ -13,10 +13,26 @@
"commander": "~1.1.1"
},
"devDependencies": {
"qunit": "~0.5.12"
"babel-cli": "^6.22.2",
"babel-eslint": "^7.1.1",
"babel-plugin-istanbul": "^3.1.2",
"babel-polyfill": "^6.22.0",
"babel-preset-babili": "^0.0.10",
"babel-preset-es2015": "^6.22.0",
"babel-register": "^6.22.0",
"chai": "^3.5.0",
"eslint": "^3.14.1",
"eslint-config-airbnb": "^14.0.0",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-jsx-a11y": "^3.0.2",
"eslint-plugin-react": "^6.9.0",
"mocha": "^3.2.0",
"nyc": "^10.1.2"
},
"scripts": {
"test": "qunit -c ./ -t ./test/tests.js"
"build": "NODE_ENV=production babel src -d dist",
"report": "NODE_ENV=test nyc --require babel-register --require babel-polyfill nyc --reporter=lcov mocha test/*.test.js",
"test2": "mocha --compilers js:babel-core/register --require babel-polyfill test/*.test.js"
},
"repository": {
"type": "git",
Expand Down
255 changes: 0 additions & 255 deletions rjson.js

This file was deleted.

Loading