flow like the river
This commit is contained in:
commit
013fe673f3
42435 changed files with 5764238 additions and 0 deletions
278
BACK_BACK/node_modules/@iarna/toml/CHANGELOG.md
generated
vendored
Executable file
278
BACK_BACK/node_modules/@iarna/toml/CHANGELOG.md
generated
vendored
Executable file
|
|
@ -0,0 +1,278 @@
|
|||
# 2.2.5
|
||||
|
||||
* Docs: Updated benchmark results. Add fast-toml to result list. Improved benchmark layout.
|
||||
* Update @sgarciac/bombadil and @ltd/j-toml in benchmarks and compliance tests.
|
||||
* Dev: Some dev dep updates that shouldn't have any impact.
|
||||
|
||||
# 2.2.4
|
||||
|
||||
* Bug fix: Plain date literals (not datetime) immediately followed by another statement (no whitespace or blank line) would crash. Fixes [#19](https://github.com/iarna/iarna-toml/issues/19) and [#23](https://github.com/iarna/iarna-toml/issues/23), thank you [@arnau](https://github.com/arnau) and [@jschaf](https://github.com/jschaf) for reporting this!
|
||||
* Bug fix: Hex literals with lowercase Es would throw errors. (Thank you [@DaeCatt](https://github.com/DaeCatt) for this fix!) Fixed [#20](https://github.com/iarna/iarna-toml/issues/20)
|
||||
* Some minor doc tweaks
|
||||
* Added Node 12 and 13 to Travis. (Node 6 is failing there now, mysteriously. It works on my machine™, shipping anyway. 🙃)
|
||||
|
||||
# 2.2.3
|
||||
|
||||
This release just updates the spec compliance tests and benchmark data to
|
||||
better represent @ltd/j-toml.
|
||||
|
||||
# 2.2.2
|
||||
|
||||
## Fixes
|
||||
|
||||
* Support parsing and stringifying objects with `__proto__` properties. ([@LongTengDao](https://github.com/LongTengDao))
|
||||
|
||||
## Misc
|
||||
|
||||
* Updates for spec compliance and benchmarking:
|
||||
* @sgarciac/bombadil -> 2.1.0
|
||||
* toml -> 3.0.0
|
||||
* Added spec compliance and benchmarking for:
|
||||
* @ltd/j-toml
|
||||
|
||||
# 2.2.1
|
||||
|
||||
## Fixes
|
||||
|
||||
* Fix bug where keys with names matching javascript Object methods would
|
||||
error. Thanks [@LongTengDao](https://github.com/LongTengDao) for finding this!
|
||||
* Fix bug where a bundled version would fail if `util.inspect` wasn't
|
||||
provided. This was supposed to be guarded against, but there was a bug in
|
||||
the guard. Thanks [@agriffis](https://github.com/agriffis) for finding and fixing this!
|
||||
|
||||
## Misc
|
||||
|
||||
* Update the version of bombadil for spec compliance and benchmarking purposes to 2.0.0
|
||||
|
||||
## Did you know?
|
||||
|
||||
Node 6 and 8 are measurably slower than Node 6, 10 and 11, at least when it comes to parsing TOML!
|
||||
|
||||

|
||||
|
||||
# 2.2.0
|
||||
|
||||
## Features
|
||||
|
||||
* Typescript: Lots of improvements to our type definitions, many many to
|
||||
[@jorgegonzalez](https://github.com/jorgegonzalez) and [@momocow](https://github.com/momocow) for working through these.
|
||||
|
||||
## Fixes
|
||||
|
||||
* Very large integers (>52bit) are stored as BigInts on runtimes that
|
||||
support them. BigInts are 128bits, but the TOML spec limits its integers
|
||||
to 64bits. We now limit our integers to 64bits
|
||||
as well.
|
||||
* Fix a bug in stringify where control characters were being emitted as unicode chars and not escape sequences.
|
||||
|
||||
## Misc
|
||||
|
||||
* Moved our spec tests out to an external repo
|
||||
* Improved the styling of the spec compliance comparison
|
||||
|
||||
# 2.1.1
|
||||
|
||||
## Fixes
|
||||
|
||||
* Oops, type defs didn't end up in the tarball, ty [@jorgegonzalez](https://github.com/jorgegonzalez)‼
|
||||
|
||||
# 2.1.0
|
||||
|
||||
## Features
|
||||
|
||||
* Types for typescript support, thank you [@momocow](https://github.com/momocow)!
|
||||
|
||||
## Fixes
|
||||
|
||||
* stringify: always strip invalid dates. This fixes a bug where an
|
||||
invalid date in an inline array would not be removed and would instead
|
||||
result in an error.
|
||||
* stringify: if an invalid type is found make sure it's thrown as an
|
||||
error object. Previously the type name was, unhelpfully, being thrown.
|
||||
* stringify: Multiline strings ending in a quote would generate invalid TOML.
|
||||
* parse: Error if a signed integer has a leading zero, eg, `-01` or `+01`.
|
||||
* parse: Error if \_ appears at the end of the integer part of a float, eg `1_.0`. \_ is only valid between _digits_.
|
||||
|
||||
## Fun
|
||||
|
||||
* BurntSushi's comprehensive TOML 0.4.0 test suite is now used in addition to our existing test suite.
|
||||
* You can see exactly how the other JS TOML libraries stack up in testing
|
||||
against both BurntSushi's tests and my own in the new
|
||||
[TOML-SPEC-SUPPORT](TOML-SPEC-SUPPORT.md) doc.
|
||||
|
||||
# 2.0.0
|
||||
|
||||
With 2.0.0, @iarna/toml supports the TOML v0.5.0 specification. TOML 0.5.0
|
||||
brings some changes:
|
||||
|
||||
* Delete characters (U+007F) are not allowed in plain strings. You can include them with
|
||||
escaped unicode characters, eg `\u007f`.
|
||||
* Integers are specified as being 64bit unsigned values. These are
|
||||
supported using `BigInt`s if you are using Node 10 or later.
|
||||
* Keys may be literal strings, that is, you can use single quoted strings to
|
||||
quote key names, so the following is now valid:
|
||||
'a"b"c' = 123
|
||||
* The floating point values `nan`, `inf` and `-inf` are supported. The stringifier will no
|
||||
longer strip NaN, Infinity and -Infinity, instead serializing them as these new values..
|
||||
* Datetimes can separate the date and time with a space instead of a T, so
|
||||
`2017-12-01T00:00:00Z` can be written as `2017-12-01 00:00:00Z`.
|
||||
* Datetimes can be floating, that is, they can be represented without a timezone.
|
||||
These are represented in javascript as Date objects whose `isFloating` property is true and
|
||||
whose `toISOString` method will return a representation without a timezone.
|
||||
* Dates without times are now supported. Dates do not have timezones. Dates
|
||||
are represented in javascript as a Date object whose `isDate` property is true and
|
||||
whose `toISOString` method returns just the date.
|
||||
* Times without dates are now supported. Times do not have timezones. Times
|
||||
are represented in javascript as a Date object whose `isTime` property is true and
|
||||
whose `toISOString` method returns just the time.
|
||||
* Keys can now include dots to directly address deeper structures, so `a.b = 23` is
|
||||
the equivalent of `a = {b = 23}` or ```[a]
|
||||
b = 23```. These can be used both as keys to regular tables and inline tables.
|
||||
* Integers can now be specified in binary, octal and hexadecimal by prefixing the
|
||||
number with `0b`, `0o` and `0x` respectively. It is now illegal to left
|
||||
pad a decimal value with zeros.
|
||||
|
||||
Some parser details were also fixed:
|
||||
|
||||
* Negative zero (`-0.0`) and positive zero (`0.0`) are distinct floating point values.
|
||||
* Negative integer zero (`-0`) is not distinguished from positive zero (`0`).
|
||||
|
||||
# 1.7.1
|
||||
|
||||
Another 18% speed boost on our overall benchmarks! This time it came from
|
||||
switching from string comparisons to integer by converting each character to
|
||||
its respective code point. This also necessitated rewriting the boolean
|
||||
parser to actually parse character-by-character as it should. End-of-stream
|
||||
is now marked with a numeric value outside of the Unicode range, rather than
|
||||
a Symbol, meaning that the parser's char property is now monomorphic.
|
||||
|
||||
Bug fix, previously, `'abc''def'''` was accepted (as the value: `abcdef`).
|
||||
Now it will correctly raise an error.
|
||||
|
||||
Spec tests now run against bombadil as well (it fails some, which is unsurprising
|
||||
given its incomplete state).
|
||||
|
||||
# 1.7.0
|
||||
|
||||
This release features an overall 15% speed boost on our benchmarks. This
|
||||
came from a few things:
|
||||
|
||||
* Date parsing was rewritten to not use regexps, resulting in a huge speed increase.
|
||||
* Strings of all kinds and bare keywords now use tight loops to collect characters when this will help.
|
||||
* Regexps in general were mostly removed. This didn't result in a speed
|
||||
change, but it did allow refactoring the parser to be a lot easier to
|
||||
follow.
|
||||
* The internal state tracking now uses a class and is constructed with a
|
||||
fixed set of properties, allowing v8's optimizer to be more effective.
|
||||
|
||||
In the land of new features:
|
||||
|
||||
* Errors in the syntax of your TOML will now have the `fromTOML` property
|
||||
set to true. This is in addition to the `line`, `col` and `pos`
|
||||
properties they already have.
|
||||
|
||||
The main use of this is to make it possible to distinguish between errors
|
||||
in the TOML and errors in the parser code itself. This is of particular utility
|
||||
when testing parse errors.
|
||||
|
||||
# 1.6.0
|
||||
|
||||
**FIXES**
|
||||
|
||||
* TOML.stringify: Allow toJSON properties that aren't functions, to align with JSON.stringify's behavior.
|
||||
* TOML.stringify: Don't use ever render keys as literal strings.
|
||||
* TOML.stringify: Don't try to escape control characters in literal strings.
|
||||
|
||||
**FEATURES**
|
||||
|
||||
* New Export: TOML.stringify.value, for encoding a stand alone inline value as TOML would. This produces
|
||||
a TOML fragment, not a complete valid document.
|
||||
|
||||
# 1.5.6
|
||||
|
||||
* String literals are NOT supported as key names.
|
||||
* Accessing a shallower table after accessing it more deeply is ok and no longer crashes, eg:
|
||||
```toml
|
||||
[a.b]
|
||||
[a]
|
||||
```
|
||||
* Unicode characters in the reserved range now crash.
|
||||
* Empty bare keys, eg `[.abc]` or `[]` now crash.
|
||||
* Multiline backslash trimming supports CRs.
|
||||
* Multiline post quote trimming supports CRs.
|
||||
* Strings may not contain bare control chars (0x00-0x1f), except for \n, \r and \t.
|
||||
|
||||
# 1.5.5
|
||||
|
||||
* Yet MORE README fixes. 🙃
|
||||
|
||||
# 1.5.4
|
||||
|
||||
* README fix
|
||||
|
||||
# 1.5.3
|
||||
|
||||
* Benchmarks!
|
||||
* More tests!
|
||||
* More complete LICENSE information (some dev files are from other, MIT
|
||||
licensed, projects, this is now more explicitly documented.)
|
||||
|
||||
# 1.5.2
|
||||
|
||||
* parse: Arrays with mixed types now throw errors, per the spec.
|
||||
* parse: Fix a parser bug that would result in errors when trying to parse arrays of numbers or dates
|
||||
that were not separated by a space from the closing ].
|
||||
* parse: Fix a bug in the error pretty printer that resulted in errors on
|
||||
the first line not getting the pretty print treatment.
|
||||
* stringify: Fix long standing bug where an array of Numbers, some of which required
|
||||
decimals, would be emitted in a way that parsers would treat as mixed
|
||||
Integer and Float values. Now if any Numbers in an array must be
|
||||
represented with a decimal then all will be emitted such that parsers will
|
||||
understand them to be Float.
|
||||
|
||||
# 1.5.1
|
||||
|
||||
* README fix
|
||||
|
||||
# 1.5.0
|
||||
|
||||
* A brand new TOML parser, from scratch, that performs like `toml-j0.4`
|
||||
without the crashes and with vastly better error messages.
|
||||
* 100% test coverage for both the new parser and the existing stringifier. Some subtle bugs squashed!
|
||||
|
||||
# v1.4.2
|
||||
|
||||
* Revert fallback due to its having issues with the same files. (New plan
|
||||
will be to write my own.)
|
||||
|
||||
# v1.4.1
|
||||
|
||||
* Depend on both `toml` and `toml-j0.4` with fallback from the latter to the
|
||||
former when the latter crashes.
|
||||
|
||||
# v1.4.0
|
||||
|
||||
* Ducktype dates to make them compatible with `moment` and other `Date` replacements.
|
||||
|
||||
# v1.3.1
|
||||
|
||||
* Update docs with new toml module.
|
||||
|
||||
# v1.3.0
|
||||
|
||||
* Switch from `toml` to `toml-j0.4`, which is between 20x and 200x faster.
|
||||
(The larger the input, the faster it is compared to `toml`).
|
||||
|
||||
# v1.2.0
|
||||
|
||||
* Return null when passed in null as the top level object.
|
||||
* Detect and skip invalid dates and numbers
|
||||
|
||||
# v1.1.0
|
||||
|
||||
* toJSON transformations are now honored (for everything except Date objects, as JSON represents them as strings).
|
||||
* Undefined/null values no longer result in exceptions, they now just result in the associated key being elided.
|
||||
|
||||
# v1.0.1
|
||||
|
||||
* Initial release
|
||||
14
BACK_BACK/node_modules/@iarna/toml/LICENSE
generated
vendored
Executable file
14
BACK_BACK/node_modules/@iarna/toml/LICENSE
generated
vendored
Executable file
|
|
@ -0,0 +1,14 @@
|
|||
Copyright (c) 2016, Rebecca Turner <me@re-becca.org>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
301
BACK_BACK/node_modules/@iarna/toml/README.md
generated
vendored
Executable file
301
BACK_BACK/node_modules/@iarna/toml/README.md
generated
vendored
Executable file
|
|
@ -0,0 +1,301 @@
|
|||
# @iarna/toml
|
||||
|
||||
Better TOML parsing and stringifying all in that familiar JSON interface.
|
||||
|
||||
[](https://coveralls.io/github/iarna/iarna-toml)
|
||||
|
||||
# ** TOML 0.5.0 **
|
||||
|
||||
### TOML Spec Support
|
||||
|
||||
The most recent version as of 2018-07-26: [v0.5.0](https://github.com/mojombo/toml/blob/master/versions/en/toml-v0.5.0.md)
|
||||
|
||||
### Example
|
||||
|
||||
```js
|
||||
const TOML = require('@iarna/toml')
|
||||
const obj = TOML.parse(`[abc]
|
||||
foo = 123
|
||||
bar = [1,2,3]`)
|
||||
/* obj =
|
||||
{abc: {foo: 123, bar: [1,2,3]}}
|
||||
*/
|
||||
const str = TOML.stringify(obj)
|
||||
/* str =
|
||||
[abc]
|
||||
foo = 123
|
||||
bar = [ 1, 2, 3 ]
|
||||
*/
|
||||
```
|
||||
|
||||
Visit the project github [for more examples](https://github.com/iarna/iarna-toml/tree/latest/examples)!
|
||||
|
||||
|
||||
## Why @iarna/toml
|
||||
|
||||
* See [TOML-SPEC-SUPPORT](https://shared.by.re-becca.org/misc/TOML-SPEC-SUPPORT.html)
|
||||
for a comparison of which TOML features are supported by the various
|
||||
Node.js TOML parsers.
|
||||
* BigInt support on Node 10!
|
||||
* 100% test coverage.
|
||||
* Fast parsing. It's as much as 100 times
|
||||
faster than `toml` and 3 times faster than `toml-j0.4`. However a recent
|
||||
newcomer [`@ltd/j-toml`](https://www.npmjs.com/package/@ltd/j-toml) has
|
||||
appeared with 0.5 support and astoundingly fast parsing speeds for large
|
||||
text blocks. All I can say is you'll have to test your specific work loads
|
||||
if you want to know which of @iarna/toml and @ltd/j-toml is faster for
|
||||
you, as we currently excell in different areas.
|
||||
* Careful adherence to spec. Tests go beyond simple coverage.
|
||||
* Smallest parser bundle (if you use `@iarna/toml/parse-string`).
|
||||
* No deps.
|
||||
* Detailed and easy to read error messages‼
|
||||
|
||||
```console
|
||||
> TOML.parse(src)
|
||||
Error: Unexpected character, expecting string, number, datetime, boolean, inline array or inline table at row 6, col 5, pos 87:
|
||||
5: "abc\"" = { abc=123,def="abc" }
|
||||
6> foo=sdkfj
|
||||
^
|
||||
7:
|
||||
```
|
||||
|
||||
## TOML.parse(str) → Object [(example)](https://github.com/iarna/iarna-toml/blob/latest/examples/parse.js)
|
||||
|
||||
Also available with: `require('@iarna/toml/parse-string')`
|
||||
|
||||
Synchronously parse a TOML string and return an object.
|
||||
|
||||
|
||||
## TOML.stringify(obj) → String [(example)](https://github.com/iarna/iarna-toml/blob/latest/examples/stringify.js)
|
||||
|
||||
Also available with: `require('@iarna/toml/stringify)`
|
||||
|
||||
Serialize an object as TOML.
|
||||
|
||||
## [your-object].toJSON
|
||||
|
||||
If an object `TOML.stringify` is serializing has a `toJSON` method then it
|
||||
will call it to transform the object before serializing it. This matches
|
||||
the behavior of `JSON.stringify`.
|
||||
|
||||
The one exception to this is that `toJSON` is not called for `Date` objects
|
||||
because `JSON` represents dates as strings and TOML can represent them natively.
|
||||
|
||||
[`moment`](https://www.npmjs.com/package/moment) objects are treated the
|
||||
same as native `Date` objects, in this respect.
|
||||
|
||||
## TOML.stringify.value(obj) -> String
|
||||
|
||||
Also available with: `require('@iarna/toml/stringify').value`
|
||||
|
||||
Serialize a value as TOML would. This is a fragment and not a complete
|
||||
valid TOML document.
|
||||
|
||||
## Promises and Streaming
|
||||
|
||||
The parser provides alternative async and streaming interfaces, for times
|
||||
that you're working with really absurdly big TOML files and don't want to
|
||||
tie-up the event loop while it parses.
|
||||
|
||||
### TOML.parse.async(str[, opts]) → Promise(Object) [(example)](https://github.com/iarna/iarna-toml/blob/latest/examples/parse-async.js)
|
||||
|
||||
Also available with: `require('@iarna/toml/parse-async')`
|
||||
|
||||
`opts.blocksize` is the amount text to parser per pass through the event loop. Defaults to 40kb.
|
||||
|
||||
Asynchronously parse a TOML string and return a promise of the resulting object.
|
||||
|
||||
### TOML.parse.stream(readable) → Promise(Object) [(example)](https://github.com/iarna/iarna-toml/blob/latest/examples/parse-stream-readable.js)
|
||||
|
||||
Also available with: `require('@iarna/toml/parse-stream')`
|
||||
|
||||
Given a readable stream, parse it as it feeds us data. Return a promise of the resulting object.
|
||||
|
||||
### readable.pipe(TOML.parse.stream()) → Transform [(example)](https://github.com/iarna/iarna-toml/blob/latest/examples/parse-stream-through.js)
|
||||
|
||||
Also available with: `require('@iarna/toml/parse-stream')`
|
||||
|
||||
Returns a transform stream in object mode. When it completes, emit the
|
||||
resulting object. Only one object will ever be emitted.
|
||||
|
||||
## Lowlevel Interface [(example)](https://github.com/iarna/iarna-toml/blob/latest/examples/parse-lowlevel.js) [(example w/ parser debugging)](https://github.com/iarna/iarna-toml/blob/latest/examples/parse-lowlevel-debug.js)
|
||||
|
||||
You construct a parser object, per TOML file you want to process:
|
||||
|
||||
```js
|
||||
const TOMLParser = require('@iarna/toml/lib/toml-parser.js')
|
||||
const parser = new TOMLParser()
|
||||
```
|
||||
|
||||
Then you call the `parse` method for each chunk as you read them, or in a
|
||||
single call:
|
||||
|
||||
```js
|
||||
parser.parse(`hello = 'world'`)
|
||||
```
|
||||
|
||||
And finally, you call the `finish` method to complete parsing and retrieve
|
||||
the resulting object.
|
||||
|
||||
```js
|
||||
const data = parser.finish()
|
||||
```
|
||||
|
||||
Both the `parse` method and `finish` method will throw if they find a
|
||||
problem with the string they were given. Error objects thrown from the
|
||||
parser have `pos`, `line` and `col` attributes. `TOML.parse` adds a visual
|
||||
summary of where in the source string there were issues using
|
||||
`parse-pretty-error` and you can too:
|
||||
|
||||
```js
|
||||
const prettyError = require('./parse-pretty-error.js')
|
||||
const newErr = prettyError(err, sourceString)
|
||||
```
|
||||
|
||||
## What's Different
|
||||
|
||||
Version 2 of this module supports TOML 0.5.0. Other modules currently
|
||||
published to the npm registry support 0.4.0. 0.5.0 is mostly backwards
|
||||
compatible with 0.4.0, but if you have need, you can install @iarna/toml@1
|
||||
to get a version of this module that supports 0.4.0. Please see the
|
||||
[CHANGELOG](CHANGELOG.md#2.0.0) for details on exactly whats changed.
|
||||
|
||||
## TOML we can't do
|
||||
|
||||
* `-nan` is a valid TOML value and is converted into `NaN`. There is no way to
|
||||
produce `-nan` when stringifying. Stringification will produce positive `nan`.
|
||||
* Detecting and erroring on invalid utf8 documents: This is because Node's
|
||||
UTF8 processing converts invalid sequences into the placeholder character
|
||||
and does not have facilities for reporting these as errors instead. We
|
||||
_can_ detect the placeholder character, but it's valid to intentionally
|
||||
include them in documents, so erroring on them is not great.
|
||||
* On versions of Node < 10, very large Integer values will lose precision.
|
||||
On Node >=10, bigints are used.
|
||||
* Floating/local dates and times are still represented by JavaScript Date
|
||||
objects, which don't actually support these concepts. The objects
|
||||
returned have been modified so that you can determine what kind of thing
|
||||
they are (with `isFloating`, `isDate`, `isTime` properties) and that
|
||||
their ISO representation (via `toISOString`) is representative of their
|
||||
TOML value. They will correctly round trip if you pass them to
|
||||
`TOML.stringify`.
|
||||
* Binary, hexadecimal and octal values are converted to ordinary integers and
|
||||
will be decimal if you stringify them.
|
||||
|
||||
## Changes
|
||||
|
||||
I write a by hand, honest-to-god,
|
||||
[CHANGELOG](https://github.com/iarna/iarna-toml/blob/latest/CHANGELOG.md)
|
||||
for this project. It's a description of what went into a release that you
|
||||
the consumer of the module could care about, not a list of git commits, so
|
||||
please check it out!
|
||||
|
||||
## Benchmarks
|
||||
|
||||
You can run them yourself with:
|
||||
|
||||
```console
|
||||
$ npm run benchmark
|
||||
```
|
||||
|
||||
The results below are from my desktop using Node 13.13.0. The library
|
||||
versions tested were `@iarna/toml@2.2.4`, `toml-j0.4@1.1.1`, `toml@3.0.0`,
|
||||
`@sgarciac/bombadil@2.3.0`, `@ltd/j-toml@0.5.107`, and `fast-toml@0.5.4`. The speed value is
|
||||
megabytes-per-second that the parser can process of that document type.
|
||||
Bigger is better. The percentage after average results is the margin of error.
|
||||
|
||||
New here is fast-toml. fast-toml is very fast, for some datatypes, but it
|
||||
also is missing most error checking demanded by the spec. For 0.4, it is
|
||||
complete except for detail of multiline strings caught by the compliance
|
||||
tests. Its support for 0.5 is incomplete. Check out the
|
||||
[spec compliance](https://shared.by.re-becca.org/misc/TOML-SPEC-SUPPORT.html) doc
|
||||
for details.
|
||||
|
||||
As this table is getting a little wide, with how npm and github display it,
|
||||
you can also view it seperately in the
|
||||
[BENCHMARK](https://shared.by.re-becca.org/misc/BENCHMARK.html) document.
|
||||
|
||||
| | @iarna/<wbr>toml | toml-j0.4 | toml | @sgarciac/<wbr>bombadil | @ltd/<wbr>j-toml | fast-toml |
|
||||
| - | :---------: | :-------: | :--: | :----------------: | :---------: | :-------: |
|
||||
| **Overall** | 28MB/sec<br><small>0.35%</small> | 6.5MB/sec<br><small>0.25%</small> | 0.2MB/sec<br><small>0.70%</small> | - | 35MB/sec<br><small>0.23%</small> | - |
|
||||
| **Spec Example: v0.4.0** | 26MB/sec<br><small>0.37%</small> | 10MB/sec<br><small>0.27%</small> | 1MB/sec<br><small>0.42%</small> | 1.2MB/sec<br><small>0.95%</small> | 28MB/sec<br><small>0.31%</small> | - |
|
||||
| **Spec Example: Hard Unicode** | 64MB/sec<br><small>0.59%</small> | 18MB/sec<br><small>0.12%</small> | 2MB/sec<br><small>0.20%</small> | 0.6MB/sec<br><small>0.53%</small> | 68MB/sec<br><small>0.31%</small> | 78MB/sec<br><small>0.28%</small> |
|
||||
| **Types: Array, Inline** | 7.3MB/sec<br><small>0.60%</small> | 4MB/sec<br><small>0.16%</small> | 0.1MB/sec<br><small>0.91%</small> | 1.3MB/sec<br><small>0.81%</small> | 10MB/sec<br><small>0.35%</small> | 9MB/sec<br><small>0.16%</small> |
|
||||
| **Types: Array** | 6.8MB/sec<br><small>0.19%</small> | 6.7MB/sec<br><small>0.15%</small> | 0.2MB/sec<br><small>0.79%</small> | 1.2MB/sec<br><small>0.93%</small> | 8.8MB/sec<br><small>0.47%</small> | 27MB/sec<br><small>0.21%</small> |
|
||||
| **Types: Boolean,** | 21MB/sec<br><small>0.20%</small> | 9.4MB/sec<br><small>0.17%</small> | 0.2MB/sec<br><small>0.96%</small> | 1.8MB/sec<br><small>0.70%</small> | 16MB/sec<br><small>0.20%</small> | 8.4MB/sec<br><small>0.22%</small> |
|
||||
| **Types: Datetime** | 18MB/sec<br><small>0.14%</small> | 11MB/sec<br><small>0.15%</small> | 0.3MB/sec<br><small>0.85%</small> | 1.6MB/sec<br><small>0.45%</small> | 9.8MB/sec<br><small>0.48%</small> | 6.5MB/sec<br><small>0.23%</small> |
|
||||
| **Types: Float** | 8.8MB/sec<br><small>0.09%</small> | 5.9MB/sec<br><small>0.14%</small> | 0.2MB/sec<br><small>0.51%</small> | 2.1MB/sec<br><small>0.82%</small> | 14MB/sec<br><small>0.15%</small> | 7.9MB/sec<br><small>0.14%</small> |
|
||||
| **Types: Int** | 5.9MB/sec<br><small>0.11%</small> | 4.5MB/sec<br><small>0.28%</small> | 0.1MB/sec<br><small>0.78%</small> | 1.5MB/sec<br><small>0.64%</small> | 10MB/sec<br><small>0.14%</small> | 8MB/sec<br><small>0.17%</small> |
|
||||
| **Types: Literal String, 7 char** | 26MB/sec<br><small>0.29%</small> | 8.5MB/sec<br><small>0.32%</small> | 0.3MB/sec<br><small>0.84%</small> | 2.3MB/sec<br><small>1.02%</small> | 23MB/sec<br><small>0.15%</small> | 13MB/sec<br><small>0.15%</small> |
|
||||
| **Types: Literal String, 92 char** | 46MB/sec<br><small>0.19%</small> | 11MB/sec<br><small>0.20%</small> | 0.3MB/sec<br><small>0.56%</small> | 12MB/sec<br><small>0.92%</small> | 101MB/sec<br><small>0.17%</small> | 75MB/sec<br><small>0.29%</small> |
|
||||
| **Types: Literal String, Multiline, 1079 char** | 22MB/sec<br><small>0.42%</small> | 6.7MB/sec<br><small>0.55%</small> | 0.9MB/sec<br><small>0.78%</small> | 44MB/sec<br><small>1.00%</small> | 350MB/sec<br><small>0.16%</small> | 636MB/sec<br><small>0.16%</small> |
|
||||
| **Types: Basic String, 7 char** | 25MB/sec<br><small>0.15%</small> | 7.3MB/sec<br><small>0.18%</small> | 0.2MB/sec<br><small>0.96%</small> | 2.2MB/sec<br><small>1.09%</small> | 14MB/sec<br><small>0.16%</small> | 12MB/sec<br><small>0.22%</small> |
|
||||
| **Types: Basic String, 92 char** | 43MB/sec<br><small>0.30%</small> | 7.2MB/sec<br><small>0.16%</small> | 0.1MB/sec<br><small>4.04%</small> | 12MB/sec<br><small>1.33%</small> | 71MB/sec<br><small>0.19%</small> | 70MB/sec<br><small>0.23%</small> |
|
||||
| **Types: Basic String, 1079 char** | 24MB/sec<br><small>0.45%</small> | 5.8MB/sec<br><small>0.17%</small> | 0.1MB/sec<br><small>3.64%</small> | 44MB/sec<br><small>1.05%</small> | 93MB/sec<br><small>0.29%</small> | 635MB/sec<br><small>0.28%</small> |
|
||||
| **Types: Table, Inline** | 9.7MB/sec<br><small>0.10%</small> | 5.5MB/sec<br><small>0.22%</small> | 0.1MB/sec<br><small>0.87%</small> | 1.4MB/sec<br><small>1.18%</small> | 8.7MB/sec<br><small>0.60%</small> | 8.7MB/sec<br><small>0.22%</small> |
|
||||
| **Types: Table** | 7.1MB/sec<br><small>0.14%</small> | 5.6MB/sec<br><small>0.42%</small> | 0.1MB/sec<br><small>0.65%</small> | 1.4MB/sec<br><small>1.11%</small> | 7.4MB/sec<br><small>0.70%</small> | 18MB/sec<br><small>0.20%</small> |
|
||||
| **Scaling: Array, Inline, 1000 elements** | 40MB/sec<br><small>0.21%</small> | 2.4MB/sec<br><small>0.19%</small> | 0.1MB/sec<br><small>0.35%</small> | 1.6MB/sec<br><small>1.02%</small> | 17MB/sec<br><small>0.15%</small> | 32MB/sec<br><small>0.16%</small> |
|
||||
| **Scaling: Array, Nested, 1000 deep** | 2MB/sec<br><small>0.15%</small> | 1.7MB/sec<br><small>0.26%</small> | 0.3MB/sec<br><small>0.58%</small> | - | 1.8MB/sec<br><small>0.74%</small> | 13MB/sec<br><small>0.20%</small> |
|
||||
| **Scaling: Literal String, 40kb** | 61MB/sec<br><small>0.18%</small> | 10MB/sec<br><small>0.15%</small> | 3MB/sec<br><small>0.84%</small> | 12MB/sec<br><small>0.51%</small> | 551MB/sec<br><small>0.44%</small> | 19kMB/sec<br><small>0.19%</small> |
|
||||
| **Scaling: Literal String, Multiline, 40kb** | 62MB/sec<br><small>0.16%</small> | 5MB/sec<br><small>0.45%</small> | 0.2MB/sec<br><small>1.70%</small> | 11MB/sec<br><small>0.74%</small> | 291MB/sec<br><small>0.24%</small> | 21kMB/sec<br><small>0.22%</small> |
|
||||
| **Scaling: Basic String, Multiline, 40kb** | 62MB/sec<br><small>0.18%</small> | 5.8MB/sec<br><small>0.38%</small> | 2.9MB/sec<br><small>0.86%</small> | 11MB/sec<br><small>0.41%</small> | 949MB/sec<br><small>0.44%</small> | 26kMB/sec<br><small>0.16%</small> |
|
||||
| **Scaling: Basic String, 40kb** | 59MB/sec<br><small>0.20%</small> | 6.3MB/sec<br><small>0.17%</small> | 0.2MB/sec<br><small>1.95%</small> | 12MB/sec<br><small>0.44%</small> | 508MB/sec<br><small>0.35%</small> | 18kMB/sec<br><small>0.15%</small> |
|
||||
| **Scaling: Table, Inline, 1000 elements** | 28MB/sec<br><small>0.12%</small> | 8.2MB/sec<br><small>0.19%</small> | 0.3MB/sec<br><small>0.89%</small> | 2.3MB/sec<br><small>1.14%</small> | 5.3MB/sec<br><small>0.24%</small> | 13MB/sec<br><small>0.20%</small> |
|
||||
| **Scaling: Table, Inline, Nested, 1000 deep** | 7.8MB/sec<br><small>0.28%</small> | 5MB/sec<br><small>0.20%</small> | 0.1MB/sec<br><small>0.84%</small> | - | 3.2MB/sec<br><small>0.52%</small> | 10MB/sec<br><small>0.23%</small> |
|
||||
|
||||
## Tests
|
||||
|
||||
The test suite is maintained at 100% coverage: [](https://coveralls.io/github/iarna/iarna-toml)
|
||||
|
||||
The spec was carefully hand converted into a series of test framework
|
||||
independent (and mostly language independent) assertions, as pairs of TOML
|
||||
and YAML files. You can find those files here:
|
||||
[spec-test](https://github.com/iarna/iarna-toml/blob/latest/test/spec-test/).
|
||||
A number of examples of invalid Unicode were also written, but are difficult
|
||||
to make use of in Node.js where Unicode errors are silently hidden. You can
|
||||
find those here: [spec-test-disabled](https://github.com/iarna/iarna-toml/blob/latest/test/spec-test-disabled/).
|
||||
|
||||
Further tests were written to increase coverage to 100%, these may be more
|
||||
implementation specific, but they can be found in [coverage](https://github.com/iarna/iarna-toml/blob/latest/test/coverage.js) and
|
||||
[coverage-error](https://github.com/iarna/iarna-toml/blob/latest/test/coverage-error.js).
|
||||
|
||||
I've also written some quality assurance style tests, which don't contribute
|
||||
to coverage but do cover scenarios that could easily be problematic for some
|
||||
implementations can be found in:
|
||||
[test/qa.js](https://github.com/iarna/iarna-toml/blob/latest/test/qa.js) and
|
||||
[test/qa-error.js](https://github.com/iarna/iarna-toml/blob/latest/test/qa-error.js).
|
||||
|
||||
All of the official example files from the TOML spec are run through this
|
||||
parser and compared to the official YAML files when available. These files are from the TOML spec as of:
|
||||
[357a4ba6](https://github.com/toml-lang/toml/tree/357a4ba6782e48ff26e646780bab11c90ed0a7bc)
|
||||
and specifically are:
|
||||
|
||||
* [github.com/toml-lang/toml/tree/357a4ba6/examples](https://github.com/toml-lang/toml/tree/357a4ba6782e48ff26e646780bab11c90ed0a7bc/examples)
|
||||
* [github.com/toml-lang/toml/tree/357a4ba6/tests](https://github.com/toml-lang/toml/tree/357a4ba6782e48ff26e646780bab11c90ed0a7bc/tests)
|
||||
|
||||
The stringifier is tested by round-tripping these same files, asserting that
|
||||
`TOML.parse(sourcefile)` deepEqual
|
||||
`TOML.parse(TOML.stringify(TOML.parse(sourcefile))`. This is done in
|
||||
[test/roundtrip-examples.js](https://github.com/iarna/iarna-toml/blob/latest/test/round-tripping.js)
|
||||
There are also some tests written to complete coverage from stringification in:
|
||||
[test/stringify.js](https://github.com/iarna/iarna-toml/blob/latest/test/stringify.js)
|
||||
|
||||
Tests for the async and streaming interfaces are in [test/async.js](https://github.com/iarna/iarna-toml/blob/latest/test/async.js) and [test/stream.js](https://github.com/iarna/iarna-toml/blob/latest/test/stream.js) respectively.
|
||||
|
||||
Tests for the parsers debugging mode live in [test/devel.js](https://github.com/iarna/iarna-toml/blob/latest/test/devel.js).
|
||||
|
||||
And finally, many more stringification tests were borrowed from [@othiym23](https://github.com/othiym23)'s
|
||||
[toml-stream](https://npmjs.com/package/toml-stream) module. They were fetched as of
|
||||
[b6f1e26b572d49742d49fa6a6d11524d003441fa](https://github.com/othiym23/toml-stream/tree/b6f1e26b572d49742d49fa6a6d11524d003441fa/test) and live in
|
||||
[test/toml-stream](https://github.com/iarna/iarna-toml/blob/latest/test/toml-stream/).
|
||||
|
||||
## Improvements to make
|
||||
|
||||
* In stringify:
|
||||
* Any way to produce comments. As a JSON stand-in I'm not too worried
|
||||
about this. That said, a document orientated fork is something I'd like
|
||||
to look at eventually…
|
||||
* Stringification could use some work on its error reporting. It reports
|
||||
_what's_ wrong, but not where in your data structure it was.
|
||||
* Further optimize the parser:
|
||||
* There are some debugging assertions left in the main parser, these should be moved to a subclass.
|
||||
* Make the whole debugging parser thing work as a mixin instead of as a superclass.
|
||||
57
BACK_BACK/node_modules/@iarna/toml/index.d.ts
generated
vendored
Executable file
57
BACK_BACK/node_modules/@iarna/toml/index.d.ts
generated
vendored
Executable file
|
|
@ -0,0 +1,57 @@
|
|||
import { Transform } from "stream";
|
||||
|
||||
type JsonArray = boolean[] | number[] | string[] | JsonMap[] | Date[]
|
||||
type AnyJson = boolean | number | string | JsonMap | Date | JsonArray | JsonArray[]
|
||||
|
||||
interface JsonMap {
|
||||
[key: string]: AnyJson;
|
||||
}
|
||||
|
||||
interface ParseOptions {
|
||||
/**
|
||||
* The amount text to parser per pass through the event loop. Defaults to 40kb (`40000`).
|
||||
*/
|
||||
blocksize: number
|
||||
}
|
||||
|
||||
interface FuncParse {
|
||||
/**
|
||||
* Synchronously parse a TOML string and return an object.
|
||||
*/
|
||||
(toml: string): JsonMap
|
||||
|
||||
/**
|
||||
* Asynchronously parse a TOML string and return a promise of the resulting object.
|
||||
*/
|
||||
async (toml: string, options?: ParseOptions): Promise<JsonMap>
|
||||
|
||||
/**
|
||||
* Given a readable stream, parse it as it feeds us data. Return a promise of the resulting object.
|
||||
*/
|
||||
stream (readable: NodeJS.ReadableStream): Promise<JsonMap>
|
||||
stream (): Transform
|
||||
}
|
||||
|
||||
interface FuncStringify {
|
||||
/**
|
||||
* Serialize an object as TOML.
|
||||
*
|
||||
* If an object `TOML.stringify` is serializing has a `toJSON` method
|
||||
* then it will call it to transform the object before serializing it.
|
||||
* This matches the behavior of JSON.stringify.
|
||||
*
|
||||
* The one exception to this is that `toJSON` is not called for `Date` objects
|
||||
* because JSON represents dates as strings and TOML can represent them natively.
|
||||
*
|
||||
* `moment` objects are treated the same as native `Date` objects, in this respect.
|
||||
*/
|
||||
(obj: JsonMap): string
|
||||
|
||||
/**
|
||||
* Serialize a value as TOML would. This is a fragment and not a complete valid TOML document.
|
||||
*/
|
||||
value (any: AnyJson): string
|
||||
}
|
||||
|
||||
export const parse: FuncParse
|
||||
export const stringify: FuncStringify
|
||||
23
BACK_BACK/node_modules/@iarna/toml/lib/create-date.js
generated
vendored
Executable file
23
BACK_BACK/node_modules/@iarna/toml/lib/create-date.js
generated
vendored
Executable file
|
|
@ -0,0 +1,23 @@
|
|||
'use strict'
|
||||
const f = require('./format-num.js')
|
||||
const DateTime = global.Date
|
||||
|
||||
class Date extends DateTime {
|
||||
constructor (value) {
|
||||
super(value)
|
||||
this.isDate = true
|
||||
}
|
||||
toISOString () {
|
||||
return `${this.getUTCFullYear()}-${f(2, this.getUTCMonth() + 1)}-${f(2, this.getUTCDate())}`
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = value => {
|
||||
const date = new Date(value)
|
||||
/* istanbul ignore if */
|
||||
if (isNaN(date)) {
|
||||
throw new TypeError('Invalid Datetime')
|
||||
} else {
|
||||
return date
|
||||
}
|
||||
}
|
||||
24
BACK_BACK/node_modules/@iarna/toml/lib/create-datetime-float.js
generated
vendored
Executable file
24
BACK_BACK/node_modules/@iarna/toml/lib/create-datetime-float.js
generated
vendored
Executable file
|
|
@ -0,0 +1,24 @@
|
|||
'use strict'
|
||||
const f = require('./format-num.js')
|
||||
|
||||
class FloatingDateTime extends Date {
|
||||
constructor (value) {
|
||||
super(value + 'Z')
|
||||
this.isFloating = true
|
||||
}
|
||||
toISOString () {
|
||||
const date = `${this.getUTCFullYear()}-${f(2, this.getUTCMonth() + 1)}-${f(2, this.getUTCDate())}`
|
||||
const time = `${f(2, this.getUTCHours())}:${f(2, this.getUTCMinutes())}:${f(2, this.getUTCSeconds())}.${f(3, this.getUTCMilliseconds())}`
|
||||
return `${date}T${time}`
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = value => {
|
||||
const date = new FloatingDateTime(value)
|
||||
/* istanbul ignore if */
|
||||
if (isNaN(date)) {
|
||||
throw new TypeError('Invalid Datetime')
|
||||
} else {
|
||||
return date
|
||||
}
|
||||
}
|
||||
10
BACK_BACK/node_modules/@iarna/toml/lib/create-datetime.js
generated
vendored
Executable file
10
BACK_BACK/node_modules/@iarna/toml/lib/create-datetime.js
generated
vendored
Executable file
|
|
@ -0,0 +1,10 @@
|
|||
'use strict'
|
||||
module.exports = value => {
|
||||
const date = new Date(value)
|
||||
/* istanbul ignore if */
|
||||
if (isNaN(date)) {
|
||||
throw new TypeError('Invalid Datetime')
|
||||
} else {
|
||||
return date
|
||||
}
|
||||
}
|
||||
22
BACK_BACK/node_modules/@iarna/toml/lib/create-time.js
generated
vendored
Executable file
22
BACK_BACK/node_modules/@iarna/toml/lib/create-time.js
generated
vendored
Executable file
|
|
@ -0,0 +1,22 @@
|
|||
'use strict'
|
||||
const f = require('./format-num.js')
|
||||
|
||||
class Time extends Date {
|
||||
constructor (value) {
|
||||
super(`0000-01-01T${value}Z`)
|
||||
this.isTime = true
|
||||
}
|
||||
toISOString () {
|
||||
return `${f(2, this.getUTCHours())}:${f(2, this.getUTCMinutes())}:${f(2, this.getUTCSeconds())}.${f(3, this.getUTCMilliseconds())}`
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = value => {
|
||||
const date = new Time(value)
|
||||
/* istanbul ignore if */
|
||||
if (isNaN(date)) {
|
||||
throw new TypeError('Invalid Datetime')
|
||||
} else {
|
||||
return date
|
||||
}
|
||||
}
|
||||
6
BACK_BACK/node_modules/@iarna/toml/lib/format-num.js
generated
vendored
Executable file
6
BACK_BACK/node_modules/@iarna/toml/lib/format-num.js
generated
vendored
Executable file
|
|
@ -0,0 +1,6 @@
|
|||
'use strict'
|
||||
module.exports = (d, num) => {
|
||||
num = String(num)
|
||||
while (num.length < d) num = '0' + num
|
||||
return num
|
||||
}
|
||||
60
BACK_BACK/node_modules/@iarna/toml/lib/parser-debug.js
generated
vendored
Executable file
60
BACK_BACK/node_modules/@iarna/toml/lib/parser-debug.js
generated
vendored
Executable file
|
|
@ -0,0 +1,60 @@
|
|||
'use strict'
|
||||
const Parser = require('./parser.js')
|
||||
const util = require('util')
|
||||
|
||||
const dump = _ => util.inspect(_, {colors: true, depth: 10, breakLength: Infinity})
|
||||
class DebugParser extends Parser {
|
||||
stateName (state) {
|
||||
// istanbul ignore next
|
||||
return (state.parser && state.parser.name) || state.name || ('anonymous')
|
||||
}
|
||||
runOne () {
|
||||
const callStack = this.stack.concat(this.state).map(_ => this.stateName(_)).join(' <- ')
|
||||
console.log('RUN', callStack, dump({line: this.line, col: this.col, char: this.char, ret: this.state.returned}))
|
||||
return super.runOne()
|
||||
}
|
||||
finish () {
|
||||
const obj = super.finish()
|
||||
// istanbul ignore if
|
||||
if (this.stack.length !== 0) {
|
||||
throw new Parser.Error('All states did not return by end of stream')
|
||||
}
|
||||
return obj
|
||||
}
|
||||
callStack () {
|
||||
const callStack = this.stack.map(_ => this.stateName(_)).join(' ').replace(/\S/g, ' ')
|
||||
return callStack ? callStack + ' ' : ''
|
||||
}
|
||||
next (fn) {
|
||||
console.log(' ', this.callStack(), 'NEXT', this.stateName(fn))
|
||||
return super.next(fn)
|
||||
}
|
||||
goto (fn) {
|
||||
console.log(' ', this.callStack(), 'GOTO', this.stateName(fn))
|
||||
super.next(fn)
|
||||
return false
|
||||
}
|
||||
call (fn, returnWith) {
|
||||
console.log(' ', this.callStack(), 'CALL', fn.name, returnWith ? '-> ' + returnWith.name : '')
|
||||
if (returnWith) super.next(returnWith)
|
||||
this.stack.push(this.state)
|
||||
this.state = {parser: fn, buf: '', returned: null}
|
||||
}
|
||||
callNow (fn, returnWith) {
|
||||
console.log(' ', this.callStack(), 'CALLNOW', fn.name, returnWith ? '-> ' + returnWith.name : '')
|
||||
if (returnWith) super.next(returnWith)
|
||||
this.stack.push(this.state)
|
||||
this.state = {parser: fn, buf: '', returned: null}
|
||||
return false
|
||||
}
|
||||
return (value) {
|
||||
console.log(' ', this.callStack(), 'RETURN')
|
||||
return super.return(value)
|
||||
}
|
||||
returnNow (value) {
|
||||
console.log(' ', this.callStack(), 'RETURNNOW')
|
||||
super.return(value)
|
||||
return false
|
||||
}
|
||||
}
|
||||
module.exports = DebugParser
|
||||
127
BACK_BACK/node_modules/@iarna/toml/lib/parser.js
generated
vendored
Executable file
127
BACK_BACK/node_modules/@iarna/toml/lib/parser.js
generated
vendored
Executable file
|
|
@ -0,0 +1,127 @@
|
|||
'use strict'
|
||||
const ParserEND = 0x110000
|
||||
class ParserError extends Error {
|
||||
/* istanbul ignore next */
|
||||
constructor (msg, filename, linenumber) {
|
||||
super('[ParserError] ' + msg, filename, linenumber)
|
||||
this.name = 'ParserError'
|
||||
this.code = 'ParserError'
|
||||
if (Error.captureStackTrace) Error.captureStackTrace(this, ParserError)
|
||||
}
|
||||
}
|
||||
class State {
|
||||
constructor (parser) {
|
||||
this.parser = parser
|
||||
this.buf = ''
|
||||
this.returned = null
|
||||
this.result = null
|
||||
this.resultTable = null
|
||||
this.resultArr = null
|
||||
}
|
||||
}
|
||||
class Parser {
|
||||
constructor () {
|
||||
this.pos = 0
|
||||
this.col = 0
|
||||
this.line = 0
|
||||
this.obj = {}
|
||||
this.ctx = this.obj
|
||||
this.stack = []
|
||||
this._buf = ''
|
||||
this.char = null
|
||||
this.ii = 0
|
||||
this.state = new State(this.parseStart)
|
||||
}
|
||||
|
||||
parse (str) {
|
||||
/* istanbul ignore next */
|
||||
if (str.length === 0 || str.length == null) return
|
||||
|
||||
this._buf = String(str)
|
||||
this.ii = -1
|
||||
this.char = -1
|
||||
let getNext
|
||||
while (getNext === false || this.nextChar()) {
|
||||
getNext = this.runOne()
|
||||
}
|
||||
this._buf = null
|
||||
}
|
||||
nextChar () {
|
||||
if (this.char === 0x0A) {
|
||||
++this.line
|
||||
this.col = -1
|
||||
}
|
||||
++this.ii
|
||||
this.char = this._buf.codePointAt(this.ii)
|
||||
++this.pos
|
||||
++this.col
|
||||
return this.haveBuffer()
|
||||
}
|
||||
haveBuffer () {
|
||||
return this.ii < this._buf.length
|
||||
}
|
||||
runOne () {
|
||||
return this.state.parser.call(this, this.state.returned)
|
||||
}
|
||||
finish () {
|
||||
this.char = ParserEND
|
||||
let last
|
||||
do {
|
||||
last = this.state.parser
|
||||
this.runOne()
|
||||
} while (this.state.parser !== last)
|
||||
|
||||
this.ctx = null
|
||||
this.state = null
|
||||
this._buf = null
|
||||
|
||||
return this.obj
|
||||
}
|
||||
next (fn) {
|
||||
/* istanbul ignore next */
|
||||
if (typeof fn !== 'function') throw new ParserError('Tried to set state to non-existent state: ' + JSON.stringify(fn))
|
||||
this.state.parser = fn
|
||||
}
|
||||
goto (fn) {
|
||||
this.next(fn)
|
||||
return this.runOne()
|
||||
}
|
||||
call (fn, returnWith) {
|
||||
if (returnWith) this.next(returnWith)
|
||||
this.stack.push(this.state)
|
||||
this.state = new State(fn)
|
||||
}
|
||||
callNow (fn, returnWith) {
|
||||
this.call(fn, returnWith)
|
||||
return this.runOne()
|
||||
}
|
||||
return (value) {
|
||||
/* istanbul ignore next */
|
||||
if (this.stack.length === 0) throw this.error(new ParserError('Stack underflow'))
|
||||
if (value === undefined) value = this.state.buf
|
||||
this.state = this.stack.pop()
|
||||
this.state.returned = value
|
||||
}
|
||||
returnNow (value) {
|
||||
this.return(value)
|
||||
return this.runOne()
|
||||
}
|
||||
consume () {
|
||||
/* istanbul ignore next */
|
||||
if (this.char === ParserEND) throw this.error(new ParserError('Unexpected end-of-buffer'))
|
||||
this.state.buf += this._buf[this.ii]
|
||||
}
|
||||
error (err) {
|
||||
err.line = this.line
|
||||
err.col = this.col
|
||||
err.pos = this.pos
|
||||
return err
|
||||
}
|
||||
/* istanbul ignore next */
|
||||
parseStart () {
|
||||
throw new ParserError('Must declare a parseStart method')
|
||||
}
|
||||
}
|
||||
Parser.END = ParserEND
|
||||
Parser.Error = ParserError
|
||||
module.exports = Parser
|
||||
1379
BACK_BACK/node_modules/@iarna/toml/lib/toml-parser.js
generated
vendored
Executable file
1379
BACK_BACK/node_modules/@iarna/toml/lib/toml-parser.js
generated
vendored
Executable file
File diff suppressed because it is too large
Load diff
82
BACK_BACK/node_modules/@iarna/toml/package.json
generated
vendored
Executable file
82
BACK_BACK/node_modules/@iarna/toml/package.json
generated
vendored
Executable file
|
|
@ -0,0 +1,82 @@
|
|||
{
|
||||
"name": "@iarna/toml",
|
||||
"version": "2.2.5",
|
||||
"main": "toml.js",
|
||||
"scripts": {
|
||||
"test": "tap -J --100 test/*.js test/toml-stream/*.js",
|
||||
"benchmark": "node benchmark.js && node benchmark-per-file.js && node results2table.js",
|
||||
"prerelease": "npm t",
|
||||
"prepack": "rm -f *~",
|
||||
"postpublish": "git push --follow-tags",
|
||||
"pretest": "iarna-standard",
|
||||
"update-coc": "weallbehave -o . && git add CODE_OF_CONDUCT.md && git commit -m 'docs(coc): updated CODE_OF_CONDUCT.md'",
|
||||
"update-contrib": "weallcontribute -o . && git add CONTRIBUTING.md && git commit -m 'docs(contributing): updated CONTRIBUTING.md'",
|
||||
"setup-burntsushi-toml-suite": "[ -d test/burntsushi-toml-test ] || (git clone https://github.com/BurntSushi/toml-test test/burntsushi-toml-test; rimraf test/burntsushi-toml-test/.git/hooks/*); cd test/burntsushi-toml-test; git pull",
|
||||
"setup-iarna-toml-suite": "[ -d test/spec-test ] || (git clone https://github.com/iarna/toml-spec-tests -b 0.5.0 test/spec-test; rimraf test/spec-test/.git/hooks/*); cd test/spec-test; git pull",
|
||||
"prepare": "npm run setup-burntsushi-toml-suite && npm run setup-iarna-toml-suite"
|
||||
},
|
||||
"keywords": [
|
||||
"toml",
|
||||
"toml-parser",
|
||||
"toml-stringifier",
|
||||
"parser",
|
||||
"stringifer",
|
||||
"emitter",
|
||||
"ini",
|
||||
"tomlify",
|
||||
"encoder",
|
||||
"decoder"
|
||||
],
|
||||
"author": "Rebecca Turner <me@re-becca.org> (http://re-becca.org/)",
|
||||
"license": "ISC",
|
||||
"description": "Better TOML parsing and stringifying all in that familiar JSON interface.",
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"@iarna/standard": "^2.0.2",
|
||||
"@ltd/j-toml": "^0.5.107",
|
||||
"@perl/qx": "^1.1.0",
|
||||
"@sgarciac/bombadil": "^2.3.0",
|
||||
"ansi": "^0.3.1",
|
||||
"approximate-number": "^2.0.0",
|
||||
"benchmark": "^2.1.4",
|
||||
"fast-toml": "^0.5.4",
|
||||
"funstream": "^4.2.0",
|
||||
"glob": "^7.1.6",
|
||||
"js-yaml": "^3.13.1",
|
||||
"rimraf": "^3.0.2",
|
||||
"tap": "^12.0.1",
|
||||
"toml": "^3.0.0",
|
||||
"toml-j0.4": "^1.1.1",
|
||||
"weallbehave": "*",
|
||||
"weallcontribute": "*"
|
||||
},
|
||||
"files": [
|
||||
"toml.js",
|
||||
"stringify.js",
|
||||
"parse.js",
|
||||
"parse-string.js",
|
||||
"parse-stream.js",
|
||||
"parse-async.js",
|
||||
"parse-pretty-error.js",
|
||||
"lib/parser.js",
|
||||
"lib/parser-debug.js",
|
||||
"lib/toml-parser.js",
|
||||
"lib/create-datetime.js",
|
||||
"lib/create-date.js",
|
||||
"lib/create-datetime-float.js",
|
||||
"lib/create-time.js",
|
||||
"lib/format-num.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"directories": {
|
||||
"test": "test"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/iarna/iarna-toml.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/iarna/iarna-toml/issues"
|
||||
},
|
||||
"homepage": "https://github.com/iarna/iarna-toml#readme"
|
||||
}
|
||||
30
BACK_BACK/node_modules/@iarna/toml/parse-async.js
generated
vendored
Executable file
30
BACK_BACK/node_modules/@iarna/toml/parse-async.js
generated
vendored
Executable file
|
|
@ -0,0 +1,30 @@
|
|||
'use strict'
|
||||
module.exports = parseAsync
|
||||
|
||||
const TOMLParser = require('./lib/toml-parser.js')
|
||||
const prettyError = require('./parse-pretty-error.js')
|
||||
|
||||
function parseAsync (str, opts) {
|
||||
if (!opts) opts = {}
|
||||
const index = 0
|
||||
const blocksize = opts.blocksize || 40960
|
||||
const parser = new TOMLParser()
|
||||
return new Promise((resolve, reject) => {
|
||||
setImmediate(parseAsyncNext, index, blocksize, resolve, reject)
|
||||
})
|
||||
function parseAsyncNext (index, blocksize, resolve, reject) {
|
||||
if (index >= str.length) {
|
||||
try {
|
||||
return resolve(parser.finish())
|
||||
} catch (err) {
|
||||
return reject(prettyError(err, str))
|
||||
}
|
||||
}
|
||||
try {
|
||||
parser.parse(str.slice(index, index + blocksize))
|
||||
setImmediate(parseAsyncNext, index + blocksize, blocksize, resolve, reject)
|
||||
} catch (err) {
|
||||
reject(prettyError(err, str))
|
||||
}
|
||||
}
|
||||
}
|
||||
33
BACK_BACK/node_modules/@iarna/toml/parse-pretty-error.js
generated
vendored
Executable file
33
BACK_BACK/node_modules/@iarna/toml/parse-pretty-error.js
generated
vendored
Executable file
|
|
@ -0,0 +1,33 @@
|
|||
'use strict'
|
||||
module.exports = prettyError
|
||||
|
||||
function prettyError (err, buf) {
|
||||
/* istanbul ignore if */
|
||||
if (err.pos == null || err.line == null) return err
|
||||
let msg = err.message
|
||||
msg += ` at row ${err.line + 1}, col ${err.col + 1}, pos ${err.pos}:\n`
|
||||
|
||||
/* istanbul ignore else */
|
||||
if (buf && buf.split) {
|
||||
const lines = buf.split(/\n/)
|
||||
const lineNumWidth = String(Math.min(lines.length, err.line + 3)).length
|
||||
let linePadding = ' '
|
||||
while (linePadding.length < lineNumWidth) linePadding += ' '
|
||||
for (let ii = Math.max(0, err.line - 1); ii < Math.min(lines.length, err.line + 2); ++ii) {
|
||||
let lineNum = String(ii + 1)
|
||||
if (lineNum.length < lineNumWidth) lineNum = ' ' + lineNum
|
||||
if (err.line === ii) {
|
||||
msg += lineNum + '> ' + lines[ii] + '\n'
|
||||
msg += linePadding + ' '
|
||||
for (let hh = 0; hh < err.col; ++hh) {
|
||||
msg += ' '
|
||||
}
|
||||
msg += '^\n'
|
||||
} else {
|
||||
msg += lineNum + ': ' + lines[ii] + '\n'
|
||||
}
|
||||
}
|
||||
}
|
||||
err.message = msg + '\n'
|
||||
return err
|
||||
}
|
||||
80
BACK_BACK/node_modules/@iarna/toml/parse-stream.js
generated
vendored
Executable file
80
BACK_BACK/node_modules/@iarna/toml/parse-stream.js
generated
vendored
Executable file
|
|
@ -0,0 +1,80 @@
|
|||
'use strict'
|
||||
module.exports = parseStream
|
||||
|
||||
const stream = require('stream')
|
||||
const TOMLParser = require('./lib/toml-parser.js')
|
||||
|
||||
function parseStream (stm) {
|
||||
if (stm) {
|
||||
return parseReadable(stm)
|
||||
} else {
|
||||
return parseTransform(stm)
|
||||
}
|
||||
}
|
||||
|
||||
function parseReadable (stm) {
|
||||
const parser = new TOMLParser()
|
||||
stm.setEncoding('utf8')
|
||||
return new Promise((resolve, reject) => {
|
||||
let readable
|
||||
let ended = false
|
||||
let errored = false
|
||||
function finish () {
|
||||
ended = true
|
||||
if (readable) return
|
||||
try {
|
||||
resolve(parser.finish())
|
||||
} catch (err) {
|
||||
reject(err)
|
||||
}
|
||||
}
|
||||
function error (err) {
|
||||
errored = true
|
||||
reject(err)
|
||||
}
|
||||
stm.once('end', finish)
|
||||
stm.once('error', error)
|
||||
readNext()
|
||||
|
||||
function readNext () {
|
||||
readable = true
|
||||
let data
|
||||
while ((data = stm.read()) !== null) {
|
||||
try {
|
||||
parser.parse(data)
|
||||
} catch (err) {
|
||||
return error(err)
|
||||
}
|
||||
}
|
||||
readable = false
|
||||
/* istanbul ignore if */
|
||||
if (ended) return finish()
|
||||
/* istanbul ignore if */
|
||||
if (errored) return
|
||||
stm.once('readable', readNext)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function parseTransform () {
|
||||
const parser = new TOMLParser()
|
||||
return new stream.Transform({
|
||||
objectMode: true,
|
||||
transform (chunk, encoding, cb) {
|
||||
try {
|
||||
parser.parse(chunk.toString(encoding))
|
||||
} catch (err) {
|
||||
this.emit('error', err)
|
||||
}
|
||||
cb()
|
||||
},
|
||||
flush (cb) {
|
||||
try {
|
||||
this.push(parser.finish())
|
||||
} catch (err) {
|
||||
this.emit('error', err)
|
||||
}
|
||||
cb()
|
||||
}
|
||||
})
|
||||
}
|
||||
18
BACK_BACK/node_modules/@iarna/toml/parse-string.js
generated
vendored
Executable file
18
BACK_BACK/node_modules/@iarna/toml/parse-string.js
generated
vendored
Executable file
|
|
@ -0,0 +1,18 @@
|
|||
'use strict'
|
||||
module.exports = parseString
|
||||
|
||||
const TOMLParser = require('./lib/toml-parser.js')
|
||||
const prettyError = require('./parse-pretty-error.js')
|
||||
|
||||
function parseString (str) {
|
||||
if (global.Buffer && global.Buffer.isBuffer(str)) {
|
||||
str = str.toString('utf8')
|
||||
}
|
||||
const parser = new TOMLParser()
|
||||
try {
|
||||
parser.parse(str)
|
||||
return parser.finish()
|
||||
} catch (err) {
|
||||
throw prettyError(err, str)
|
||||
}
|
||||
}
|
||||
5
BACK_BACK/node_modules/@iarna/toml/parse.js
generated
vendored
Executable file
5
BACK_BACK/node_modules/@iarna/toml/parse.js
generated
vendored
Executable file
|
|
@ -0,0 +1,5 @@
|
|||
'use strict'
|
||||
module.exports = require('./parse-string.js')
|
||||
module.exports.async = require('./parse-async.js')
|
||||
module.exports.stream = require('./parse-stream.js')
|
||||
module.exports.prettyError = require('./parse-pretty-error.js')
|
||||
296
BACK_BACK/node_modules/@iarna/toml/stringify.js
generated
vendored
Executable file
296
BACK_BACK/node_modules/@iarna/toml/stringify.js
generated
vendored
Executable file
|
|
@ -0,0 +1,296 @@
|
|||
'use strict'
|
||||
module.exports = stringify
|
||||
module.exports.value = stringifyInline
|
||||
|
||||
function stringify (obj) {
|
||||
if (obj === null) throw typeError('null')
|
||||
if (obj === void (0)) throw typeError('undefined')
|
||||
if (typeof obj !== 'object') throw typeError(typeof obj)
|
||||
|
||||
if (typeof obj.toJSON === 'function') obj = obj.toJSON()
|
||||
if (obj == null) return null
|
||||
const type = tomlType(obj)
|
||||
if (type !== 'table') throw typeError(type)
|
||||
return stringifyObject('', '', obj)
|
||||
}
|
||||
|
||||
function typeError (type) {
|
||||
return new Error('Can only stringify objects, not ' + type)
|
||||
}
|
||||
|
||||
function arrayOneTypeError () {
|
||||
return new Error("Array values can't have mixed types")
|
||||
}
|
||||
|
||||
function getInlineKeys (obj) {
|
||||
return Object.keys(obj).filter(key => isInline(obj[key]))
|
||||
}
|
||||
function getComplexKeys (obj) {
|
||||
return Object.keys(obj).filter(key => !isInline(obj[key]))
|
||||
}
|
||||
|
||||
function toJSON (obj) {
|
||||
let nobj = Array.isArray(obj) ? [] : Object.prototype.hasOwnProperty.call(obj, '__proto__') ? {['__proto__']: undefined} : {}
|
||||
for (let prop of Object.keys(obj)) {
|
||||
if (obj[prop] && typeof obj[prop].toJSON === 'function' && !('toISOString' in obj[prop])) {
|
||||
nobj[prop] = obj[prop].toJSON()
|
||||
} else {
|
||||
nobj[prop] = obj[prop]
|
||||
}
|
||||
}
|
||||
return nobj
|
||||
}
|
||||
|
||||
function stringifyObject (prefix, indent, obj) {
|
||||
obj = toJSON(obj)
|
||||
var inlineKeys
|
||||
var complexKeys
|
||||
inlineKeys = getInlineKeys(obj)
|
||||
complexKeys = getComplexKeys(obj)
|
||||
var result = []
|
||||
var inlineIndent = indent || ''
|
||||
inlineKeys.forEach(key => {
|
||||
var type = tomlType(obj[key])
|
||||
if (type !== 'undefined' && type !== 'null') {
|
||||
result.push(inlineIndent + stringifyKey(key) + ' = ' + stringifyAnyInline(obj[key], true))
|
||||
}
|
||||
})
|
||||
if (result.length > 0) result.push('')
|
||||
var complexIndent = prefix && inlineKeys.length > 0 ? indent + ' ' : ''
|
||||
complexKeys.forEach(key => {
|
||||
result.push(stringifyComplex(prefix, complexIndent, key, obj[key]))
|
||||
})
|
||||
return result.join('\n')
|
||||
}
|
||||
|
||||
function isInline (value) {
|
||||
switch (tomlType(value)) {
|
||||
case 'undefined':
|
||||
case 'null':
|
||||
case 'integer':
|
||||
case 'nan':
|
||||
case 'float':
|
||||
case 'boolean':
|
||||
case 'string':
|
||||
case 'datetime':
|
||||
return true
|
||||
case 'array':
|
||||
return value.length === 0 || tomlType(value[0]) !== 'table'
|
||||
case 'table':
|
||||
return Object.keys(value).length === 0
|
||||
/* istanbul ignore next */
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
function tomlType (value) {
|
||||
if (value === undefined) {
|
||||
return 'undefined'
|
||||
} else if (value === null) {
|
||||
return 'null'
|
||||
/* eslint-disable valid-typeof */
|
||||
} else if (typeof value === 'bigint' || (Number.isInteger(value) && !Object.is(value, -0))) {
|
||||
return 'integer'
|
||||
} else if (typeof value === 'number') {
|
||||
return 'float'
|
||||
} else if (typeof value === 'boolean') {
|
||||
return 'boolean'
|
||||
} else if (typeof value === 'string') {
|
||||
return 'string'
|
||||
} else if ('toISOString' in value) {
|
||||
return isNaN(value) ? 'undefined' : 'datetime'
|
||||
} else if (Array.isArray(value)) {
|
||||
return 'array'
|
||||
} else {
|
||||
return 'table'
|
||||
}
|
||||
}
|
||||
|
||||
function stringifyKey (key) {
|
||||
var keyStr = String(key)
|
||||
if (/^[-A-Za-z0-9_]+$/.test(keyStr)) {
|
||||
return keyStr
|
||||
} else {
|
||||
return stringifyBasicString(keyStr)
|
||||
}
|
||||
}
|
||||
|
||||
function stringifyBasicString (str) {
|
||||
return '"' + escapeString(str).replace(/"/g, '\\"') + '"'
|
||||
}
|
||||
|
||||
function stringifyLiteralString (str) {
|
||||
return "'" + str + "'"
|
||||
}
|
||||
|
||||
function numpad (num, str) {
|
||||
while (str.length < num) str = '0' + str
|
||||
return str
|
||||
}
|
||||
|
||||
function escapeString (str) {
|
||||
return str.replace(/\\/g, '\\\\')
|
||||
.replace(/[\b]/g, '\\b')
|
||||
.replace(/\t/g, '\\t')
|
||||
.replace(/\n/g, '\\n')
|
||||
.replace(/\f/g, '\\f')
|
||||
.replace(/\r/g, '\\r')
|
||||
/* eslint-disable no-control-regex */
|
||||
.replace(/([\u0000-\u001f\u007f])/, c => '\\u' + numpad(4, c.codePointAt(0).toString(16)))
|
||||
/* eslint-enable no-control-regex */
|
||||
}
|
||||
|
||||
function stringifyMultilineString (str) {
|
||||
let escaped = str.split(/\n/).map(str => {
|
||||
return escapeString(str).replace(/"(?="")/g, '\\"')
|
||||
}).join('\n')
|
||||
if (escaped.slice(-1) === '"') escaped += '\\\n'
|
||||
return '"""\n' + escaped + '"""'
|
||||
}
|
||||
|
||||
function stringifyAnyInline (value, multilineOk) {
|
||||
let type = tomlType(value)
|
||||
if (type === 'string') {
|
||||
if (multilineOk && /\n/.test(value)) {
|
||||
type = 'string-multiline'
|
||||
} else if (!/[\b\t\n\f\r']/.test(value) && /"/.test(value)) {
|
||||
type = 'string-literal'
|
||||
}
|
||||
}
|
||||
return stringifyInline(value, type)
|
||||
}
|
||||
|
||||
function stringifyInline (value, type) {
|
||||
/* istanbul ignore if */
|
||||
if (!type) type = tomlType(value)
|
||||
switch (type) {
|
||||
case 'string-multiline':
|
||||
return stringifyMultilineString(value)
|
||||
case 'string':
|
||||
return stringifyBasicString(value)
|
||||
case 'string-literal':
|
||||
return stringifyLiteralString(value)
|
||||
case 'integer':
|
||||
return stringifyInteger(value)
|
||||
case 'float':
|
||||
return stringifyFloat(value)
|
||||
case 'boolean':
|
||||
return stringifyBoolean(value)
|
||||
case 'datetime':
|
||||
return stringifyDatetime(value)
|
||||
case 'array':
|
||||
return stringifyInlineArray(value.filter(_ => tomlType(_) !== 'null' && tomlType(_) !== 'undefined' && tomlType(_) !== 'nan'))
|
||||
case 'table':
|
||||
return stringifyInlineTable(value)
|
||||
/* istanbul ignore next */
|
||||
default:
|
||||
throw typeError(type)
|
||||
}
|
||||
}
|
||||
|
||||
function stringifyInteger (value) {
|
||||
/* eslint-disable security/detect-unsafe-regex */
|
||||
return String(value).replace(/\B(?=(\d{3})+(?!\d))/g, '_')
|
||||
}
|
||||
|
||||
function stringifyFloat (value) {
|
||||
if (value === Infinity) {
|
||||
return 'inf'
|
||||
} else if (value === -Infinity) {
|
||||
return '-inf'
|
||||
} else if (Object.is(value, NaN)) {
|
||||
return 'nan'
|
||||
} else if (Object.is(value, -0)) {
|
||||
return '-0.0'
|
||||
}
|
||||
var chunks = String(value).split('.')
|
||||
var int = chunks[0]
|
||||
var dec = chunks[1] || 0
|
||||
return stringifyInteger(int) + '.' + dec
|
||||
}
|
||||
|
||||
function stringifyBoolean (value) {
|
||||
return String(value)
|
||||
}
|
||||
|
||||
function stringifyDatetime (value) {
|
||||
return value.toISOString()
|
||||
}
|
||||
|
||||
function isNumber (type) {
|
||||
return type === 'float' || type === 'integer'
|
||||
}
|
||||
function arrayType (values) {
|
||||
var contentType = tomlType(values[0])
|
||||
if (values.every(_ => tomlType(_) === contentType)) return contentType
|
||||
// mixed integer/float, emit as floats
|
||||
if (values.every(_ => isNumber(tomlType(_)))) return 'float'
|
||||
return 'mixed'
|
||||
}
|
||||
function validateArray (values) {
|
||||
const type = arrayType(values)
|
||||
if (type === 'mixed') {
|
||||
throw arrayOneTypeError()
|
||||
}
|
||||
return type
|
||||
}
|
||||
|
||||
function stringifyInlineArray (values) {
|
||||
values = toJSON(values)
|
||||
const type = validateArray(values)
|
||||
var result = '['
|
||||
var stringified = values.map(_ => stringifyInline(_, type))
|
||||
if (stringified.join(', ').length > 60 || /\n/.test(stringified)) {
|
||||
result += '\n ' + stringified.join(',\n ') + '\n'
|
||||
} else {
|
||||
result += ' ' + stringified.join(', ') + (stringified.length > 0 ? ' ' : '')
|
||||
}
|
||||
return result + ']'
|
||||
}
|
||||
|
||||
function stringifyInlineTable (value) {
|
||||
value = toJSON(value)
|
||||
var result = []
|
||||
Object.keys(value).forEach(key => {
|
||||
result.push(stringifyKey(key) + ' = ' + stringifyAnyInline(value[key], false))
|
||||
})
|
||||
return '{ ' + result.join(', ') + (result.length > 0 ? ' ' : '') + '}'
|
||||
}
|
||||
|
||||
function stringifyComplex (prefix, indent, key, value) {
|
||||
var valueType = tomlType(value)
|
||||
/* istanbul ignore else */
|
||||
if (valueType === 'array') {
|
||||
return stringifyArrayOfTables(prefix, indent, key, value)
|
||||
} else if (valueType === 'table') {
|
||||
return stringifyComplexTable(prefix, indent, key, value)
|
||||
} else {
|
||||
throw typeError(valueType)
|
||||
}
|
||||
}
|
||||
|
||||
function stringifyArrayOfTables (prefix, indent, key, values) {
|
||||
values = toJSON(values)
|
||||
validateArray(values)
|
||||
var firstValueType = tomlType(values[0])
|
||||
/* istanbul ignore if */
|
||||
if (firstValueType !== 'table') throw typeError(firstValueType)
|
||||
var fullKey = prefix + stringifyKey(key)
|
||||
var result = ''
|
||||
values.forEach(table => {
|
||||
if (result.length > 0) result += '\n'
|
||||
result += indent + '[[' + fullKey + ']]\n'
|
||||
result += stringifyObject(fullKey + '.', indent, table)
|
||||
})
|
||||
return result
|
||||
}
|
||||
|
||||
function stringifyComplexTable (prefix, indent, key, value) {
|
||||
var fullKey = prefix + stringifyKey(key)
|
||||
var result = ''
|
||||
if (getInlineKeys(value).length > 0) {
|
||||
result += indent + '[' + fullKey + ']\n'
|
||||
}
|
||||
return result + stringifyObject(fullKey + '.', indent, value)
|
||||
}
|
||||
3
BACK_BACK/node_modules/@iarna/toml/toml.js
generated
vendored
Executable file
3
BACK_BACK/node_modules/@iarna/toml/toml.js
generated
vendored
Executable file
|
|
@ -0,0 +1,3 @@
|
|||
'use strict'
|
||||
exports.parse = require('./parse.js')
|
||||
exports.stringify = require('./stringify.js')
|
||||
Loading…
Add table
Add a link
Reference in a new issue