Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

json5

Package Overview
Dependencies
Maintainers
2
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json5 - npm Package Compare versions

Comparing version 0.5.1 to 1.0.0-dates

dist/index.js

49

CHANGELOG.md
### v0.5.1 [[code][c0.5.1], [diff][d0.5.1]]
[c0.5.1]: https://github.com/aseemk/json5/tree/v0.5.1
[d0.5.1]: https://github.com/aseemk/json5/compare/v0.5.0...v0.5.1
[c0.5.1]: https://github.com/json5/json5/tree/v0.5.1
[d0.5.1]: https://github.com/json5/json5/compare/v0.5.0...v0.5.1

@@ -14,4 +14,4 @@ This release includes a minor fix for indentations when stringifying empty

[c0.5.0]: https://github.com/aseemk/json5/tree/v0.5.0
[d0.5.0]: https://github.com/aseemk/json5/compare/v0.4.0...v0.5.0
[c0.5.0]: https://github.com/json5/json5/tree/v0.5.0
[d0.5.0]: https://github.com/json5/json5/compare/v0.4.0...v0.5.0

@@ -32,4 +32,4 @@ This release includes major internal changes and public API enhancements.

[c0.4.0]: https://github.com/aseemk/json5/tree/v0.4.0
[d0.4.0]: https://github.com/aseemk/json5/compare/v0.2.0...v0.4.0
[c0.4.0]: https://github.com/json5/json5/tree/v0.4.0
[d0.4.0]: https://github.com/json5/json5/compare/v0.2.0...v0.4.0

@@ -66,4 +66,4 @@ Note that v0.3.0 was tagged, but never published to npm, so this v0.4.0

[c0.2.0]: https://github.com/aseemk/json5/tree/v0.2.0
[d0.2.0]: https://github.com/aseemk/json5/compare/v0.1.0...v0.2.0
[c0.2.0]: https://github.com/json5/json5/tree/v0.2.0
[d0.2.0]: https://github.com/json5/json5/compare/v0.1.0...v0.2.0

@@ -96,4 +96,4 @@ This release fixes some bugs and adds some more utility features to help you

[c0.1.0]: https://github.com/aseemk/json5/tree/v0.1.0
[d0.1.0]: https://github.com/aseemk/json5/compare/v0.0.1...v0.1.0
[c0.1.0]: https://github.com/json5/json5/tree/v0.1.0
[d0.1.0]: https://github.com/json5/json5/compare/v0.0.1...v0.1.0

@@ -129,4 +129,4 @@ This release tightens JSON5 support and adds helpful utility features:

[c0.0.1]: https://github.com/aseemk/json5/tree/v0.0.1
[d0.0.1]: https://github.com/aseemk/json5/compare/v0.0.0...v0.0.1
[c0.0.1]: https://github.com/json5/json5/tree/v0.0.1
[d0.0.1]: https://github.com/json5/json5/compare/v0.0.0...v0.0.1

@@ -147,3 +147,3 @@ This was the first implementation of this JSON5 parser.

### v0.0.0 [[code](https://github.com/aseemk/json5/tree/v0.0.0)]
### v0.0.0 [[code](https://github.com/json5/json5/tree/v0.0.0)]

@@ -165,12 +165,13 @@ Let's consider this to be Douglas Crockford's original [json_parse.js] — a

[#16]: https://github.com/aseemk/json5/issues/16
[#24]: https://github.com/aseemk/json5/issues/24
[#30]: https://github.com/aseemk/json5/issues/30
[#32]: https://github.com/aseemk/json5/issues/32
[#36]: https://github.com/aseemk/json5/issues/36
[#57]: https://github.com/aseemk/json5/issues/57
[#58]: https://github.com/aseemk/json5/pull/58
[#60]: https://github.com/aseemk/json5/pull/60
[#63]: https://github.com/aseemk/json5/pull/63
[#97]: https://github.com/aseemk/json5/pull/97
[#101]: https://github.com/aseemk/json5/pull/101
[#16]: https://github.com/json5/json5/issues/16
[#24]: https://github.com/json5/json5/issues/24
[#30]: https://github.com/json5/json5/issues/30
[#32]: https://github.com/json5/json5/issues/32
[#36]: https://github.com/json5/json5/issues/36
[#57]: https://github.com/json5/json5/issues/57
[#58]: https://github.com/json5/json5/pull/58
[#60]: https://github.com/json5/json5/pull/60
[#63]: https://github.com/json5/json5/pull/63
[#97]: https://github.com/json5/json5/pull/97
[#101]: https://github.com/json5/json5/pull/101
[#134]: https://github.com/json5/json5/pull/134
#!/usr/bin/env node
// cli.js
// JSON5 command-line interface.
//
// This is pretty minimal for now; just supports compiling files via `-c`.
// TODO More useful functionality, like output path, watch, etc.?
var FS = require('fs');
var JSON5 = require('./json5');
var Path = require('path');
var USAGE = [
'Usage: json5 -c path/to/file.json5 ...',
'Compiles JSON5 files into sibling JSON files with the same basenames.',
].join('\n');
// if valid, args look like [node, json5, -c, file1, file2, ...]
var args = process.argv;
if (args.length < 4 || args[2] !== '-c') {
console.error(USAGE);
process.exit(1);
}
var cwd = process.cwd();
var files = args.slice(3);
// iterate over each file and convert JSON5 files to JSON:
files.forEach(function (file) {
var path = Path.resolve(cwd, file);
var basename = Path.basename(path, '.json5');
var dirname = Path.dirname(path);
var json5 = FS.readFileSync(path, 'utf8');
var obj = JSON5.parse(json5);
var json = JSON.stringify(obj, null, 4); // 4 spaces; TODO configurable?
path = Path.join(dirname, basename + '.json');
FS.writeFileSync(path, json, 'utf8');
});
'use strict';var _fs=require('fs');var _fs2=_interopRequireDefault(_fs);var _path=require('path');var _path2=_interopRequireDefault(_path);var _minimist=require('minimist');var _minimist2=_interopRequireDefault(_minimist);var _package=require('../package.json');var _package2=_interopRequireDefault(_package);var _=require('./');var _2=_interopRequireDefault(_);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}var argv=(0,_minimist2.default)(process.argv.slice(2),{alias:{'convert':'c','space':'s','validate':'v','out-file':'o','version':'V','help':'h'},boolean:['convert','validate','version','help'],string:['space','out-file']});if(argv.version){version()}else if(argv.help){usage()}else{var inFilename=argv._[0];var readStream=void 0;if(inFilename){readStream=_fs2.default.createReadStream(inFilename)}else{readStream=process.stdin}var json5='';readStream.on('data',function(data){json5+=data});readStream.on('end',function(){var space=void 0;if(argv.space==='t'||argv.space==='tab'){space='\t'}else{space=Number(argv.space)}var value=void 0;try{value=_2.default.parse(json5);if(!argv.validate){var json=JSON.stringify(value,null,space);var writeStream=void 0;if(argv.convert&&inFilename&&!argv.o){var parsedFilename=_path2.default.parse(inFilename);var outFilename=_path2.default.format(Object.assign(parsedFilename,{base:_path2.default.basename(parsedFilename.base,parsedFilename.ext)+'.json'}));writeStream=_fs2.default.createWriteStream(outFilename)}else if(argv.o){writeStream=_fs2.default.createWriteStream(argv.o)}else{writeStream=process.stdout}writeStream.write(json)}}catch(err){console.error(err.message);process.exit(1)}})}function version(){console.log(_package2.default.version)}function usage(){console.log('\n Usage: json5 [options] <file>\n\n\n Options:\n\n -s, --space The number of spaces to indent or \'t\' for tabs\n -o, --out-file [file] Outputs to the specified file\n -v, --validate Validate JSON5 but do not output JSON\n -V, --version Output the version number\n -h, --help Output usage information')}

@@ -1,18 +0,1 @@

// require.js
// Node.js only: adds a require() hook for .json5 files, just like the native
// hook for .json files.
//
// Usage:
// require('json5/require');
// require('./foo'); // will check foo.json5 after foo.js, foo.json, etc.
// require('./bar.json5');
var FS = require('fs');
var JSON5 = require('./json5');
// Modeled off of (v0.6.18 link; check latest too):
// https://github.com/joyent/node/blob/v0.6.18/lib/module.js#L468-L472
require.extensions['.json5'] = function (module, filename) {
var content = FS.readFileSync(filename, 'utf8');
module.exports = JSON5.parse(content);
};
'use strict';require('./register');
MIT License
Copyright (c) 2012-2016 Aseem Kishore, and [others](https://github.com/aseemk/json5/contributors).
Copyright (c) 2012-2017 Aseem Kishore, and [others].

@@ -22,1 +22,3 @@ Permission is hereby granted, free of charge, to any person obtaining a copy

SOFTWARE.
[others]: https://github.com/json5/json5/contributors
{
"name": "json5",
"version": "0.5.1",
"description": "JSON for the ES5 era.",
"keywords": [
"json",
"es5"
],
"author": "Aseem Kishore <aseem.kishore@gmail.com>",
"contributors": [
"Max Nanasy <max.nanasy@gmail.com>",
"Andrew Eisenberg <andrew@eisenberg.as>",
"Jordan Tucker <jordanbtucker@gmail.com>"
],
"main": "lib/json5.js",
"bin": "lib/cli.js",
"files": [
"lib/"
],
"dependencies": {},
"devDependencies": {
"gulp": "^3.9.1",
"gulp-jshint": "^2.0.1",
"jshint": "^2.9.3",
"jshint-stylish": "^2.2.1",
"mocha": "^3.1.0"
},
"scripts": {
"build": "node ./lib/cli.js -c package.json5",
"test": "mocha --ui exports --reporter spec"
},
"homepage": "http://json5.org/",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/aseemk/json5.git"
}
}
"name": "json5",
"version": "1.0.0-dates",
"description": "JSON for humans.",
"main": "lib/index.js",
"bin": "lib/cli.js",
"browser": "dist/index.js",
"files": [
"lib/",
"dist/"
],
"scripts": {
"build": "babel-node build/build.js && babel src -d lib && rollup -c",
"lint": "eslint --fix build src",
"prepublishOnly": "npm run lint && npm test && npm run production",
"pretest": "cross-env NODE_ENV=test npm run build",
"preversion": "npm run lint && npm test && npm run production",
"production": "cross-env NODE_ENV=production npm run build && babel-node build/check-package.js",
"test": "nyc --reporter=html --reporter=text mocha"
},
"repository": {
"type": "git",
"url": "git+https://github.com/json5/json5.git"
},
"keywords": [
"json",
"json5",
"es5",
"es2015",
"ecmascript"
],
"author": "Aseem Kishore <aseem.kishore@gmail.com>",
"contributors": [
"Max Nanasy <max.nanasy@gmail.com>",
"Andrew Eisenberg <andrew@eisenberg.as>",
"Jordan Tucker <jordanbtucker@gmail.com>"
],
"license": "MIT",
"bugs": {
"url": "https://github.com/json5/json5/issues"
},
"homepage": "http://json5.org/",
"dependencies": {
"minimist": "^1.2.0"
},
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-core": "^6.26.0",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-plugin-external-helpers": "^6.22.0",
"babel-plugin-istanbul": "^4.1.5",
"babel-preset-env": "^1.6.0",
"babel-register": "^6.26.0",
"babelrc-rollup": "^3.0.0",
"cross-env": "^5.0.5",
"del": "^3.0.0",
"eslint": "^4.7.1",
"eslint-config-standard": "^10.2.1",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-node": "^5.1.1",
"eslint-plugin-promise": "^3.5.0",
"eslint-plugin-standard": "^3.0.1",
"mocha": "^3.5.3",
"nyc": "^11.2.1",
"regenerate": "^1.3.3",
"rollup": "^0.50.0",
"rollup-plugin-babel": "^3.0.2",
"rollup-plugin-commonjs": "^8.2.1",
"rollup-plugin-node-resolve": "^3.0.0",
"rollup-plugin-uglify": "^2.0.1",
"sinon": "^3.3.0",
"unicode-9.0.0": "^0.7.4"
}
}

@@ -1,2 +0,2 @@

# JSON5 – Modern JSON
# JSON5 – JSON for Humans

@@ -125,13 +125,37 @@ [![Build Status](https://travis-ci.org/json5/json5.svg)](https://travis-ci.org/json5/json5)

// This file is written in JSON5 syntax, naturally, but npm needs a regular
// JSON file, so compile via `npm run build`. Be sure to keep both in sync!
// JSON file, so be sure to keep package.json and package.json5 in sync!
{
name: 'json5',
version: '0.5.0',
description: 'JSON for the ES5 era.',
keywords: ['json', 'es5'],
version: '0.5.1',
description: 'JSON for humans.',
main: 'lib/index.js',
bin: 'lib/cli.js',
browser: 'dist/index.js',
files: [
'lib/',
'dist/',
],
scripts: {
build: 'babel-node build/build.js && babel src -d lib && rollup -c',
lint: 'eslint --fix build src',
prepublishOnly: 'npm run lint && npm test && npm run production',
pretest: 'cross-env NODE_ENV=test npm run build',
preversion: 'npm run lint && npm test && npm run production',
production: 'cross-env NODE_ENV=production npm run build && babel-node build/check-package.js',
test: 'nyc --reporter=html --reporter=text mocha',
},
repository: {
type: 'git',
url: 'git+https://github.com/json5/json5.git',
},
keywords: [
'json',
'json5',
'es5',
'es2015',
'ecmascript',
],
author: 'Aseem Kishore <aseem.kishore@gmail.com>',
contributors: [
// TODO: Should we remove this section in favor of GitHub's list?
// https://github.com/aseemk/json5/contributors
'Max Nanasy <max.nanasy@gmail.com>',

@@ -141,24 +165,38 @@ 'Andrew Eisenberg <andrew@eisenberg.as>',

],
main: 'lib/json5.js',
bin: 'lib/cli.js',
files: ["lib/"],
dependencies: {},
devDependencies: {
gulp: "^3.9.1",
'gulp-jshint': "^2.0.0",
jshint: "^2.9.1",
'jshint-stylish': "^2.1.0",
mocha: "^2.4.5"
license: 'MIT',
bugs: {
url: 'https://github.com/json5/json5/issues',
},
scripts: {
build: 'node ./lib/cli.js -c package.json5',
test: 'mocha --ui exports --reporter spec',
// TODO: Would it be better to define these in a mocha.opts file?
},
homepage: 'http://json5.org/',
license: 'MIT',
repository: {
type: 'git',
url: 'https://github.com/aseemk/json5.git',
dependencies: {
minimist: '^1.2.0',
},
devDependencies: {
'babel-cli': '^6.26.0',
'babel-core': '^6.26.0',
'babel-plugin-add-module-exports': '^0.2.1',
'babel-plugin-external-helpers': '^6.22.0',
'babel-plugin-istanbul': '^4.1.5',
'babel-preset-env': '^1.6.0',
'babel-register': '^6.26.0',
'babelrc-rollup': '^3.0.0',
'cross-env': '^5.0.5',
'del': '^3.0.0',
'eslint': '^4.7.1',
'eslint-config-standard': '^10.2.1',
'eslint-plugin-import': '^2.7.0',
'eslint-plugin-node': '^5.1.1',
'eslint-plugin-promise': '^3.5.0',
'eslint-plugin-standard': '^3.0.1',
'mocha': '^3.5.3',
'nyc': '^11.2.1',
'regenerate': '^1.3.3',
'rollup': '^0.50.0',
'rollup-plugin-babel': '^3.0.2',
'rollup-plugin-commonjs': '^8.2.1',
'rollup-plugin-node-resolve': '^3.0.0',
'rollup-plugin-uglify': '^2.0.1',
'sinon': '^3.3.0',
'unicode-9.0.0': '^0.7.4',
},
}

@@ -174,6 +212,6 @@ ```

The [GitHub wiki](https://github.com/aseemk/json5/wiki) is a good place to track
The [GitHub wiki](https://github.com/json5/json5/wiki) is a good place to track
JSON5 support and usage. Contribute freely there!
[GitHub Issues](https://github.com/aseemk/json5/issues) is the place to
[GitHub Issues](https://github.com/json5/json5/issues) is the place to
formally propose feature requests and report bugs. Questions and general

@@ -246,3 +284,3 @@ feedback are better directed at the Google Group.

```sh
git clone git://github.com/aseemk/json5.git
git clone https://github.com/json5/json5
cd json5

@@ -256,4 +294,4 @@ npm install

Feel free to [file issues](https://github.com/aseemk/json5/issues) and submit
[pull requests](https://github.com/aseemk/json5/pulls) — contributions are
Feel free to [file issues](https://github.com/json5/json5/issues) and submit
[pull requests](https://github.com/json5/json5/pulls) — contributions are
welcome. If you do submit a pull request, please be sure to add or update the

@@ -260,0 +298,0 @@ tests, and ensure that `npm test` continues to pass.

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc