nav tabs on admin dashboard
This commit is contained in:
194
node_modules/json5/CHANGELOG.md
generated
vendored
194
node_modules/json5/CHANGELOG.md
generated
vendored
@@ -1,7 +1,138 @@
|
||||
### v2.1.0 [[code][c2.1.0], [diff][d2.1.0]]
|
||||
|
||||
[c2.1.0]: https://github.com/json5/json5/tree/v2.1.0
|
||||
[d2.1.0]: https://github.com/json5/json5/compare/v2.0.1...v2.1.0
|
||||
|
||||
- New: The `index.mjs` and `index.min.mjs` browser builds in the `dist`
|
||||
directory support ES6 modules. ([#187])
|
||||
|
||||
### v2.0.1 [[code][c2.0.1], [diff][d2.0.1]]
|
||||
|
||||
[c2.0.1]: https://github.com/json5/json5/tree/v2.0.1
|
||||
[d2.0.1]: https://github.com/json5/json5/compare/v2.0.0...v2.0.1
|
||||
|
||||
- Fix: The browser builds in the `dist` directory support ES5. ([#182])
|
||||
|
||||
### v2.0.0 [[code][c2.0.0], [diff][d2.0.0]]
|
||||
|
||||
[c2.0.0]: https://github.com/json5/json5/tree/v2.0.0
|
||||
[d2.0.0]: https://github.com/json5/json5/compare/v1.0.1...v2.0.0
|
||||
|
||||
- **Major**: JSON5 officially supports Node.js v6 and later. Support for Node.js
|
||||
v4 has been dropped. Since Node.js v6 supports ES5 features, the code has been
|
||||
rewritten in native ES5, and the dependence on Babel has been eliminated.
|
||||
|
||||
- New: Support for Unicode 10 has been added.
|
||||
|
||||
- New: The test framework has been migrated from Mocha to Tap.
|
||||
|
||||
- New: The browser build at `dist/index.js` is no longer minified by default. A
|
||||
minified version is available at `dist/index.min.js`. ([#181])
|
||||
|
||||
- Fix: The warning has been made clearer when line and paragraph separators are
|
||||
used in strings.
|
||||
|
||||
- Fix: `package.json5` has been restored, and it is automatically generated and
|
||||
committed when the version is bumped. A new `build-package` NPM script has
|
||||
been added to facilitate this.
|
||||
|
||||
### v1.0.1 [[code][c1.0.1], [diff][d1.0.1]]
|
||||
|
||||
[c1.0.1]: https://github.com/json5/json5/tree/v1.0.1
|
||||
[d1.0.1]: https://github.com/json5/json5/compare/v1.0.0...v1.0.1
|
||||
|
||||
This release includes a bug fix and minor change.
|
||||
|
||||
- Fix: `parse` throws on unclosed objects and arrays.
|
||||
|
||||
- New: `package.json5` has been removed until an easier way to keep it in sync
|
||||
with `package.json` is found.
|
||||
|
||||
|
||||
### v1.0.0 [[code][c1.0.0], [diff][d1.0.0]]
|
||||
|
||||
[c1.0.0]: https://github.com/json5/json5/tree/v1.0.0
|
||||
[d1.0.0]: https://github.com/json5/json5/compare/v0.5.1...v1.0.0
|
||||
|
||||
This release includes major internal changes and public API enhancements.
|
||||
|
||||
- **Major**: JSON5 officially supports Node.js v4 and later. Support for Node.js
|
||||
v0.10 and v0.12 have been dropped.
|
||||
|
||||
- New: Unicode property names and Unicode escapes in property names are
|
||||
supported. ([#1])
|
||||
|
||||
- New: `stringify` outputs trailing commas in objects and arrays when a `space`
|
||||
option is provided. ([#66])
|
||||
|
||||
- New: JSON5 allows line and paragraph separator characters (U+2028 and U+2029)
|
||||
in strings in order to be compatible with JSON. However, ES5 does not allow
|
||||
these characters in strings, so JSON5 gives a warning when they are parsed and
|
||||
escapes them when they are stringified. ([#70])
|
||||
|
||||
- New: `stringify` accepts an options object as its second argument. The
|
||||
supported options are `replacer`, `space`, and a new `quote` option that
|
||||
specifies the quote character used in strings. ([#71])
|
||||
|
||||
- New: The CLI supports STDIN and STDOUT and adds `--out-file`, `--space`, and
|
||||
`--validate` options. See `json5 --help` for more information. ([#72], [#84],
|
||||
and [#108])
|
||||
|
||||
- New: In addition to the white space characters space `\t`, `\v`, `\f`, `\n`,
|
||||
`\r`, and `\xA0`, the additional white space characters `\u2028`, `\u2029`,
|
||||
and all other characters in the Space Separator Unicode category are allowed.
|
||||
|
||||
- New: In addition to the character escapes `\'`, `\"`, `\\`, `\b`, `\f`, `\n`,
|
||||
`\r`, and `\t`, the additional character escapes `\v` and `\0`, hexadecimal
|
||||
escapes like `\x0F`, and unnecessary escapes like `\a` are allowed in string
|
||||
values and string property names.
|
||||
|
||||
- New: `stringify` outputs strings with single quotes by default but
|
||||
intelligently uses double quotes if there are more single quotes than double
|
||||
quotes inside the string. (i.e. `stringify('Stay here.')` outputs
|
||||
`'Stay here.'` while `stringify('Let\'s go.')` outputs `"Let's go."`)
|
||||
|
||||
- New: When a character is not allowed in a string, `stringify` outputs a
|
||||
character escape like `\t` when available, a hexadecimal escape like `\x0F`
|
||||
when the Unicode code point is less than 256, or a Unicode character escape
|
||||
like `\u01FF`, in that order.
|
||||
|
||||
- New: `stringify` checks for a `toJSON5` method on objects and, if it exists,
|
||||
stringifies its return value instead of the object. `toJSON5` overrides
|
||||
`toJSON` if they both exist.
|
||||
|
||||
- New: To `require` or `import` JSON5 files, use `require('json5/lib/register')`
|
||||
or `import 'json5/lib/register'`. Previous versions used `json5/lib/require`,
|
||||
which still exists for backward compatibility but is deprecated and will give
|
||||
a warning.
|
||||
|
||||
- New: To use JSON5 in browsers, use the file at `dist/index.js` or
|
||||
`https://unpkg.com/json5@^1.0.0`.
|
||||
|
||||
- Fix: `stringify` properly outputs `Infinity` and `NaN`. ([#67])
|
||||
|
||||
- Fix: `isWord` no longer becomes a property of `JSON5` after calling
|
||||
`stringify`. ([#68] and [#89])
|
||||
|
||||
- Fix: `stringify` no longer throws when an object does not have a `prototype`.
|
||||
([#154])
|
||||
|
||||
- Fix: `stringify` properly handles the `key` argument of `toJSON(key)` methods.
|
||||
`toJSON5(key)` follows this pattern.
|
||||
|
||||
- Fix: `stringify` accepts `Number` and `String` objects as its `space`
|
||||
argument.
|
||||
|
||||
- Fix: In addition to a function, `stringify` also accepts an array of keys to
|
||||
include in the output as its `replacer` argument. Numbers, `Number` objects,
|
||||
and `String` objects will be converted to a string if they are given as array
|
||||
values.
|
||||
|
||||
|
||||
### 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
|
||||
|
||||
This release includes a minor fix for indentations when stringifying empty
|
||||
arrays.
|
||||
@@ -11,8 +142,8 @@ arrays.
|
||||
|
||||
### v0.5.0 [[code][c0.5.0], [diff][d0.5.0]]
|
||||
|
||||
[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
|
||||
|
||||
This release includes major internal changes and public API enhancements.
|
||||
|
||||
@@ -28,8 +159,8 @@ This release includes major internal changes and public API enhancements.
|
||||
|
||||
### v0.4.0 [[code][c0.4.0], [diff][d0.4.0]]
|
||||
|
||||
[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
|
||||
|
||||
Note that v0.3.0 was tagged, but never published to npm, so this v0.4.0
|
||||
changelog entry includes v0.3.0 features.
|
||||
@@ -61,8 +192,8 @@ This is a massive release that adds `stringify` support, among other things.
|
||||
|
||||
### v0.2.0 [[code][c0.2.0], [diff][d0.2.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
|
||||
|
||||
This release fixes some bugs and adds some more utility features to help you
|
||||
express data more easily:
|
||||
@@ -90,8 +221,8 @@ express data more easily:
|
||||
|
||||
### v0.1.0 [[code][c0.1.0], [diff][d0.1.0]]
|
||||
|
||||
[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
|
||||
|
||||
This release tightens JSON5 support and adds helpful utility features:
|
||||
|
||||
@@ -122,8 +253,8 @@ This release tightens JSON5 support and adds helpful utility features:
|
||||
|
||||
### v0.0.1 [[code][c0.0.1], [diff][d0.0.1]]
|
||||
|
||||
[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
|
||||
|
||||
This was the first implementation of this JSON5 parser.
|
||||
|
||||
@@ -139,7 +270,7 @@ This was the first implementation of this JSON5 parser.
|
||||
- Support comments, both inline and block.
|
||||
|
||||
|
||||
### 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)]
|
||||
|
||||
Let's consider this to be Douglas Crockford's original [json_parse.js] — a
|
||||
parser for the regular JSON format.
|
||||
@@ -156,14 +287,29 @@ parser for the regular JSON format.
|
||||
[@jordanbtucker]: https://github.com/jordanbtucker
|
||||
[@amb26]: https://github.com/amb26
|
||||
|
||||
[#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
|
||||
[#1]: https://github.com/json5/json5/issues/1
|
||||
[#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
|
||||
[#66]: https://github.com/json5/json5/issues/66
|
||||
[#67]: https://github.com/json5/json5/issues/67
|
||||
[#68]: https://github.com/json5/json5/issues/68
|
||||
[#70]: https://github.com/json5/json5/issues/70
|
||||
[#71]: https://github.com/json5/json5/issues/71
|
||||
[#72]: https://github.com/json5/json5/issues/72
|
||||
[#84]: https://github.com/json5/json5/pull/84
|
||||
[#89]: https://github.com/json5/json5/pull/89
|
||||
[#97]: https://github.com/json5/json5/pull/97
|
||||
[#101]: https://github.com/json5/json5/pull/101
|
||||
[#108]: https://github.com/json5/json5/pull/108
|
||||
[#134]: https://github.com/json5/json5/pull/134
|
||||
[#154]: https://github.com/json5/json5/issues/154
|
||||
[#181]: https://github.com/json5/json5/issues/181
|
||||
[#182]: https://github.com/json5/json5/issues/182
|
||||
[#187]: https://github.com/json5/json5/issues/187
|
||||
|
||||
4
node_modules/json5/LICENSE.md
generated
vendored
4
node_modules/json5/LICENSE.md
generated
vendored
@@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2012-2016 Aseem Kishore, and [others](https://github.com/aseemk/json5/contributors).
|
||||
Copyright (c) 2012-2018 Aseem Kishore, and [others].
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -19,3 +19,5 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
[others]: https://github.com/json5/json5/contributors
|
||||
|
||||
374
node_modules/json5/README.md
generated
vendored
374
node_modules/json5/README.md
generated
vendored
@@ -1,286 +1,234 @@
|
||||
# JSON5 – Modern JSON
|
||||
# JSON5 – JSON for Humans
|
||||
|
||||
[](https://travis-ci.org/json5/json5)
|
||||
[][Build Status]
|
||||
[][Coverage
|
||||
Status]
|
||||
|
||||
JSON is an excellent data format, but we think it can be better.
|
||||
The JSON5 Data Interchange Format (JSON5) is a superset of [JSON] that aims to
|
||||
alleviate some of the limitations of JSON by expanding its syntax to include
|
||||
some productions from [ECMAScript 5.1].
|
||||
|
||||
**JSON5 is a proposed extension to JSON** that aims to make it easier for
|
||||
*humans to write and maintain* by hand. It does this by adding some minimal
|
||||
syntax features directly from ECMAScript 5.
|
||||
This JavaScript library is the official reference implementation for JSON5
|
||||
parsing and serialization libraries.
|
||||
|
||||
JSON5 remains a **strict subset of JavaScript**, adds **no new data types**,
|
||||
and **works with all existing JSON content**.
|
||||
[Build Status]: https://travis-ci.org/json5/json5
|
||||
|
||||
JSON5 is *not* an official successor to JSON, and JSON5 content may *not*
|
||||
work with existing JSON parsers. For this reason, JSON5 files use a new .json5
|
||||
extension. *(TODO: new MIME type needed too.)*
|
||||
[Coverage Status]: https://coveralls.io/github/json5/json5
|
||||
|
||||
The code here is a **reference JavaScript implementation** for both Node.js
|
||||
and all browsers. It’s based directly off of Douglas Crockford’s own [JSON
|
||||
implementation][json_parse.js], and it’s both robust and secure.
|
||||
[JSON]: https://tools.ietf.org/html/rfc7159
|
||||
|
||||
[ECMAScript 5.1]: https://www.ecma-international.org/ecma-262/5.1/
|
||||
|
||||
## Why
|
||||
|
||||
JSON isn’t the friendliest to *write*. Keys need to be quoted, objects and
|
||||
arrays can’t have trailing commas, and comments aren’t allowed — even though
|
||||
none of these are the case with regular JavaScript today.
|
||||
|
||||
That was fine when JSON’s goal was to be a great data format, but JSON’s usage
|
||||
has expanded beyond *machines*. JSON is now used for writing [configs][ex1],
|
||||
[manifests][ex2], even [tests][ex3] — all by *humans*.
|
||||
|
||||
[ex1]: http://plovr.com/docs.html
|
||||
[ex2]: https://www.npmjs.org/doc/files/package.json.html
|
||||
[ex3]: http://code.google.com/p/fuzztester/wiki/JSONFileFormat
|
||||
|
||||
There are other formats that are human-friendlier, like YAML, but changing
|
||||
from JSON to a completely different format is undesirable in many cases.
|
||||
JSON5’s aim is to remain close to JSON and JavaScript.
|
||||
|
||||
|
||||
## Features
|
||||
|
||||
The following is the exact list of additions to JSON’s syntax introduced by
|
||||
JSON5. **All of these are optional**, and **all of these come from ES5**.
|
||||
## Summary of Features
|
||||
The following ECMAScript 5.1 features, which are not supported in JSON, have
|
||||
been extended to JSON5.
|
||||
|
||||
### Objects
|
||||
|
||||
- Object keys can be unquoted if they’re valid [identifiers][mdn_variables].
|
||||
Yes, even reserved keywords (like `default`) are valid unquoted keys in ES5
|
||||
[[§11.1.5](http://es5.github.com/#x11.1.5), [§7.6](http://es5.github.com/#x7.6)].
|
||||
([More info](https://mathiasbynens.be/notes/javascript-identifiers))
|
||||
|
||||
*(TODO: Unicode characters and escape sequences aren’t yet supported in this
|
||||
implementation.)*
|
||||
|
||||
- Object keys can also be single-quoted.
|
||||
|
||||
- Objects can have trailing commas.
|
||||
|
||||
[mdn_variables]: https://developer.mozilla.org/en/Core_JavaScript_1.5_Guide/Core_Language_Features#Variables
|
||||
- Object keys may be an ECMAScript 5.1 _[IdentifierName]_.
|
||||
- Objects may have a single trailing comma.
|
||||
|
||||
### Arrays
|
||||
|
||||
- Arrays can have trailing commas.
|
||||
- Arrays may have a single trailing comma.
|
||||
|
||||
### Strings
|
||||
|
||||
- Strings can be single-quoted.
|
||||
|
||||
- Strings can be split across multiple lines; just prefix each newline with a
|
||||
backslash. [ES5 [§7.8.4](http://es5.github.com/#x7.8.4)]
|
||||
- Strings may be single quoted.
|
||||
- Strings may span multiple lines by escaping new line characters.
|
||||
- Strings may include character escapes.
|
||||
|
||||
### Numbers
|
||||
|
||||
- Numbers can be hexadecimal (base 16).
|
||||
|
||||
- Numbers can begin or end with a (leading or trailing) decimal point.
|
||||
|
||||
- Numbers can include `Infinity`, `-Infinity`, `NaN`, and `-NaN`.
|
||||
|
||||
- Numbers can begin with an explicit plus sign.
|
||||
- Numbers may be hexadecimal.
|
||||
- Numbers may have a leading or trailing decimal point.
|
||||
- Numbers may be [IEEE 754] positive infinity, negative infinity, and NaN.
|
||||
- Numbers may begin with an explicit plus sign.
|
||||
|
||||
### Comments
|
||||
- Single and multi-line comments are allowed.
|
||||
|
||||
- Both inline (single-line) and block (multi-line) comments are allowed.
|
||||
### White Space
|
||||
- Additional white space characters are allowed.
|
||||
|
||||
[IdentifierName]: https://www.ecma-international.org/ecma-262/5.1/#sec-7.6
|
||||
|
||||
## Example
|
||||
|
||||
The following is a contrived example, but it illustrates most of the features:
|
||||
[IEEE 754]: http://ieeexplore.ieee.org/servlet/opac?punumber=4610933
|
||||
|
||||
## Short Example
|
||||
```js
|
||||
{
|
||||
foo: 'bar',
|
||||
while: true,
|
||||
|
||||
this: 'is a \
|
||||
multi-line string',
|
||||
|
||||
// this is an inline comment
|
||||
here: 'is another', // inline comment
|
||||
|
||||
/* this is a block comment
|
||||
that continues on another line */
|
||||
|
||||
hex: 0xDEADbeef,
|
||||
half: .5,
|
||||
delta: +10,
|
||||
to: Infinity, // and beyond!
|
||||
|
||||
finally: 'a trailing comma',
|
||||
oh: [
|
||||
"we shouldn't forget",
|
||||
'arrays can have',
|
||||
'trailing commas too',
|
||||
],
|
||||
// comments
|
||||
unquoted: 'and you can quote me on that',
|
||||
singleQuotes: 'I can use "double quotes" here',
|
||||
lineBreaks: "Look, Mom! \
|
||||
No \\n's!",
|
||||
hexadecimal: 0xdecaf,
|
||||
leadingDecimalPoint: .8675309, andTrailing: 8675309.,
|
||||
positiveSign: +1,
|
||||
trailingComma: 'in objects', andIn: ['arrays',],
|
||||
"backwardsCompatible": "with JSON",
|
||||
}
|
||||
```
|
||||
|
||||
This implementation’s own [package.json5](package.json5) is more realistic:
|
||||
|
||||
```js
|
||||
// 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!
|
||||
|
||||
{
|
||||
name: 'json5',
|
||||
version: '0.5.0',
|
||||
description: 'JSON for the ES5 era.',
|
||||
keywords: ['json', 'es5'],
|
||||
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>',
|
||||
'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.0",
|
||||
jshint: "^2.9.1",
|
||||
'jshint-stylish': "^2.1.0",
|
||||
mocha: "^2.4.5"
|
||||
},
|
||||
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',
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## Community
|
||||
|
||||
Join the [Google Group](http://groups.google.com/group/json5) if you’re
|
||||
interested in JSON5 news, updates, and general discussion.
|
||||
Don’t worry, it’s very low-traffic.
|
||||
|
||||
The [GitHub wiki](https://github.com/aseemk/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
|
||||
formally propose feature requests and report bugs. Questions and general
|
||||
feedback are better directed at the Google Group.
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
This JavaScript implementation of JSON5 simply provides a `JSON5` object just
|
||||
like the native ES5 `JSON` object.
|
||||
|
||||
To use from Node:
|
||||
## Specification
|
||||
For a detailed explanation of the JSON5 format, please read the [official
|
||||
specification](https://json5.github.io/json5-spec/).
|
||||
|
||||
## Installation
|
||||
### Node.js
|
||||
```sh
|
||||
npm install json5
|
||||
```
|
||||
|
||||
```js
|
||||
var JSON5 = require('json5');
|
||||
const JSON5 = require('json5')
|
||||
```
|
||||
|
||||
To use in the browser (adds the `JSON5` object to the global namespace):
|
||||
|
||||
### Browsers
|
||||
```html
|
||||
<script src="json5.js"></script>
|
||||
<script src="https://unpkg.com/json5@^2.0.0/dist/index.min.js"></script>
|
||||
```
|
||||
|
||||
Then in both cases, you can simply replace native `JSON` calls with `JSON5`:
|
||||
This will create a global `JSON5` variable.
|
||||
|
||||
## API
|
||||
The JSON5 API is compatible with the [JSON API].
|
||||
|
||||
[JSON API]:
|
||||
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON
|
||||
|
||||
### JSON5.parse()
|
||||
Parses a JSON5 string, constructing the JavaScript value or object described by
|
||||
the string. An optional reviver function can be provided to perform a
|
||||
transformation on the resulting object before it is returned.
|
||||
|
||||
#### Syntax
|
||||
JSON5.parse(text[, reviver])
|
||||
|
||||
#### Parameters
|
||||
- `text`: The string to parse as JSON5.
|
||||
- `reviver`: If a function, this prescribes how the value originally produced by
|
||||
parsing is transformed, before being returned.
|
||||
|
||||
#### Return value
|
||||
The object corresponding to the given JSON5 text.
|
||||
|
||||
### JSON5.stringify()
|
||||
Converts a JavaScript value to a JSON5 string, optionally replacing values if a
|
||||
replacer function is specified, or optionally including only the specified
|
||||
properties if a replacer array is specified.
|
||||
|
||||
#### Syntax
|
||||
JSON5.stringify(value[, replacer[, space]])
|
||||
JSON5.stringify(value[, options])
|
||||
|
||||
#### Parameters
|
||||
- `value`: The value to convert to a JSON5 string.
|
||||
- `replacer`: A function that alters the behavior of the stringification
|
||||
process, or an array of String and Number objects that serve as a whitelist
|
||||
for selecting/filtering the properties of the value object to be included in
|
||||
the JSON5 string. If this value is null or not provided, all properties of the
|
||||
object are included in the resulting JSON5 string.
|
||||
- `space`: A String or Number object that's used to insert white space into the
|
||||
output JSON5 string for readability purposes. If this is a Number, it
|
||||
indicates the number of space characters to use as white space; this number is
|
||||
capped at 10 (if it is greater, the value is just 10). Values less than 1
|
||||
indicate that no space should be used. If this is a String, the string (or the
|
||||
first 10 characters of the string, if it's longer than that) is used as white
|
||||
space. If this parameter is not provided (or is null), no white space is used.
|
||||
If white space is used, trailing commas will be used in objects and arrays.
|
||||
- `options`: An object with the following properties:
|
||||
- `replacer`: Same as the `replacer` parameter.
|
||||
- `space`: Same as the `space` parameter.
|
||||
- `quote`: A String representing the quote character to use when serializing
|
||||
strings.
|
||||
|
||||
#### Return value
|
||||
A JSON5 string representing the value.
|
||||
|
||||
### Node.js `require()` JSON5 files
|
||||
When using Node.js, you can `require()` JSON5 files by adding the following
|
||||
statement.
|
||||
|
||||
```js
|
||||
var obj = JSON5.parse('{unquoted:"key",trailing:"comma",}');
|
||||
var str = JSON5.stringify(obj);
|
||||
require('json5/lib/register')
|
||||
```
|
||||
|
||||
`JSON5.parse` supports all of the JSON5 features listed above (*TODO: except
|
||||
Unicode*), as well as the native [`reviver` argument][json-parse].
|
||||
|
||||
[json-parse]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse
|
||||
|
||||
`JSON5.stringify` mainly avoids quoting keys where possible, but we hope to
|
||||
keep expanding it in the future (e.g. to also output trailing commas).
|
||||
It supports the native [`replacer` and `space` arguments][json-stringify],
|
||||
as well. *(TODO: Any implemented `toJSON` methods aren’t used today.)*
|
||||
|
||||
[json-stringify]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify
|
||||
|
||||
|
||||
### Extras
|
||||
|
||||
If you’re running this on Node, you can also register a JSON5 `require()` hook
|
||||
to let you `require()` `.json5` files just like you can `.json` files:
|
||||
Then you can load a JSON5 file with a Node.js `require()` statement. For
|
||||
example:
|
||||
|
||||
```js
|
||||
require('json5/lib/require');
|
||||
require('./path/to/foo'); // tries foo.json5 after foo.js, foo.json, etc.
|
||||
require('./path/to/bar.json5');
|
||||
const config = require('./config.json5')
|
||||
```
|
||||
|
||||
This module also provides a `json5` executable (requires Node) for converting
|
||||
JSON5 files to JSON:
|
||||
## CLI
|
||||
Since JSON is more widely used than JSON5, this package includes a CLI for
|
||||
converting JSON5 to JSON and for validating the syntax of JSON5 documents.
|
||||
|
||||
### Installation
|
||||
```sh
|
||||
json5 -c path/to/foo.json5 # generates path/to/foo.json
|
||||
npm install --global json5
|
||||
```
|
||||
|
||||
|
||||
## Development
|
||||
|
||||
### Usage
|
||||
```sh
|
||||
git clone git://github.com/aseemk/json5.git
|
||||
json5 [options] <file>
|
||||
```
|
||||
|
||||
If `<file>` is not provided, then STDIN is used.
|
||||
|
||||
#### Options:
|
||||
- `-s`, `--space`: The number of spaces to indent or `t` for tabs
|
||||
- `-o`, `--out-file [file]`: Output to the specified file, otherwise STDOUT
|
||||
- `-v`, `--validate`: Validate JSON5 but do not output JSON
|
||||
- `-V`, `--version`: Output the version number
|
||||
- `-h`, `--help`: Output usage information
|
||||
|
||||
## Contributing
|
||||
### Development
|
||||
```sh
|
||||
git clone https://github.com/json5/json5
|
||||
cd json5
|
||||
npm install
|
||||
npm test
|
||||
```
|
||||
|
||||
As the `package.json5` file states, be sure to run `npm run build` on changes
|
||||
to `package.json5`, since npm requires `package.json`.
|
||||
When contributing code, please write relevant tests and run `npm test` and `npm
|
||||
run lint` before submitting pull requests. Please use an editor that supports
|
||||
[EditorConfig](http://editorconfig.org/).
|
||||
|
||||
Feel free to [file issues](https://github.com/aseemk/json5/issues) and submit
|
||||
[pull requests](https://github.com/aseemk/json5/pulls) — contributions are
|
||||
welcome. If you do submit a pull request, please be sure to add or update the
|
||||
tests, and ensure that `npm test` continues to pass.
|
||||
### Issues
|
||||
To report bugs or request features regarding the JSON5 data format, please
|
||||
submit an issue to the [official specification
|
||||
repository](https://github.com/json5/json5-spec).
|
||||
|
||||
To report bugs or request features regarding the JavaScript implentation of
|
||||
JSON5, please submit an issue to this repository.
|
||||
|
||||
## License
|
||||
|
||||
MIT. See [LICENSE.md](./LICENSE.md) for details.
|
||||
|
||||
|
||||
## Credits
|
||||
[Assem Kishore](https://github.com/aseemk) founded this project.
|
||||
|
||||
[Michael Bolin](http://bolinfest.com/) independently arrived at and published
|
||||
some of these same ideas with awesome explanations and detail.
|
||||
Recommended reading:
|
||||
[Suggested Improvements to JSON](http://bolinfest.com/essays/json.html)
|
||||
some of these same ideas with awesome explanations and detail. Recommended
|
||||
reading: [Suggested Improvements to JSON](http://bolinfest.com/essays/json.html)
|
||||
|
||||
[Douglas Crockford](http://www.crockford.com/) of course designed and built
|
||||
JSON, but his state machine diagrams on the [JSON website](http://json.org/),
|
||||
as cheesy as it may sound, gave me motivation and confidence that building a
|
||||
new parser to implement these ideas this was within my reach!
|
||||
This code is also modeled directly off of Doug’s open-source [json_parse.js][]
|
||||
parser. I’m super grateful for that clean and well-documented code.
|
||||
JSON, but his state machine diagrams on the [JSON website](http://json.org/), as
|
||||
cheesy as it may sound, gave us motivation and confidence that building a new
|
||||
parser to implement these ideas was within reach! The original
|
||||
implementation of JSON5 was also modeled directly off of Doug’s open-source
|
||||
[json_parse.js] parser. We’re grateful for that clean and well-documented
|
||||
code.
|
||||
|
||||
[json_parse.js]: https://github.com/douglascrockford/JSON-js/blob/master/json_parse.js
|
||||
[json_parse.js]:
|
||||
https://github.com/douglascrockford/JSON-js/blob/master/json_parse.js
|
||||
|
||||
[Max Nanasy](https://github.com/MaxNanasy) has been an early and prolific
|
||||
supporter, contributing multiple patches and ideas. Thanks Max!
|
||||
supporter, contributing multiple patches and ideas.
|
||||
|
||||
[Andrew Eisenberg](https://github.com/aeisenberg) has contributed the
|
||||
[Andrew Eisenberg](https://github.com/aeisenberg) contributed the original
|
||||
`stringify` method.
|
||||
|
||||
[Jordan Tucker](https://github.com/jordanbtucker) has aligned JSON5 more closely
|
||||
with ES5 and is actively maintaining this project.
|
||||
with ES5, wrote the official JSON5 specification, completely rewrote the
|
||||
codebase from the ground up, and is actively maintaining this project.
|
||||
|
||||
131
node_modules/json5/lib/cli.js
generated
vendored
131
node_modules/json5/lib/cli.js
generated
vendored
@@ -1,41 +1,112 @@
|
||||
#!/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.?
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const minimist = require('minimist')
|
||||
const pkg = require('../package.json')
|
||||
const JSON5 = require('./')
|
||||
|
||||
var FS = require('fs');
|
||||
var JSON5 = require('./json5');
|
||||
var Path = require('path');
|
||||
const argv = minimist(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',
|
||||
],
|
||||
})
|
||||
|
||||
var USAGE = [
|
||||
'Usage: json5 -c path/to/file.json5 ...',
|
||||
'Compiles JSON5 files into sibling JSON files with the same basenames.',
|
||||
].join('\n');
|
||||
if (argv.version) {
|
||||
version()
|
||||
} else if (argv.help) {
|
||||
usage()
|
||||
} else {
|
||||
const inFilename = argv._[0]
|
||||
|
||||
// if valid, args look like [node, json5, -c, file1, file2, ...]
|
||||
var args = process.argv;
|
||||
let readStream
|
||||
if (inFilename) {
|
||||
readStream = fs.createReadStream(inFilename)
|
||||
} else {
|
||||
readStream = process.stdin
|
||||
}
|
||||
|
||||
if (args.length < 4 || args[2] !== '-c') {
|
||||
console.error(USAGE);
|
||||
process.exit(1);
|
||||
let json5 = ''
|
||||
readStream.on('data', data => {
|
||||
json5 += data
|
||||
})
|
||||
|
||||
readStream.on('end', () => {
|
||||
let space
|
||||
if (argv.space === 't' || argv.space === 'tab') {
|
||||
space = '\t'
|
||||
} else {
|
||||
space = Number(argv.space)
|
||||
}
|
||||
|
||||
let value
|
||||
try {
|
||||
value = JSON5.parse(json5)
|
||||
if (!argv.validate) {
|
||||
const json = JSON.stringify(value, null, space)
|
||||
|
||||
let writeStream
|
||||
|
||||
// --convert is for backward compatibility with v0.5.1. If
|
||||
// specified with <file> and not --out-file, then a file with
|
||||
// the same name but with a .json extension will be written.
|
||||
if (argv.convert && inFilename && !argv.o) {
|
||||
const parsedFilename = path.parse(inFilename)
|
||||
const outFilename = path.format(
|
||||
Object.assign(
|
||||
parsedFilename,
|
||||
{base: path.basename(parsedFilename.base, parsedFilename.ext) + '.json'}
|
||||
)
|
||||
)
|
||||
|
||||
writeStream = fs.createWriteStream(outFilename)
|
||||
} else if (argv.o) {
|
||||
writeStream = fs.createWriteStream(argv.o)
|
||||
} else {
|
||||
writeStream = process.stdout
|
||||
}
|
||||
|
||||
writeStream.write(json)
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err.message)
|
||||
process.exit(1)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
var cwd = process.cwd();
|
||||
var files = args.slice(3);
|
||||
function version () {
|
||||
console.log(pkg.version)
|
||||
}
|
||||
|
||||
// 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);
|
||||
function usage () {
|
||||
console.log(
|
||||
`
|
||||
Usage: json5 [options] <file>
|
||||
|
||||
var json5 = FS.readFileSync(path, 'utf8');
|
||||
var obj = JSON5.parse(json5);
|
||||
var json = JSON.stringify(obj, null, 4); // 4 spaces; TODO configurable?
|
||||
If <file> is not provided, then STDIN is used.
|
||||
|
||||
path = Path.join(dirname, basename + '.json');
|
||||
FS.writeFileSync(path, json, 'utf8');
|
||||
});
|
||||
Options:
|
||||
|
||||
-s, --space The number of spaces to indent or 't' for tabs
|
||||
-o, --out-file [file] Output to the specified file, otherwise STDOUT
|
||||
-v, --validate Validate JSON5 but do not output JSON
|
||||
-V, --version Output the version number
|
||||
-h, --help Output usage information`
|
||||
)
|
||||
}
|
||||
|
||||
770
node_modules/json5/lib/json5.js
generated
vendored
770
node_modules/json5/lib/json5.js
generated
vendored
@@ -1,770 +0,0 @@
|
||||
// json5.js
|
||||
// Modern JSON. See README.md for details.
|
||||
//
|
||||
// This file is based directly off of Douglas Crockford's json_parse.js:
|
||||
// https://github.com/douglascrockford/JSON-js/blob/master/json_parse.js
|
||||
|
||||
var JSON5 = (typeof exports === 'object' ? exports : {});
|
||||
|
||||
JSON5.parse = (function () {
|
||||
"use strict";
|
||||
|
||||
// This is a function that can parse a JSON5 text, producing a JavaScript
|
||||
// data structure. It is a simple, recursive descent parser. It does not use
|
||||
// eval or regular expressions, so it can be used as a model for implementing
|
||||
// a JSON5 parser in other languages.
|
||||
|
||||
// We are defining the function inside of another function to avoid creating
|
||||
// global variables.
|
||||
|
||||
var at, // The index of the current character
|
||||
lineNumber, // The current line number
|
||||
columnNumber, // The current column number
|
||||
ch, // The current character
|
||||
escapee = {
|
||||
"'": "'",
|
||||
'"': '"',
|
||||
'\\': '\\',
|
||||
'/': '/',
|
||||
'\n': '', // Replace escaped newlines in strings w/ empty string
|
||||
b: '\b',
|
||||
f: '\f',
|
||||
n: '\n',
|
||||
r: '\r',
|
||||
t: '\t'
|
||||
},
|
||||
ws = [
|
||||
' ',
|
||||
'\t',
|
||||
'\r',
|
||||
'\n',
|
||||
'\v',
|
||||
'\f',
|
||||
'\xA0',
|
||||
'\uFEFF'
|
||||
],
|
||||
text,
|
||||
|
||||
renderChar = function (chr) {
|
||||
return chr === '' ? 'EOF' : "'" + chr + "'";
|
||||
},
|
||||
|
||||
error = function (m) {
|
||||
|
||||
// Call error when something is wrong.
|
||||
|
||||
var error = new SyntaxError();
|
||||
// beginning of message suffix to agree with that provided by Gecko - see https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse
|
||||
error.message = m + " at line " + lineNumber + " column " + columnNumber + " of the JSON5 data. Still to read: " + JSON.stringify(text.substring(at - 1, at + 19));
|
||||
error.at = at;
|
||||
// These two property names have been chosen to agree with the ones in Gecko, the only popular
|
||||
// environment which seems to supply this info on JSON.parse
|
||||
error.lineNumber = lineNumber;
|
||||
error.columnNumber = columnNumber;
|
||||
throw error;
|
||||
},
|
||||
|
||||
next = function (c) {
|
||||
|
||||
// If a c parameter is provided, verify that it matches the current character.
|
||||
|
||||
if (c && c !== ch) {
|
||||
error("Expected " + renderChar(c) + " instead of " + renderChar(ch));
|
||||
}
|
||||
|
||||
// Get the next character. When there are no more characters,
|
||||
// return the empty string.
|
||||
|
||||
ch = text.charAt(at);
|
||||
at++;
|
||||
columnNumber++;
|
||||
if (ch === '\n' || ch === '\r' && peek() !== '\n') {
|
||||
lineNumber++;
|
||||
columnNumber = 0;
|
||||
}
|
||||
return ch;
|
||||
},
|
||||
|
||||
peek = function () {
|
||||
|
||||
// Get the next character without consuming it or
|
||||
// assigning it to the ch varaible.
|
||||
|
||||
return text.charAt(at);
|
||||
},
|
||||
|
||||
identifier = function () {
|
||||
|
||||
// Parse an identifier. Normally, reserved words are disallowed here, but we
|
||||
// only use this for unquoted object keys, where reserved words are allowed,
|
||||
// so we don't check for those here. References:
|
||||
// - http://es5.github.com/#x7.6
|
||||
// - https://developer.mozilla.org/en/Core_JavaScript_1.5_Guide/Core_Language_Features#Variables
|
||||
// - http://docstore.mik.ua/orelly/webprog/jscript/ch02_07.htm
|
||||
// TODO Identifiers can have Unicode "letters" in them; add support for those.
|
||||
|
||||
var key = ch;
|
||||
|
||||
// Identifiers must start with a letter, _ or $.
|
||||
if ((ch !== '_' && ch !== '$') &&
|
||||
(ch < 'a' || ch > 'z') &&
|
||||
(ch < 'A' || ch > 'Z')) {
|
||||
error("Bad identifier as unquoted key");
|
||||
}
|
||||
|
||||
// Subsequent characters can contain digits.
|
||||
while (next() && (
|
||||
ch === '_' || ch === '$' ||
|
||||
(ch >= 'a' && ch <= 'z') ||
|
||||
(ch >= 'A' && ch <= 'Z') ||
|
||||
(ch >= '0' && ch <= '9'))) {
|
||||
key += ch;
|
||||
}
|
||||
|
||||
return key;
|
||||
},
|
||||
|
||||
number = function () {
|
||||
|
||||
// Parse a number value.
|
||||
|
||||
var number,
|
||||
sign = '',
|
||||
string = '',
|
||||
base = 10;
|
||||
|
||||
if (ch === '-' || ch === '+') {
|
||||
sign = ch;
|
||||
next(ch);
|
||||
}
|
||||
|
||||
// support for Infinity (could tweak to allow other words):
|
||||
if (ch === 'I') {
|
||||
number = word();
|
||||
if (typeof number !== 'number' || isNaN(number)) {
|
||||
error('Unexpected word for number');
|
||||
}
|
||||
return (sign === '-') ? -number : number;
|
||||
}
|
||||
|
||||
// support for NaN
|
||||
if (ch === 'N' ) {
|
||||
number = word();
|
||||
if (!isNaN(number)) {
|
||||
error('expected word to be NaN');
|
||||
}
|
||||
// ignore sign as -NaN also is NaN
|
||||
return number;
|
||||
}
|
||||
|
||||
if (ch === '0') {
|
||||
string += ch;
|
||||
next();
|
||||
if (ch === 'x' || ch === 'X') {
|
||||
string += ch;
|
||||
next();
|
||||
base = 16;
|
||||
} else if (ch >= '0' && ch <= '9') {
|
||||
error('Octal literal');
|
||||
}
|
||||
}
|
||||
|
||||
switch (base) {
|
||||
case 10:
|
||||
while (ch >= '0' && ch <= '9' ) {
|
||||
string += ch;
|
||||
next();
|
||||
}
|
||||
if (ch === '.') {
|
||||
string += '.';
|
||||
while (next() && ch >= '0' && ch <= '9') {
|
||||
string += ch;
|
||||
}
|
||||
}
|
||||
if (ch === 'e' || ch === 'E') {
|
||||
string += ch;
|
||||
next();
|
||||
if (ch === '-' || ch === '+') {
|
||||
string += ch;
|
||||
next();
|
||||
}
|
||||
while (ch >= '0' && ch <= '9') {
|
||||
string += ch;
|
||||
next();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 16:
|
||||
while (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'F' || ch >= 'a' && ch <= 'f') {
|
||||
string += ch;
|
||||
next();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if(sign === '-') {
|
||||
number = -string;
|
||||
} else {
|
||||
number = +string;
|
||||
}
|
||||
|
||||
if (!isFinite(number)) {
|
||||
error("Bad number");
|
||||
} else {
|
||||
return number;
|
||||
}
|
||||
},
|
||||
|
||||
string = function () {
|
||||
|
||||
// Parse a string value.
|
||||
|
||||
var hex,
|
||||
i,
|
||||
string = '',
|
||||
delim, // double quote or single quote
|
||||
uffff;
|
||||
|
||||
// When parsing for string values, we must look for ' or " and \ characters.
|
||||
|
||||
if (ch === '"' || ch === "'") {
|
||||
delim = ch;
|
||||
while (next()) {
|
||||
if (ch === delim) {
|
||||
next();
|
||||
return string;
|
||||
} else if (ch === '\\') {
|
||||
next();
|
||||
if (ch === 'u') {
|
||||
uffff = 0;
|
||||
for (i = 0; i < 4; i += 1) {
|
||||
hex = parseInt(next(), 16);
|
||||
if (!isFinite(hex)) {
|
||||
break;
|
||||
}
|
||||
uffff = uffff * 16 + hex;
|
||||
}
|
||||
string += String.fromCharCode(uffff);
|
||||
} else if (ch === '\r') {
|
||||
if (peek() === '\n') {
|
||||
next();
|
||||
}
|
||||
} else if (typeof escapee[ch] === 'string') {
|
||||
string += escapee[ch];
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
} else if (ch === '\n') {
|
||||
// unescaped newlines are invalid; see:
|
||||
// https://github.com/aseemk/json5/issues/24
|
||||
// TODO this feels special-cased; are there other
|
||||
// invalid unescaped chars?
|
||||
break;
|
||||
} else {
|
||||
string += ch;
|
||||
}
|
||||
}
|
||||
}
|
||||
error("Bad string");
|
||||
},
|
||||
|
||||
inlineComment = function () {
|
||||
|
||||
// Skip an inline comment, assuming this is one. The current character should
|
||||
// be the second / character in the // pair that begins this inline comment.
|
||||
// To finish the inline comment, we look for a newline or the end of the text.
|
||||
|
||||
if (ch !== '/') {
|
||||
error("Not an inline comment");
|
||||
}
|
||||
|
||||
do {
|
||||
next();
|
||||
if (ch === '\n' || ch === '\r') {
|
||||
next();
|
||||
return;
|
||||
}
|
||||
} while (ch);
|
||||
},
|
||||
|
||||
blockComment = function () {
|
||||
|
||||
// Skip a block comment, assuming this is one. The current character should be
|
||||
// the * character in the /* pair that begins this block comment.
|
||||
// To finish the block comment, we look for an ending */ pair of characters,
|
||||
// but we also watch for the end of text before the comment is terminated.
|
||||
|
||||
if (ch !== '*') {
|
||||
error("Not a block comment");
|
||||
}
|
||||
|
||||
do {
|
||||
next();
|
||||
while (ch === '*') {
|
||||
next('*');
|
||||
if (ch === '/') {
|
||||
next('/');
|
||||
return;
|
||||
}
|
||||
}
|
||||
} while (ch);
|
||||
|
||||
error("Unterminated block comment");
|
||||
},
|
||||
|
||||
comment = function () {
|
||||
|
||||
// Skip a comment, whether inline or block-level, assuming this is one.
|
||||
// Comments always begin with a / character.
|
||||
|
||||
if (ch !== '/') {
|
||||
error("Not a comment");
|
||||
}
|
||||
|
||||
next('/');
|
||||
|
||||
if (ch === '/') {
|
||||
inlineComment();
|
||||
} else if (ch === '*') {
|
||||
blockComment();
|
||||
} else {
|
||||
error("Unrecognized comment");
|
||||
}
|
||||
},
|
||||
|
||||
white = function () {
|
||||
|
||||
// Skip whitespace and comments.
|
||||
// Note that we're detecting comments by only a single / character.
|
||||
// This works since regular expressions are not valid JSON(5), but this will
|
||||
// break if there are other valid values that begin with a / character!
|
||||
|
||||
while (ch) {
|
||||
if (ch === '/') {
|
||||
comment();
|
||||
} else if (ws.indexOf(ch) >= 0) {
|
||||
next();
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
word = function () {
|
||||
|
||||
// true, false, or null.
|
||||
|
||||
switch (ch) {
|
||||
case 't':
|
||||
next('t');
|
||||
next('r');
|
||||
next('u');
|
||||
next('e');
|
||||
return true;
|
||||
case 'f':
|
||||
next('f');
|
||||
next('a');
|
||||
next('l');
|
||||
next('s');
|
||||
next('e');
|
||||
return false;
|
||||
case 'n':
|
||||
next('n');
|
||||
next('u');
|
||||
next('l');
|
||||
next('l');
|
||||
return null;
|
||||
case 'I':
|
||||
next('I');
|
||||
next('n');
|
||||
next('f');
|
||||
next('i');
|
||||
next('n');
|
||||
next('i');
|
||||
next('t');
|
||||
next('y');
|
||||
return Infinity;
|
||||
case 'N':
|
||||
next( 'N' );
|
||||
next( 'a' );
|
||||
next( 'N' );
|
||||
return NaN;
|
||||
}
|
||||
error("Unexpected " + renderChar(ch));
|
||||
},
|
||||
|
||||
value, // Place holder for the value function.
|
||||
|
||||
array = function () {
|
||||
|
||||
// Parse an array value.
|
||||
|
||||
var array = [];
|
||||
|
||||
if (ch === '[') {
|
||||
next('[');
|
||||
white();
|
||||
while (ch) {
|
||||
if (ch === ']') {
|
||||
next(']');
|
||||
return array; // Potentially empty array
|
||||
}
|
||||
// ES5 allows omitting elements in arrays, e.g. [,] and
|
||||
// [,null]. We don't allow this in JSON5.
|
||||
if (ch === ',') {
|
||||
error("Missing array element");
|
||||
} else {
|
||||
array.push(value());
|
||||
}
|
||||
white();
|
||||
// If there's no comma after this value, this needs to
|
||||
// be the end of the array.
|
||||
if (ch !== ',') {
|
||||
next(']');
|
||||
return array;
|
||||
}
|
||||
next(',');
|
||||
white();
|
||||
}
|
||||
}
|
||||
error("Bad array");
|
||||
},
|
||||
|
||||
object = function () {
|
||||
|
||||
// Parse an object value.
|
||||
|
||||
var key,
|
||||
object = {};
|
||||
|
||||
if (ch === '{') {
|
||||
next('{');
|
||||
white();
|
||||
while (ch) {
|
||||
if (ch === '}') {
|
||||
next('}');
|
||||
return object; // Potentially empty object
|
||||
}
|
||||
|
||||
// Keys can be unquoted. If they are, they need to be
|
||||
// valid JS identifiers.
|
||||
if (ch === '"' || ch === "'") {
|
||||
key = string();
|
||||
} else {
|
||||
key = identifier();
|
||||
}
|
||||
|
||||
white();
|
||||
next(':');
|
||||
object[key] = value();
|
||||
white();
|
||||
// If there's no comma after this pair, this needs to be
|
||||
// the end of the object.
|
||||
if (ch !== ',') {
|
||||
next('}');
|
||||
return object;
|
||||
}
|
||||
next(',');
|
||||
white();
|
||||
}
|
||||
}
|
||||
error("Bad object");
|
||||
};
|
||||
|
||||
value = function () {
|
||||
|
||||
// Parse a JSON value. It could be an object, an array, a string, a number,
|
||||
// or a word.
|
||||
|
||||
white();
|
||||
switch (ch) {
|
||||
case '{':
|
||||
return object();
|
||||
case '[':
|
||||
return array();
|
||||
case '"':
|
||||
case "'":
|
||||
return string();
|
||||
case '-':
|
||||
case '+':
|
||||
case '.':
|
||||
return number();
|
||||
default:
|
||||
return ch >= '0' && ch <= '9' ? number() : word();
|
||||
}
|
||||
};
|
||||
|
||||
// Return the json_parse function. It will have access to all of the above
|
||||
// functions and variables.
|
||||
|
||||
return function (source, reviver) {
|
||||
var result;
|
||||
|
||||
text = String(source);
|
||||
at = 0;
|
||||
lineNumber = 1;
|
||||
columnNumber = 1;
|
||||
ch = ' ';
|
||||
result = value();
|
||||
white();
|
||||
if (ch) {
|
||||
error("Syntax error");
|
||||
}
|
||||
|
||||
// If there is a reviver function, we recursively walk the new structure,
|
||||
// passing each name/value pair to the reviver function for possible
|
||||
// transformation, starting with a temporary root object that holds the result
|
||||
// in an empty key. If there is not a reviver function, we simply return the
|
||||
// result.
|
||||
|
||||
return typeof reviver === 'function' ? (function walk(holder, key) {
|
||||
var k, v, value = holder[key];
|
||||
if (value && typeof value === 'object') {
|
||||
for (k in value) {
|
||||
if (Object.prototype.hasOwnProperty.call(value, k)) {
|
||||
v = walk(value, k);
|
||||
if (v !== undefined) {
|
||||
value[k] = v;
|
||||
} else {
|
||||
delete value[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return reviver.call(holder, key, value);
|
||||
}({'': result}, '')) : result;
|
||||
};
|
||||
}());
|
||||
|
||||
// JSON5 stringify will not quote keys where appropriate
|
||||
JSON5.stringify = function (obj, replacer, space) {
|
||||
if (replacer && (typeof(replacer) !== "function" && !isArray(replacer))) {
|
||||
throw new Error('Replacer must be a function or an array');
|
||||
}
|
||||
var getReplacedValueOrUndefined = function(holder, key, isTopLevel) {
|
||||
var value = holder[key];
|
||||
|
||||
// Replace the value with its toJSON value first, if possible
|
||||
if (value && value.toJSON && typeof value.toJSON === "function") {
|
||||
value = value.toJSON();
|
||||
}
|
||||
|
||||
// If the user-supplied replacer if a function, call it. If it's an array, check objects' string keys for
|
||||
// presence in the array (removing the key/value pair from the resulting JSON if the key is missing).
|
||||
if (typeof(replacer) === "function") {
|
||||
return replacer.call(holder, key, value);
|
||||
} else if(replacer) {
|
||||
if (isTopLevel || isArray(holder) || replacer.indexOf(key) >= 0) {
|
||||
return value;
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
};
|
||||
|
||||
function isWordChar(c) {
|
||||
return (c >= 'a' && c <= 'z') ||
|
||||
(c >= 'A' && c <= 'Z') ||
|
||||
(c >= '0' && c <= '9') ||
|
||||
c === '_' || c === '$';
|
||||
}
|
||||
|
||||
function isWordStart(c) {
|
||||
return (c >= 'a' && c <= 'z') ||
|
||||
(c >= 'A' && c <= 'Z') ||
|
||||
c === '_' || c === '$';
|
||||
}
|
||||
|
||||
function isWord(key) {
|
||||
if (typeof key !== 'string') {
|
||||
return false;
|
||||
}
|
||||
if (!isWordStart(key[0])) {
|
||||
return false;
|
||||
}
|
||||
var i = 1, length = key.length;
|
||||
while (i < length) {
|
||||
if (!isWordChar(key[i])) {
|
||||
return false;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// export for use in tests
|
||||
JSON5.isWord = isWord;
|
||||
|
||||
// polyfills
|
||||
function isArray(obj) {
|
||||
if (Array.isArray) {
|
||||
return Array.isArray(obj);
|
||||
} else {
|
||||
return Object.prototype.toString.call(obj) === '[object Array]';
|
||||
}
|
||||
}
|
||||
|
||||
function isDate(obj) {
|
||||
return Object.prototype.toString.call(obj) === '[object Date]';
|
||||
}
|
||||
|
||||
var objStack = [];
|
||||
function checkForCircular(obj) {
|
||||
for (var i = 0; i < objStack.length; i++) {
|
||||
if (objStack[i] === obj) {
|
||||
throw new TypeError("Converting circular structure to JSON");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function makeIndent(str, num, noNewLine) {
|
||||
if (!str) {
|
||||
return "";
|
||||
}
|
||||
// indentation no more than 10 chars
|
||||
if (str.length > 10) {
|
||||
str = str.substring(0, 10);
|
||||
}
|
||||
|
||||
var indent = noNewLine ? "" : "\n";
|
||||
for (var i = 0; i < num; i++) {
|
||||
indent += str;
|
||||
}
|
||||
|
||||
return indent;
|
||||
}
|
||||
|
||||
var indentStr;
|
||||
if (space) {
|
||||
if (typeof space === "string") {
|
||||
indentStr = space;
|
||||
} else if (typeof space === "number" && space >= 0) {
|
||||
indentStr = makeIndent(" ", space, true);
|
||||
} else {
|
||||
// ignore space parameter
|
||||
}
|
||||
}
|
||||
|
||||
// Copied from Crokford's implementation of JSON
|
||||
// See https://github.com/douglascrockford/JSON-js/blob/e39db4b7e6249f04a195e7dd0840e610cc9e941e/json2.js#L195
|
||||
// Begin
|
||||
var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
|
||||
escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
|
||||
meta = { // table of character substitutions
|
||||
'\b': '\\b',
|
||||
'\t': '\\t',
|
||||
'\n': '\\n',
|
||||
'\f': '\\f',
|
||||
'\r': '\\r',
|
||||
'"' : '\\"',
|
||||
'\\': '\\\\'
|
||||
};
|
||||
function escapeString(string) {
|
||||
|
||||
// If the string contains no control characters, no quote characters, and no
|
||||
// backslash characters, then we can safely slap some quotes around it.
|
||||
// Otherwise we must also replace the offending characters with safe escape
|
||||
// sequences.
|
||||
escapable.lastIndex = 0;
|
||||
return escapable.test(string) ? '"' + string.replace(escapable, function (a) {
|
||||
var c = meta[a];
|
||||
return typeof c === 'string' ?
|
||||
c :
|
||||
'\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
|
||||
}) + '"' : '"' + string + '"';
|
||||
}
|
||||
// End
|
||||
|
||||
function internalStringify(holder, key, isTopLevel) {
|
||||
var buffer, res;
|
||||
|
||||
// Replace the value, if necessary
|
||||
var obj_part = getReplacedValueOrUndefined(holder, key, isTopLevel);
|
||||
|
||||
if (obj_part && !isDate(obj_part)) {
|
||||
// unbox objects
|
||||
// don't unbox dates, since will turn it into number
|
||||
obj_part = obj_part.valueOf();
|
||||
}
|
||||
switch(typeof obj_part) {
|
||||
case "boolean":
|
||||
return obj_part.toString();
|
||||
|
||||
case "number":
|
||||
if (isNaN(obj_part) || !isFinite(obj_part)) {
|
||||
return "null";
|
||||
}
|
||||
return obj_part.toString();
|
||||
|
||||
case "string":
|
||||
return escapeString(obj_part.toString());
|
||||
|
||||
case "object":
|
||||
if (obj_part === null) {
|
||||
return "null";
|
||||
} else if (isArray(obj_part)) {
|
||||
checkForCircular(obj_part);
|
||||
buffer = "[";
|
||||
objStack.push(obj_part);
|
||||
|
||||
for (var i = 0; i < obj_part.length; i++) {
|
||||
res = internalStringify(obj_part, i, false);
|
||||
buffer += makeIndent(indentStr, objStack.length);
|
||||
if (res === null || typeof res === "undefined") {
|
||||
buffer += "null";
|
||||
} else {
|
||||
buffer += res;
|
||||
}
|
||||
if (i < obj_part.length-1) {
|
||||
buffer += ",";
|
||||
} else if (indentStr) {
|
||||
buffer += "\n";
|
||||
}
|
||||
}
|
||||
objStack.pop();
|
||||
if (obj_part.length) {
|
||||
buffer += makeIndent(indentStr, objStack.length, true)
|
||||
}
|
||||
buffer += "]";
|
||||
} else {
|
||||
checkForCircular(obj_part);
|
||||
buffer = "{";
|
||||
var nonEmpty = false;
|
||||
objStack.push(obj_part);
|
||||
for (var prop in obj_part) {
|
||||
if (obj_part.hasOwnProperty(prop)) {
|
||||
var value = internalStringify(obj_part, prop, false);
|
||||
isTopLevel = false;
|
||||
if (typeof value !== "undefined" && value !== null) {
|
||||
buffer += makeIndent(indentStr, objStack.length);
|
||||
nonEmpty = true;
|
||||
key = isWord(prop) ? prop : escapeString(prop);
|
||||
buffer += key + ":" + (indentStr ? ' ' : '') + value + ",";
|
||||
}
|
||||
}
|
||||
}
|
||||
objStack.pop();
|
||||
if (nonEmpty) {
|
||||
buffer = buffer.substring(0, buffer.length-1) + makeIndent(indentStr, objStack.length) + "}";
|
||||
} else {
|
||||
buffer = '{}';
|
||||
}
|
||||
}
|
||||
return buffer;
|
||||
default:
|
||||
// functions and undefined should be ignored
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
// special case...when undefined is used inside of
|
||||
// a compound object/array, return null.
|
||||
// but when top-level, return undefined
|
||||
var topLevelHolder = {"":obj};
|
||||
if (obj === undefined) {
|
||||
return getReplacedValueOrUndefined(topLevelHolder, '', true);
|
||||
}
|
||||
return internalStringify(topLevelHolder, '', true);
|
||||
};
|
||||
20
node_modules/json5/lib/require.js
generated
vendored
20
node_modules/json5/lib/require.js
generated
vendored
@@ -1,18 +1,4 @@
|
||||
// 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');
|
||||
// This file is for backward compatibility with v0.5.1.
|
||||
require('./register')
|
||||
|
||||
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);
|
||||
};
|
||||
console.warn("'json5/require' is deprecated. Please use 'json5/register' instead.")
|
||||
|
||||
83
node_modules/json5/package.json
generated
vendored
83
node_modules/json5/package.json
generated
vendored
@@ -1,29 +1,27 @@
|
||||
{
|
||||
"_from": "json5@^0.5.1",
|
||||
"_id": "json5@0.5.1",
|
||||
"_from": "json5@^2.1.0",
|
||||
"_id": "json5@2.1.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-Hq3nrMASA0rYTiOWdn6tn6VJWCE=",
|
||||
"_integrity": "sha512-8Mh9h6xViijj36g7Dxi+Y4S6hNGV96vcJZr/SrlHh1LR/pEn/8j/+qIBbs44YKl69Lrfctp4QD+AdWLTMqEZAQ==",
|
||||
"_location": "/json5",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "json5@^0.5.1",
|
||||
"raw": "json5@^2.1.0",
|
||||
"name": "json5",
|
||||
"escapedName": "json5",
|
||||
"rawSpec": "^0.5.1",
|
||||
"rawSpec": "^2.1.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^0.5.1"
|
||||
"fetchSpec": "^2.1.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/babel-core",
|
||||
"/loader-utils",
|
||||
"/webpack"
|
||||
"/@babel/core"
|
||||
],
|
||||
"_resolved": "http://registry.npmjs.org/json5/-/json5-0.5.1.tgz",
|
||||
"_shasum": "1eade7acc012034ad84e2396767ead9fa5495821",
|
||||
"_spec": "json5@^0.5.1",
|
||||
"_where": "C:\\xampp\\htdocs\\w4rpservices\\node_modules\\babel-core",
|
||||
"_resolved": "https://registry.npmjs.org/json5/-/json5-2.1.0.tgz",
|
||||
"_shasum": "e7a0c62c48285c628d20a10b85c89bb807c32850",
|
||||
"_spec": "json5@^2.1.0",
|
||||
"_where": "C:\\xampp\\htdocs\\w4rpservices\\node_modules\\@babel\\core",
|
||||
"author": {
|
||||
"name": "Aseem Kishore",
|
||||
"email": "aseem.kishore@gmail.com"
|
||||
@@ -31,8 +29,9 @@
|
||||
"bin": {
|
||||
"json5": "lib/cli.js"
|
||||
},
|
||||
"browser": "dist/index.js",
|
||||
"bugs": {
|
||||
"url": "https://github.com/aseemk/json5/issues"
|
||||
"url": "https://github.com/json5/json5/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"contributors": [
|
||||
@@ -49,34 +48,62 @@
|
||||
"email": "jordanbtucker@gmail.com"
|
||||
}
|
||||
],
|
||||
"dependencies": {},
|
||||
"dependencies": {
|
||||
"minimist": "^1.2.0"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "JSON for the ES5 era.",
|
||||
"description": "JSON for humans.",
|
||||
"devDependencies": {
|
||||
"gulp": "^3.9.1",
|
||||
"gulp-jshint": "^2.0.1",
|
||||
"jshint": "^2.9.3",
|
||||
"jshint-stylish": "^2.2.1",
|
||||
"mocha": "^3.1.0"
|
||||
"core-js": "^2.5.7",
|
||||
"eslint": "^5.3.0",
|
||||
"eslint-config-standard": "^11.0.0",
|
||||
"eslint-plugin-import": "^2.14.0",
|
||||
"eslint-plugin-node": "^7.0.1",
|
||||
"eslint-plugin-promise": "^3.8.0",
|
||||
"eslint-plugin-standard": "^3.1.0",
|
||||
"regenerate": "^1.4.0",
|
||||
"rollup": "^0.64.1",
|
||||
"rollup-plugin-buble": "^0.19.2",
|
||||
"rollup-plugin-commonjs": "^9.1.5",
|
||||
"rollup-plugin-node-resolve": "^3.3.0",
|
||||
"rollup-plugin-terser": "^1.0.1",
|
||||
"sinon": "^6.1.5",
|
||||
"tap": "^12.0.1",
|
||||
"unicode-10.0.0": "^0.7.5"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
},
|
||||
"files": [
|
||||
"lib/"
|
||||
"lib/",
|
||||
"dist/"
|
||||
],
|
||||
"homepage": "http://json5.org/",
|
||||
"keywords": [
|
||||
"json",
|
||||
"es5"
|
||||
"json5",
|
||||
"es5",
|
||||
"es2015",
|
||||
"ecmascript"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "lib/json5.js",
|
||||
"main": "lib/index.js",
|
||||
"name": "json5",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/aseemk/json5.git"
|
||||
"url": "git+https://github.com/json5/json5.git"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "node ./lib/cli.js -c package.json5",
|
||||
"test": "mocha --ui exports --reporter spec"
|
||||
"build": "rollup -c",
|
||||
"build-package": "node build/package.js",
|
||||
"build-unicode": "node build/unicode.js",
|
||||
"coverage": "tap --coverage-report html test",
|
||||
"lint": "eslint --fix .",
|
||||
"prepublishOnly": "npm run production",
|
||||
"preversion": "npm run production",
|
||||
"production": "npm run lint && npm test && npm run build",
|
||||
"test": "tap -Rspec --100 test",
|
||||
"version": "npm run build-package && git add package.json5"
|
||||
},
|
||||
"version": "0.5.1"
|
||||
"version": "2.1.0"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user