Simulator first commit

This commit is contained in:
2019-09-18 11:11:16 +03:00
commit 6e1686be67
5028 changed files with 985331 additions and 0 deletions

18
node_modules/toml/.jshintrc generated vendored Normal file
View File

@ -0,0 +1,18 @@
{
"node": true,
"browser": true,
"browserify": true,
"curly": true,
"eqeqeq": true,
"eqnull": false,
"latedef": "nofunc",
"newcap": true,
"noarg": true,
"undef": true,
"strict": true,
"trailing": true,
"smarttabs": true,
"indent": 2,
"quotmark": true,
"laxbreak": true
}

7
node_modules/toml/.travis.yml generated vendored Normal file
View File

@ -0,0 +1,7 @@
language: node_js
sudo: false
node_js:
- "4.1"
- "4.0"
- "0.12"
- "0.10"

116
node_modules/toml/CHANGELOG.md generated vendored Normal file
View File

@ -0,0 +1,116 @@
2.3.0 - July 13 2015
====================
* Correctly handle quoted keys ([#21](https://github.com/BinaryMuse/toml-node/issues/21))
2.2.3 - June 8 2015
===================
* Support empty inline tables ([#24](https://github.com/BinaryMuse/toml-node/issues/24))
* Do not allow implicit table definitions to replace value ([#23](https://github.com/BinaryMuse/toml-node/issues/23))
* Don't allow tables to replace inline tables ([#25](https://github.com/BinaryMuse/toml-node/issues/25))
2.2.2 - April 3 2015
====================
* Correctly handle newlines at beginning of string ([#22](https://github.com/BinaryMuse/toml-node/issues/22))
2.2.1 - March 17 2015
=====================
* Parse dates generated by Date#toISOString() ([#20](https://github.com/BinaryMuse/toml-node/issues/20))
2.2.0 - Feb 26 2015
===================
* Support TOML spec v0.4.0
2.1.0 - Jan 7 2015
==================
* Support TOML spec v0.3.1
2.0.6 - May 23 2014
===================
### Bug Fixes
* Fix support for empty arrays with newlines ([#13](https://github.com/BinaryMuse/toml-node/issues/13))
2.0.5 - May 5 2014
==================
### Bug Fixes
* Fix loop iteration leak, by [sebmck](https://github.com/sebmck) ([#12](https://github.com/BinaryMuse/toml-node/pull/12))
### Development
* Tests now run JSHint on `lib/compiler.js`
2.0.4 - Mar 9 2014
==================
### Bug Fixes
* Fix failure on duplicate table name inside table array ([#11](https://github.com/BinaryMuse/toml-node/issues/11))
2.0.2 - Feb 23 2014
===================
### Bug Fixes
* Fix absence of errors when table path starts or ends with period
2.0.1 - Feb 23 2014
===================
### Bug Fixes
* Fix incorrect messaging in array type errors
* Fix missing error when overwriting key with table array
2.0.0 - Feb 23 2014
===================
### Features
* Add support for [version 0.2 of the TOML spec](https://github.com/mojombo/toml/blob/master/versions/toml-v0.2.0.md) ([#9](https://github.com/BinaryMuse/toml-node/issues/9))
### Internals
* Upgrade to PEG.js v0.8 and rewrite compiler; parser is now considerably faster (from ~7000ms to ~1000ms to parse `example.toml` 1000 times on Node.js v0.10)
1.0.4 - Aug 17 2013
===================
### Bug Fixes
* Fix support for empty arrays
1.0.3 - Aug 17 2013
===================
### Bug Fixes
* Fix typo in array type error message
* Fix single-element arrays with no trailing commas
1.0.2 - Aug 17 2013
===================
### Bug Fixes
* Fix errors on lines that contain only whitespace ([#7](https://github.com/BinaryMuse/toml-node/issues/7))
1.0.1 - Aug 17 2013
===================
### Internals
* Remove old code remaining from the remove streaming API
1.0.0 - Aug 17 2013
===================
Initial stable release

22
node_modules/toml/LICENSE generated vendored Normal file
View File

@ -0,0 +1,22 @@
Copyright (c) 2012 Michelle Tilley
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE 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.

93
node_modules/toml/README.md generated vendored Normal file
View File

@ -0,0 +1,93 @@
TOML Parser for Node.js
=======================
[![Build Status](https://travis-ci.org/BinaryMuse/toml-node.png?branch=master)](https://travis-ci.org/BinaryMuse/toml-node)
[![NPM](https://nodei.co/npm/toml.png?downloads=true)](https://nodei.co/npm/toml/)
If you haven't heard of TOML, well you're just missing out. [Go check it out now.](https://github.com/mojombo/toml) Back? Good.
TOML Spec Support
-----------------
toml-node supports version 0.4.0 the TOML spec as specified by [mojombo/toml@v0.4.0](https://github.com/mojombo/toml/blob/master/versions/en/toml-v0.4.0.md)
Installation
------------
toml-node is available via npm.
npm install toml
toml-node also works with browser module bundlers like Browserify and webpack.
Usage
-----
### Standalone
Say you have some awesome TOML in a variable called `someTomlString`. Maybe it came from the web; maybe it came from a file; wherever it came from, it came asynchronously! Let's turn that sucker into a JavaScript object.
```javascript
var toml = require('toml');
var data = toml.parse(someTomlString);
console.dir(data);
```
`toml.parse` throws an exception in the case of a parsing error; such exceptions have a `line` and `column` property on them to help identify the offending text.
```javascript
try {
toml.parse(someCrazyKnuckleHeadedTrblToml);
} catch (e) {
console.error("Parsing error on line " + e.line + ", column " + e.column +
": " + e.message);
}
```
### Streaming
As of toml-node version 1.0, the streaming interface has been removed. Instead, use a module like [concat-stream](https://npmjs.org/package/concat-stream):
```javascript
var toml = require('toml');
var concat = require('concat-stream');
var fs = require('fs');
fs.createReadStream('tomlFile.toml', 'utf8').pipe(concat(function(data) {
var parsed = toml.parse(data);
}));
```
Thanks [@ForbesLindesay](https://github.com/ForbesLindesay) for the suggestion.
### Requiring with Node.js
You can use the [toml-require package](https://github.com/BinaryMuse/toml-require) to `require()` your `.toml` files with Node.js
Live Demo
---------
You can experiment with TOML online at http://binarymuse.github.io/toml-node/, which uses the latest version of this library.
Building & Testing
------------------
toml-node uses [the PEG.js parser generator](http://pegjs.majda.cz/).
npm install
npm run build
npm test
Any changes to `src/toml.peg` requires a regeneration of the parser with `npm run build`.
toml-node is tested on Travis CI and is tested against:
* Node 0.10
* Node 0.12
* Latest stable io.js
License
-------
toml-node is licensed under the MIT license agreement. See the LICENSE file for more information.

12
node_modules/toml/benchmark.js generated vendored Normal file
View File

@ -0,0 +1,12 @@
var toml = require('./index');
var fs = require('fs');
var data = fs.readFileSync('./test/example.toml', 'utf8');
var iterations = 1000;
var start = new Date();
for(var i = 0; i < iterations; i++) {
toml.parse(data);
}
var end = new Date();
console.log("%s iterations in %sms", iterations, end - start);

3
node_modules/toml/index.d.ts generated vendored Normal file
View File

@ -0,0 +1,3 @@
declare module 'toml' {
export function parse(input: string): any;
}

9
node_modules/toml/index.js generated vendored Normal file
View File

@ -0,0 +1,9 @@
var parser = require('./lib/parser');
var compiler = require('./lib/compiler');
module.exports = {
parse: function(input) {
var nodes = parser.parse(input.toString());
return compiler.compile(nodes);
}
};

195
node_modules/toml/lib/compiler.js generated vendored Normal file
View File

@ -0,0 +1,195 @@
"use strict";
function compile(nodes) {
var assignedPaths = [];
var valueAssignments = [];
var currentPath = "";
var data = {};
var context = data;
var arrayMode = false;
return reduce(nodes);
function reduce(nodes) {
var node;
for (var i = 0; i < nodes.length; i++) {
node = nodes[i];
switch (node.type) {
case "Assign":
assign(node);
break;
case "ObjectPath":
setPath(node);
break;
case "ArrayPath":
addTableArray(node);
break;
}
}
return data;
}
function genError(err, line, col) {
var ex = new Error(err);
ex.line = line;
ex.column = col;
throw ex;
}
function assign(node) {
var key = node.key;
var value = node.value;
var line = node.line;
var column = node.column;
var fullPath;
if (currentPath) {
fullPath = currentPath + "." + key;
} else {
fullPath = key;
}
if (typeof context[key] !== "undefined") {
genError("Cannot redefine existing key '" + fullPath + "'.", line, column);
}
context[key] = reduceValueNode(value);
if (!pathAssigned(fullPath)) {
assignedPaths.push(fullPath);
valueAssignments.push(fullPath);
}
}
function pathAssigned(path) {
return assignedPaths.indexOf(path) !== -1;
}
function reduceValueNode(node) {
if (node.type === "Array") {
return reduceArrayWithTypeChecking(node.value);
} else if (node.type === "InlineTable") {
return reduceInlineTableNode(node.value);
} else {
return node.value;
}
}
function reduceInlineTableNode(values) {
var obj = {};
for (var i = 0; i < values.length; i++) {
var val = values[i];
if (val.value.type === "InlineTable") {
obj[val.key] = reduceInlineTableNode(val.value.value);
} else if (val.type === "InlineTableValue") {
obj[val.key] = reduceValueNode(val.value);
}
}
return obj;
}
function setPath(node) {
var path = node.value;
var quotedPath = path.map(quoteDottedString).join(".");
var line = node.line;
var column = node.column;
if (pathAssigned(quotedPath)) {
genError("Cannot redefine existing key '" + path + "'.", line, column);
}
assignedPaths.push(quotedPath);
context = deepRef(data, path, {}, line, column);
currentPath = path;
}
function addTableArray(node) {
var path = node.value;
var quotedPath = path.map(quoteDottedString).join(".");
var line = node.line;
var column = node.column;
if (!pathAssigned(quotedPath)) {
assignedPaths.push(quotedPath);
}
assignedPaths = assignedPaths.filter(function(p) {
return p.indexOf(quotedPath) !== 0;
});
assignedPaths.push(quotedPath);
context = deepRef(data, path, [], line, column);
currentPath = quotedPath;
if (context instanceof Array) {
var newObj = {};
context.push(newObj);
context = newObj;
} else {
genError("Cannot redefine existing key '" + path + "'.", line, column);
}
}
// Given a path 'a.b.c', create (as necessary) `start.a`,
// `start.a.b`, and `start.a.b.c`, assigning `value` to `start.a.b.c`.
// If `a` or `b` are arrays and have items in them, the last item in the
// array is used as the context for the next sub-path.
function deepRef(start, keys, value, line, column) {
var traversed = [];
var traversedPath = "";
var path = keys.join(".");
var ctx = start;
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
traversed.push(key);
traversedPath = traversed.join(".");
if (typeof ctx[key] === "undefined") {
if (i === keys.length - 1) {
ctx[key] = value;
} else {
ctx[key] = {};
}
} else if (i !== keys.length - 1 && valueAssignments.indexOf(traversedPath) > -1) {
// already a non-object value at key, can't be used as part of a new path
genError("Cannot redefine existing key '" + traversedPath + "'.", line, column);
}
ctx = ctx[key];
if (ctx instanceof Array && ctx.length && i < keys.length - 1) {
ctx = ctx[ctx.length - 1];
}
}
return ctx;
}
function reduceArrayWithTypeChecking(array) {
// Ensure that all items in the array are of the same type
var firstType = null;
for (var i = 0; i < array.length; i++) {
var node = array[i];
if (firstType === null) {
firstType = node.type;
} else {
if (node.type !== firstType) {
genError("Cannot add value of type " + node.type + " to array of type " +
firstType + ".", node.line, node.column);
}
}
}
// Recursively reduce array of nodes into array of the nodes' values
return array.map(reduceValueNode);
}
function quoteDottedString(str) {
if (str.indexOf(".") > -1) {
return "\"" + str + "\"";
} else {
return str;
}
}
}
module.exports = {
compile: compile
};

3841
node_modules/toml/lib/parser.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

59
node_modules/toml/package.json generated vendored Normal file
View File

@ -0,0 +1,59 @@
{
"_from": "toml@^2.3.3",
"_id": "toml@2.3.6",
"_inBundle": false,
"_integrity": "sha512-gVweAectJU3ebq//Ferr2JUY4WKSDe5N+z0FvjDncLGyHmIDoxgY/2Ie4qfEIDm4IS7OA6Rmdm7pdEEdMcV/xQ==",
"_location": "/toml",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "toml@^2.3.3",
"name": "toml",
"escapedName": "toml",
"rawSpec": "^2.3.3",
"saveSpec": null,
"fetchSpec": "^2.3.3"
},
"_requiredBy": [
"/"
],
"_resolved": "https://registry.npmjs.org/toml/-/toml-2.3.6.tgz",
"_shasum": "25b0866483a9722474895559088b436fd11f861b",
"_spec": "toml@^2.3.3",
"_where": "/home/sergiu/linx-audio-simulator",
"author": {
"name": "Michelle Tilley",
"email": "michelle@michelletilley.net"
},
"bugs": {
"url": "https://github.com/BinaryMuse/toml-node/issues"
},
"bundleDependencies": false,
"deprecated": false,
"description": "TOML parser for Node.js (parses TOML spec v0.4.0)",
"devDependencies": {
"jshint": "*",
"nodeunit": "~0.9.0",
"pegjs": "~0.8.0"
},
"homepage": "https://github.com/BinaryMuse/toml-node#readme",
"keywords": [
"toml",
"parser"
],
"license": "MIT",
"main": "index.js",
"name": "toml",
"repository": {
"type": "git",
"url": "git://github.com/BinaryMuse/toml-node.git"
},
"scripts": {
"build": "pegjs --cache src/toml.pegjs lib/parser.js",
"prepublish": "npm run build",
"test": "jshint lib/compiler.js && nodeunit test/test_*.js"
},
"types": "index.d.ts",
"version": "2.3.6"
}

231
node_modules/toml/src/toml.pegjs generated vendored Normal file
View File

@ -0,0 +1,231 @@
{
var nodes = [];
function genError(err, line, col) {
var ex = new Error(err);
ex.line = line;
ex.column = col;
throw ex;
}
function addNode(node) {
nodes.push(node);
}
function node(type, value, line, column, key) {
var obj = { type: type, value: value, line: line(), column: column() };
if (key) obj.key = key;
return obj;
}
function convertCodePoint(str, line, col) {
var num = parseInt("0x" + str);
if (
!isFinite(num) ||
Math.floor(num) != num ||
num < 0 ||
num > 0x10FFFF ||
(num > 0xD7FF && num < 0xE000)
) {
genError("Invalid Unicode escape code: " + str, line, col);
} else {
return fromCodePoint(num);
}
}
function fromCodePoint() {
var MAX_SIZE = 0x4000;
var codeUnits = [];
var highSurrogate;
var lowSurrogate;
var index = -1;
var length = arguments.length;
if (!length) {
return '';
}
var result = '';
while (++index < length) {
var codePoint = Number(arguments[index]);
if (codePoint <= 0xFFFF) { // BMP code point
codeUnits.push(codePoint);
} else { // Astral code point; split in surrogate halves
// http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
codePoint -= 0x10000;
highSurrogate = (codePoint >> 10) + 0xD800;
lowSurrogate = (codePoint % 0x400) + 0xDC00;
codeUnits.push(highSurrogate, lowSurrogate);
}
if (index + 1 == length || codeUnits.length > MAX_SIZE) {
result += String.fromCharCode.apply(null, codeUnits);
codeUnits.length = 0;
}
}
return result;
}
}
start
= line* { return nodes }
line
= S* expr:expression S* comment* (NL+ / EOF)
/ S+ (NL+ / EOF)
/ NL
expression
= comment / path / tablearray / assignment
comment
= '#' (!(NL / EOF) .)*
path
= '[' S* name:table_key S* ']' { addNode(node('ObjectPath', name, line, column)) }
tablearray
= '[' '[' S* name:table_key S* ']' ']' { addNode(node('ArrayPath', name, line, column)) }
table_key
= parts:dot_ended_table_key_part+ name:table_key_part { return parts.concat(name) }
/ name:table_key_part { return [name] }
table_key_part
= S* name:key S* { return name }
/ S* name:quoted_key S* { return name }
dot_ended_table_key_part
= S* name:key S* '.' S* { return name }
/ S* name:quoted_key S* '.' S* { return name }
assignment
= key:key S* '=' S* value:value { addNode(node('Assign', value, line, column, key)) }
/ key:quoted_key S* '=' S* value:value { addNode(node('Assign', value, line, column, key)) }
key
= chars:ASCII_BASIC+ { return chars.join('') }
quoted_key
= node:double_quoted_single_line_string { return node.value }
/ node:single_quoted_single_line_string { return node.value }
value
= string / datetime / float / integer / boolean / array / inline_table
string
= double_quoted_multiline_string
/ double_quoted_single_line_string
/ single_quoted_multiline_string
/ single_quoted_single_line_string
double_quoted_multiline_string
= '"""' NL? chars:multiline_string_char* '"""' { return node('String', chars.join(''), line, column) }
double_quoted_single_line_string
= '"' chars:string_char* '"' { return node('String', chars.join(''), line, column) }
single_quoted_multiline_string
= "'''" NL? chars:multiline_literal_char* "'''" { return node('String', chars.join(''), line, column) }
single_quoted_single_line_string
= "'" chars:literal_char* "'" { return node('String', chars.join(''), line, column) }
string_char
= ESCAPED / (!'"' char:. { return char })
literal_char
= (!"'" char:. { return char })
multiline_string_char
= ESCAPED / multiline_string_delim / (!'"""' char:. { return char})
multiline_string_delim
= '\\' NL NLS* { return '' }
multiline_literal_char
= (!"'''" char:. { return char })
float
= left:(float_text / integer_text) ('e' / 'E') right:integer_text { return node('Float', parseFloat(left + 'e' + right), line, column) }
/ text:float_text { return node('Float', parseFloat(text), line, column) }
float_text
= '+'? digits:(DIGITS '.' DIGITS) { return digits.join('') }
/ '-' digits:(DIGITS '.' DIGITS) { return '-' + digits.join('') }
integer
= text:integer_text { return node('Integer', parseInt(text, 10), line, column) }
integer_text
= '+'? digits:DIGIT+ !'.' { return digits.join('') }
/ '-' digits:DIGIT+ !'.' { return '-' + digits.join('') }
boolean
= 'true' { return node('Boolean', true, line, column) }
/ 'false' { return node('Boolean', false, line, column) }
array
= '[' array_sep* ']' { return node('Array', [], line, column) }
/ '[' value:array_value? ']' { return node('Array', value ? [value] : [], line, column) }
/ '[' values:array_value_list+ ']' { return node('Array', values, line, column) }
/ '[' values:array_value_list+ value:array_value ']' { return node('Array', values.concat(value), line, column) }
array_value
= array_sep* value:value array_sep* { return value }
array_value_list
= array_sep* value:value array_sep* ',' array_sep* { return value }
array_sep
= S / NL / comment
inline_table
= '{' S* values:inline_table_assignment* S* '}' { return node('InlineTable', values, line, column) }
inline_table_assignment
= S* key:key S* '=' S* value:value S* ',' S* { return node('InlineTableValue', value, line, column, key) }
/ S* key:key S* '=' S* value:value { return node('InlineTableValue', value, line, column, key) }
secfragment
= '.' digits:DIGITS { return "." + digits }
date
= date:(
DIGIT DIGIT DIGIT DIGIT
'-'
DIGIT DIGIT
'-'
DIGIT DIGIT
) { return date.join('') }
time
= time:(DIGIT DIGIT ':' DIGIT DIGIT ':' DIGIT DIGIT secfragment?) { return time.join('') }
time_with_offset
= time:(
DIGIT DIGIT ':' DIGIT DIGIT ':' DIGIT DIGIT secfragment?
('-' / '+')
DIGIT DIGIT ':' DIGIT DIGIT
) { return time.join('') }
datetime
= date:date 'T' time:time 'Z' { return node('Date', new Date(date + "T" + time + "Z"), line, column) }
/ date:date 'T' time:time_with_offset { return node('Date', new Date(date + "T" + time), line, column) }
S = [ \t]
NL = "\n" / "\r" "\n"
NLS = NL / S
EOF = !.
HEX = [0-9a-f]i
DIGIT = DIGIT_OR_UNDER
DIGIT_OR_UNDER = [0-9]
/ '_' { return "" }
ASCII_BASIC = [A-Za-z0-9_\-]
DIGITS = d:DIGIT_OR_UNDER+ { return d.join('') }
ESCAPED = '\\"' { return '"' }
/ '\\\\' { return '\\' }
/ '\\b' { return '\b' }
/ '\\t' { return '\t' }
/ '\\n' { return '\n' }
/ '\\f' { return '\f' }
/ '\\r' { return '\r' }
/ ESCAPED_UNICODE
ESCAPED_UNICODE = "\\U" digits:(HEX HEX HEX HEX HEX HEX HEX HEX) { return convertCodePoint(digits.join('')) }
/ "\\u" digits:(HEX HEX HEX HEX) { return convertCodePoint(digits.join('')) }

5
node_modules/toml/test/bad.toml generated vendored Normal file
View File

@ -0,0 +1,5 @@
[something]
awesome = "this is"
[something.awesome]
this = "isn't"

32
node_modules/toml/test/example.toml generated vendored Normal file
View File

@ -0,0 +1,32 @@
# This is a TOML document. Boom.
title = "TOML Example"
[owner]
name = "Tom Preston-Werner"
organization = "GitHub"
bio = "GitHub Cofounder & CEO\n\tLikes \"tater tots\" and beer and backslashes: \\"
dob = 1979-05-27T07:32:00Z # First class dates? Why not?
[database]
server = "192.168.1.1"
ports = [ 8001, 8001, 8003 ]
connection_max = 5000
connection_min = -2 # Don't ask me how
max_temp = 87.1 # It's a float
min_temp = -17.76
enabled = true
[servers]
# You can indent as you please. Tabs or spaces. TOML don't care.
[servers.alpha]
ip = "10.0.0.1"
dc = "eqdc10"
[servers.beta]
ip = "10.0.0.2"
dc = "eqdc10"
[clients]
data = [ ["gamma", "delta"], [1, 2] ] # just an update to make sure parsers support it

33
node_modules/toml/test/hard_example.toml generated vendored Normal file
View File

@ -0,0 +1,33 @@
# Test file for TOML
# Only this one tries to emulate a TOML file written by a user of the kind of parser writers probably hate
# This part you'll really hate
[the]
test_string = "You'll hate me after this - #" # " Annoying, isn't it?
[the.hard]
test_array = [ "] ", " # "] # ] There you go, parse this!
test_array2 = [ "Test #11 ]proved that", "Experiment #9 was a success" ]
# You didn't think it'd as easy as chucking out the last #, did you?
another_test_string = " Same thing, but with a string #"
harder_test_string = " And when \"'s are in the string, along with # \"" # "and comments are there too"
# Things will get harder
[the.hard."bit#"]
"what?" = "You don't think some user won't do that?"
multi_line_array = [
"]",
# ] Oh yes I did
]
# Each of the following keygroups/key value pairs should produce an error. Uncomment to them to test
#[error] if you didn't catch this, your parser is broken
#string = "Anything other than tabs, spaces and newline after a keygroup or key value pair has ended should produce an error unless it is a comment" like this
#array = [
# "This might most likely happen in multiline arrays",
# Like here,
# "or here,
# and here"
# ] End of array comment, forgot the #
#number = 3.14 pi <--again forgot the #

10
node_modules/toml/test/inline_tables.toml generated vendored Normal file
View File

@ -0,0 +1,10 @@
name = { first = "Tom", last = "Preston-Werner" }
point = { x = 1, y = 2 }
nested = { x = { a = { b = 3 } } }
points = [ { x = 1, y = 2, z = 3 },
{ x = 7, y = 8, z = 9 },
{ x = 2, y = 4, z = 8 } ]
arrays = [ { x = [1, 2, 3], y = [4, 5, 6] },
{ x = [7, 8, 9], y = [0, 1, 2] } ]

5
node_modules/toml/test/literal_strings.toml generated vendored Normal file
View File

@ -0,0 +1,5 @@
# What you see is what you get.
winpath = 'C:\Users\nodejs\templates'
winpath2 = '\\ServerX\admin$\system32\'
quoted = 'Tom "Dubs" Preston-Werner'
regex = '<\i\c*\s*>'

15
node_modules/toml/test/multiline_eat_whitespace.toml generated vendored Normal file
View File

@ -0,0 +1,15 @@
# The following strings are byte-for-byte equivalent:
key1 = "The quick brown fox jumps over the lazy dog."
key2 = """
The quick brown \
fox jumps over \
the lazy dog."""
key3 = """\
The quick brown \
fox jumps over \
the lazy dog.\
"""

View File

@ -0,0 +1,7 @@
regex2 = '''I [dw]on't need \d{2} apples'''
lines = '''
The first newline is
trimmed in raw strings.
All other whitespace
is preserved.
'''

6
node_modules/toml/test/multiline_strings.toml generated vendored Normal file
View File

@ -0,0 +1,6 @@
# The following strings are byte-for-byte equivalent:
key1 = "One\nTwo"
key2 = """One\nTwo"""
key3 = """
One
Two"""

22
node_modules/toml/test/smoke.js generated vendored Normal file
View File

@ -0,0 +1,22 @@
var fs = require('fs');
var parser = require('../index');
var codes = [
"# test\n my.key=\"value\"\nother = 101\nthird = -37",
"first = 1.2\nsecond = -56.02\nth = true\nfth = false",
"time = 1979-05-27T07:32:00Z",
"test = [\"one\", ]",
"test = [[1, 2,], [true, false,],]",
"[my.sub.path]\nkey = true\nother = -15.3\n[my.sub]\nkey=false",
"arry = [\"one\", \"two\",\"thr\nee\", \"\\u03EA\"]",
fs.readFileSync(__dirname + '/example.toml', 'utf8'),
fs.readFileSync(__dirname + '/hard_example.toml', 'utf8')
]
console.log("=============================================");
for(i in codes) {
var code = codes[i];
console.log(code + "\n");
console.log(JSON.stringify(parser.parse(code)));
console.log("=============================================");
}

10
node_modules/toml/test/table_arrays_easy.toml generated vendored Normal file
View File

@ -0,0 +1,10 @@
[[products]]
name = "Hammer"
sku = 738594937
[[products]]
[[products]]
name = "Nail"
sku = 284758393
color = "gray"

31
node_modules/toml/test/table_arrays_hard.toml generated vendored Normal file
View File

@ -0,0 +1,31 @@
[[fruit]]
name = "durian"
variety = []
[[fruit]]
name = "apple"
[fruit.physical]
color = "red"
shape = "round"
[[fruit.variety]]
name = "red delicious"
[[fruit.variety]]
name = "granny smith"
[[fruit]]
[[fruit]]
name = "banana"
[[fruit.variety]]
name = "plantain"
[[fruit]]
name = "orange"
[fruit.physical]
color = "orange"
shape = "round"

586
node_modules/toml/test/test_toml.js generated vendored Normal file
View File

@ -0,0 +1,586 @@
var toml = require('../');
var fs = require('fs');
var assert = require("nodeunit").assert;
assert.parsesToml = function(tomlStr, expected) {
try {
var actual = toml.parse(tomlStr);
} catch (e) {
var errInfo = "line: " + e.line + ", column: " + e.column;
return assert.fail("TOML parse error: " + e.message, errInfo, null, "at", assert.parsesToml);
}
return assert.deepEqual(actual, expected);
};
var exampleExpected = {
title: "TOML Example",
owner: {
name: "Tom Preston-Werner",
organization: "GitHub",
bio: "GitHub Cofounder & CEO\n\tLikes \"tater tots\" and beer and backslashes: \\",
dob: new Date("1979-05-27T07:32:00Z")
},
database: {
server: "192.168.1.1",
ports: [8001, 8001, 8003],
connection_max: 5000,
connection_min: -2,
max_temp: 87.1,
min_temp: -17.76,
enabled: true
},
servers: {
alpha: {
ip: "10.0.0.1",
dc: "eqdc10"
},
beta: {
ip: "10.0.0.2",
dc: "eqdc10"
}
},
clients: {
data: [ ["gamma", "delta"], [1, 2] ]
}
};
var hardExampleExpected = {
the: {
hard: {
another_test_string: ' Same thing, but with a string #',
'bit#': {
multi_line_array: [']'],
'what?': "You don't think some user won't do that?"
},
harder_test_string: " And when \"'s are in the string, along with # \"",
test_array: ['] ', ' # '],
test_array2: ['Test #11 ]proved that', 'Experiment #9 was a success']
},
test_string: "You'll hate me after this - #"
}
};
var easyTableArrayExpected = {
"products": [
{ "name": "Hammer", "sku": 738594937 },
{ },
{ "name": "Nail", "sku": 284758393, "color": "gray" }
]
};
var hardTableArrayExpected = {
"fruit": [
{
"name": "durian",
"variety": []
},
{
"name": "apple",
"physical": {
"color": "red",
"shape": "round"
},
"variety": [
{ "name": "red delicious" },
{ "name": "granny smith" }
]
},
{},
{
"name": "banana",
"variety": [
{ "name": "plantain" }
]
},
{
"name": "orange",
"physical": {
"color": "orange",
"shape": "round"
}
}
]
}
var badInputs = [
'[error] if you didn\'t catch this, your parser is broken',
'string = "Anything other than tabs, spaces and newline after a table or key value pair has ended should produce an error unless it is a comment" like this',
'array = [\n \"This might most likely happen in multiline arrays\",\n Like here,\n \"or here,\n and here\"\n ] End of array comment, forgot the #',
'number = 3.14 pi <--again forgot the #'
];
exports.testParsesExample = function(test) {
var str = fs.readFileSync(__dirname + "/example.toml", 'utf-8')
test.parsesToml(str, exampleExpected);
test.done();
};
exports.testParsesHardExample = function(test) {
var str = fs.readFileSync(__dirname + "/hard_example.toml", 'utf-8')
test.parsesToml(str, hardExampleExpected);
test.done();
};
exports.testEasyTableArrays = function(test) {
var str = fs.readFileSync(__dirname + "/table_arrays_easy.toml", 'utf8')
test.parsesToml(str, easyTableArrayExpected);
test.done();
};
exports.testHarderTableArrays = function(test) {
var str = fs.readFileSync(__dirname + "/table_arrays_hard.toml", 'utf8')
test.parsesToml(str, hardTableArrayExpected);
test.done();
};
exports.testSupportsTrailingCommasInArrays = function(test) {
var str = 'arr = [1, 2, 3,]';
var expected = { arr: [1, 2, 3] };
test.parsesToml(str, expected);
test.done();
};
exports.testSingleElementArrayWithNoTrailingComma = function(test) {
var str = "a = [1]";
test.parsesToml(str, {
a: [1]
});
test.done();
};
exports.testEmptyArray = function(test) {
var str = "a = []";
test.parsesToml(str, {
a: []
});
test.done();
};
exports.testArrayWithWhitespace = function(test) {
var str = "[versions]\nfiles = [\n 3, \n 5 \n\n ]";
test.parsesToml(str, {
versions: {
files: [3, 5]
}
});
test.done();
};
exports.testEmptyArrayWithWhitespace = function(test) {
var str = "[versions]\nfiles = [\n \n ]";
test.parsesToml(str, {
versions: {
files: []
}
});
test.done();
};
exports.testDefineOnSuperkey = function(test) {
var str = "[a.b]\nc = 1\n\n[a]\nd = 2";
var expected = {
a: {
b: {
c: 1
},
d: 2
}
};
test.parsesToml(str, expected);
test.done();
};
exports.testWhitespace = function(test) {
var str = "a = 1\n \n b = 2 ";
test.parsesToml(str, {
a: 1, b: 2
});
test.done();
};
exports.testUnicode = function(test) {
var str = "str = \"My name is Jos\\u00E9\"";
test.parsesToml(str, {
str: "My name is Jos\u00E9"
});
var str = "str = \"My name is Jos\\U000000E9\"";
test.parsesToml(str, {
str: "My name is Jos\u00E9"
});
test.done();
};
exports.testMultilineStrings = function(test) {
var str = fs.readFileSync(__dirname + "/multiline_strings.toml", 'utf8');
test.parsesToml(str, {
key1: "One\nTwo",
key2: "One\nTwo",
key3: "One\nTwo"
});
test.done();
};
exports.testMultilineEatWhitespace = function(test) {
var str = fs.readFileSync(__dirname + "/multiline_eat_whitespace.toml", 'utf8');
test.parsesToml(str, {
key1: "The quick brown fox jumps over the lazy dog.",
key2: "The quick brown fox jumps over the lazy dog.",
key3: "The quick brown fox jumps over the lazy dog."
});
test.done();
};
exports.testLiteralStrings = function(test) {
var str = fs.readFileSync(__dirname + "/literal_strings.toml", 'utf8');
test.parsesToml(str, {
winpath: "C:\\Users\\nodejs\\templates",
winpath2: "\\\\ServerX\\admin$\\system32\\",
quoted: "Tom \"Dubs\" Preston-Werner",
regex: "<\\i\\c*\\s*>"
});
test.done();
};
exports.testMultilineLiteralStrings = function(test) {
var str = fs.readFileSync(__dirname + "/multiline_literal_strings.toml", 'utf8');
test.parsesToml(str, {
regex2: "I [dw]on't need \\d{2} apples",
lines: "The first newline is\ntrimmed in raw strings.\n All other whitespace\n is preserved.\n"
});
test.done();
};
exports.testIntegerFormats = function(test) {
var str = "a = +99\nb = 42\nc = 0\nd = -17\ne = 1_000_001\nf = 1_2_3_4_5 # why u do dis";
test.parsesToml(str, {
a: 99,
b: 42,
c: 0,
d: -17,
e: 1000001,
f: 12345
});
test.done();
};
exports.testFloatFormats = function(test) {
var str = "a = +1.0\nb = 3.1415\nc = -0.01\n" +
"d = 5e+22\ne = 1e6\nf = -2E-2\n" +
"g = 6.626e-34\n" +
"h = 9_224_617.445_991_228_313\n" +
"i = 1e1_000";
test.parsesToml(str, {
a: 1.0,
b: 3.1415,
c: -0.01,
d: 5e22,
e: 1e6,
f: -2e-2,
g: 6.626e-34,
h: 9224617.445991228313,
i: 1e1000
});
test.done();
};
exports.testDate = function(test) {
var date = new Date("1979-05-27T07:32:00Z");
test.parsesToml("a = 1979-05-27T07:32:00Z", {
a: date
});
test.done();
};
exports.testDateWithOffset = function(test) {
var date1 = new Date("1979-05-27T07:32:00-07:00"),
date2 = new Date("1979-05-27T07:32:00+02:00");
test.parsesToml("a = 1979-05-27T07:32:00-07:00\nb = 1979-05-27T07:32:00+02:00", {
a: date1,
b: date2
});
test.done();
};
exports.testDateWithSecondFraction = function(test) {
var date = new Date("1979-05-27T00:32:00.999999-07:00");
test.parsesToml("a = 1979-05-27T00:32:00.999999-07:00", {
a: date
});
test.done();
};
exports.testDateFromIsoString = function(test) {
// https://github.com/BinaryMuse/toml-node/issues/20
var date = new Date(),
dateStr = date.toISOString(),
tomlStr = "a = " + dateStr;
test.parsesToml(tomlStr, {
a: date
});
test.done();
};
exports.testLeadingNewlines = function(test) {
// https://github.com/BinaryMuse/toml-node/issues/22
var str = "\ntest = \"ing\"";
test.parsesToml(str, {
test: "ing"
});
test.done();
};
exports.testInlineTables = function(test) {
var str = fs.readFileSync(__dirname + "/inline_tables.toml", 'utf8');
test.parsesToml(str, {
name: {
first: "Tom",
last: "Preston-Werner"
},
point: {
x: 1,
y: 2
},
nested: {
x: {
a: {
b: 3
}
}
},
points: [
{ x: 1, y: 2, z: 3 },
{ x: 7, y: 8, z: 9 },
{ x: 2, y: 4, z: 8 }
],
arrays: [
{ x: [1, 2, 3], y: [4, 5, 6] },
{ x: [7, 8, 9], y: [0, 1, 2] }
]
});
test.done();
};
exports.testEmptyInlineTables = function(test) {
// https://github.com/BinaryMuse/toml-node/issues/24
var str = "a = { }";
test.parsesToml(str, {
a: {}
});
test.done();
};
exports.testKeyNamesWithWhitespaceAroundStartAndFinish = function(test) {
var str = "[ a ]\nb = 1";
test.parsesToml(str, {
a: {
b: 1
}
});
test.done();
};
exports.testKeyNamesWithWhitespaceAroundDots = function(test) {
var str = "[ a . b . c]\nd = 1";
test.parsesToml(str, {
a: {
b: {
c: {
d: 1
}
}
}
});
test.done();
};
exports.testSimpleQuotedKeyNames = function(test) {
var str = "[\"ʞ\"]\na = 1";
test.parsesToml(str, {
"ʞ": {
a: 1
}
});
test.done();
};
exports.testComplexQuotedKeyNames = function(test) {
var str = "[ a . \"ʞ\" . c ]\nd = 1";
test.parsesToml(str, {
a: {
"ʞ": {
c: {
d: 1
}
}
}
});
test.done();
};
exports.testEscapedQuotesInQuotedKeyNames = function(test) {
test.parsesToml("[\"the \\\"thing\\\"\"]\na = true", {
'the "thing"': {
a: true
}
});
test.done();
};
exports.testMoreComplexQuotedKeyNames = function(test) {
// https://github.com/BinaryMuse/toml-node/issues/21
test.parsesToml('["the\\ key"]\n\none = "one"\ntwo = 2\nthree = false', {
"the\\ key": {
one: "one",
two: 2,
three: false
}
});
test.parsesToml('[a."the\\ key"]\n\none = "one"\ntwo = 2\nthree = false', {
a: {
"the\\ key": {
one: "one",
two: 2,
three: false
}
}
});
test.parsesToml('[a."the-key"]\n\none = "one"\ntwo = 2\nthree = false', {
a: {
"the-key": {
one: "one",
two: 2,
three: false
}
}
});
test.parsesToml('[a."the.key"]\n\none = "one"\ntwo = 2\nthree = false', {
a: {
"the.key": {
one: "one",
two: 2,
three: false
}
}
});
// https://github.com/BinaryMuse/toml-node/issues/34
test.parsesToml('[table]\n\'a "quoted value"\' = "value"', {
table: {
'a "quoted value"': "value"
}
});
// https://github.com/BinaryMuse/toml-node/issues/33
test.parsesToml('[module]\n"foo=bar" = "zzz"', {
module: {
"foo=bar": "zzz"
}
});
test.done();
};
exports.testErrorOnBadUnicode = function(test) {
var str = "str = \"My name is Jos\\uD800\"";
test.throws(function() {
toml.parse(str);
});
test.done();
};
exports.testErrorOnDotAtStartOfKey = function(test) {
test.throws(function() {
var str = "[.a]\nb = 1";
toml.parse(str);
});
test.done()
};
exports.testErrorOnDotAtEndOfKey = function(test) {
test.throws(function() {
var str = "[.a]\nb = 1";
toml.parse(str);
});
test.done()
};
exports.testErrorOnTableOverride = function(test) {
test.throws(function() {
var str = "[a]\nb = 1\n\n[a]\nc = 2";
toml.parse(str);
});
test.done()
};
exports.testErrorOnKeyOverride = function(test) {
test.throws(function() {
var str = "[a]\nb = 1\n[a.b]\nc = 2";
toml.parse(str);
});
test.done()
};
exports.testErrorOnKeyOverrideWithNested = function(test) {
// https://github.com/BinaryMuse/toml-node/issues/23
test.throws(function() {
var str = "[a]\nb = \"a\"\n[a.b.c]";
toml.parse(str);
}, "existing key 'a.b'");
test.done();
};
exports.testErrorOnKeyOverrideWithArrayTable = function(test) {
test.throws(function() {
var str = "[a]\nb = 1\n[[a]]\nc = 2";
toml.parse(str);
});
test.done()
};
exports.testErrorOnKeyReplace = function(test) {
test.throws(function() {
var str = "[a]\nb = 1\nb = 2";
toml.parse(str);
});
test.done()
};
exports.testErrorOnInlineTableReplace = function(test) {
// https://github.com/BinaryMuse/toml-node/issues/25
test.throws(function() {
var str = "a = { b = 1 }\n[a]\nc = 2";
toml.parse(str);
}, "existing key 'a'");
test.done();
};
exports.testErrorOnArrayMismatch = function(test) {
test.throws(function() {
var str = 'data = [1, 2, "test"]'
toml.parse(str);
});
test.done();
};
exports.testErrorOnBadInputs = function(test) {
var count = 0;
for (i in badInputs) {
(function(num) {
test.throws(function() {
toml.parse(badInputs[num]);
});
})(i);
}
test.done();
};
exports.testErrorsHaveCorrectLineAndColumn = function(test) {
var str = "[a]\nb = 1\n [a.b]\nc = 2";
try { toml.parse(str); }
catch (e) {
test.equal(e.line, 3);
test.equal(e.column, 2);
test.done();
}
};