forked from enviPath/enviPy
Current Dev State
This commit is contained in:
21
static/js/ketcher2/node_modules/varstream/LICENCE
generated
vendored
Executable file
21
static/js/ketcher2/node_modules/varstream/LICENCE
generated
vendored
Executable file
@ -0,0 +1,21 @@
|
||||
The MIT License
|
||||
|
||||
Copyright (c) 2013 Nicolas Froidure, <http://insertafter.com/>
|
||||
|
||||
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.
|
||||
136
static/js/ketcher2/node_modules/varstream/README.md
generated
vendored
Executable file
136
static/js/ketcher2/node_modules/varstream/README.md
generated
vendored
Executable file
@ -0,0 +1,136 @@
|
||||
# VarStream
|
||||
> VarStream is a data storage and exchange format.
|
||||
|
||||
[](https://npmjs.org/package/varstream) [](https://travis-ci.org/nfroidure/VarStream) [](https://david-dm.org/nfroidure/VarStream) [](https://david-dm.org/nfroidure/VarStream#info=devDependencies) [](https://coveralls.io/r/nfroidure/VarStream?branch=master)
|
||||
|
||||
VarStream :
|
||||
* is human readable/writeable : no need to be a programmer to create VarStreams.
|
||||
* is streamable : No need to wait the datas to be fully loaded to
|
||||
populate/access your program variables.
|
||||
* keeps backward references: you can refer to another variable of the stream
|
||||
in the stream itself.
|
||||
* merges with no loss: you can easily merge multiple varstreams.
|
||||
* is light: due to it's smart optimizations and syntax sugar.
|
||||
* is memory efficient: the garbage collector can cleanup memory before the parse
|
||||
ends, backward references prevent data duplication.
|
||||
* accept comments: keep your configuration/localization files readable.
|
||||
* loves circular references: transmit your variable trees with no hack.
|
||||
|
||||
## Use cases
|
||||
|
||||
### Smarter configuration files
|
||||
VarStream allows you to configure your projects in a clear and readable way.
|
||||
Since VarStream is merge friendly, it is particularly usefull for loading
|
||||
multilevel configuration files without erasing previously set contents.
|
||||
|
||||
Imagine this sample configuration file:
|
||||
|
||||
```
|
||||
# Server
|
||||
server.domain=example.com
|
||||
server.protocols.+=http
|
||||
server.protocols.+=https
|
||||
server.databases.+.host=db1.example.com
|
||||
server.databases.*.username=db1
|
||||
server.databases.+.host=db2.example.com
|
||||
server.databases.*.username=db2
|
||||
server.cache.size=2048
|
||||
# HTML document
|
||||
document.scripts.+.uri=//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js
|
||||
document.scripts.+.uri=//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js
|
||||
```
|
||||
|
||||
You could easily override some of its contents by loading this specific
|
||||
configuration file next to him:
|
||||
|
||||
```
|
||||
# Append my custom dev TLD
|
||||
server.domain+=.local
|
||||
# Support 1 more protocol
|
||||
server.protocols.+=ws
|
||||
# Reset DB and set my local one
|
||||
server.databases.!.host=localhost
|
||||
server.databases.*.username=db1
|
||||
# Increase cache size (8 times)
|
||||
server.cache.size*=8
|
||||
# Use local scripts
|
||||
document.scripts.0.uri=javascript/jquery.js
|
||||
document.scripts.1.uri=javascript/jquery-ui.js
|
||||
```
|
||||
|
||||
The same goes for internationalization files. You could load a language file and
|
||||
augment it with a locale file.
|
||||
|
||||
### Sharing variable trees in realtime
|
||||
VarStreams particularly suits with the JavaScript messaging systems. Communicate
|
||||
through different JavaScript threads (or over the Network) has never been so
|
||||
simple.
|
||||
|
||||
This is particularly usefull for data driven applications.
|
||||
|
||||
## Test it !
|
||||
* [draw content before its full load](http://server.elitwork.com/experiments/pagestream/index.html).
|
||||
* [loading charts progressively](http://server.elitwork.com/experiments/chartstream/index.html).
|
||||
* [maintain a variable tree beetween many processes with web sockets](https://github.com/nfroidure/WebSockIPC).
|
||||
* claim yours !
|
||||
|
||||
## Performances
|
||||
Compared to JSON, VarStreams brings nice formatting with often less weight.
|
||||
* test1 : linear.dat [390 bytes] vs linear.json [423 bytes] => 8% smaller
|
||||
* test2 : arrays.dat [1244 bytes] vs arrays.json [1178 bytes] => 6% bigger
|
||||
* test3 : references.dat [2844 bytes] vs references.json [3314 bytes] => 16% smaller
|
||||
|
||||
## How to use
|
||||
With NodeJs :
|
||||
```js
|
||||
// Synchronous API
|
||||
var cnt = fs.ReadFileSync('test2.dat', {encoding: 'utf-8'});
|
||||
// Parse VarStream content
|
||||
var obj = VarStream.parse(cnt);
|
||||
// Get an Object content as a VarStream
|
||||
cnt = VarStream.stringify(obj);
|
||||
|
||||
// Streaming
|
||||
var VarStream = require('varstream');
|
||||
var fs = require('fs');
|
||||
|
||||
var scope = {}; // The root scope
|
||||
var myVarStream=new VarStream(scope, 'prop');
|
||||
// Reading var stream from a file
|
||||
fs.createReadStream('test.dat').pipe(myVarStream)
|
||||
.on('end', function () {
|
||||
// Piping VarStream to a file
|
||||
myVarStream.pipe(fs.createWriteStream('test2.dat'));
|
||||
});
|
||||
```
|
||||
|
||||
In the browser, you can use browserify or directly VarStreamReader and
|
||||
VarStreamWriter constructors.
|
||||
|
||||
## CLI Usage
|
||||
VarStream comes with two CLI utilities, to use them, install VarStream globally:
|
||||
```sh
|
||||
npm install -g varstream
|
||||
# Convert JSON datas to VarStream
|
||||
json2varstream path/to/input.json > path/to/ouput.dat
|
||||
# Convert VarStreams datas to JSON
|
||||
varstream2json path/to/input.dat > path/to/ouput.json
|
||||
```
|
||||
|
||||
## Contributing/Testing
|
||||
The VarStream JavaScript library is fully tested. If you want to contribute,
|
||||
test your code before submitting, just run the following command with
|
||||
NodeJS dependencies installed :
|
||||
```js
|
||||
npm test
|
||||
```
|
||||
|
||||
## Contributors
|
||||
* Nicolas Froidure - @nfroidure
|
||||
|
||||
## License
|
||||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
38
static/js/ketcher2/node_modules/varstream/cli/json2varstream.js
generated
vendored
Executable file
38
static/js/ketcher2/node_modules/varstream/cli/json2varstream.js
generated
vendored
Executable file
@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
var VarStream = require(__dirname + '/../src/VarStream')
|
||||
, fs = require('fs')
|
||||
;
|
||||
|
||||
if(process.argv[2]) {
|
||||
var scope = {}, myVarStream;
|
||||
// Reading the file
|
||||
fs.readFile(process.argv[2], function read(err, data) {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
// Parsing the JSON datas
|
||||
try {
|
||||
scope.vars = JSON.parse(data);
|
||||
} catch (err) {
|
||||
console.error('Bad JSON file', err);
|
||||
}
|
||||
// Creating the varstream
|
||||
myVarStream = new VarStream(scope, 'vars', VarStream.Writer.OPTIONS);
|
||||
// Creating the write stream
|
||||
if(!process.argv[3]) {
|
||||
myVarStream.pipe(process.stdout);
|
||||
return;
|
||||
}
|
||||
var wS = fs.createWriteStream(process.argv[3]);
|
||||
// Piping it to the ouput file
|
||||
myVarStream.pipe(wS);
|
||||
myVarStream.on('close', function() {
|
||||
console.log('Saved!');
|
||||
});
|
||||
});
|
||||
} else {
|
||||
console.log('Usage: ' + process.argv[0] + ' ' + process.argv[1]
|
||||
+ ' path/to/input.json path/to/output.dat');
|
||||
}
|
||||
|
||||
33
static/js/ketcher2/node_modules/varstream/cli/varstream2json.js
generated
vendored
Executable file
33
static/js/ketcher2/node_modules/varstream/cli/varstream2json.js
generated
vendored
Executable file
@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
var VarStream = require(__dirname + '/../src/VarStream')
|
||||
, fs = require('fs')
|
||||
;
|
||||
|
||||
if(process.argv[2]) {
|
||||
var scope = {}
|
||||
, myVarStream = new VarStream(scope, 'vars')
|
||||
, rS=fs.createReadStream(process.argv[2])
|
||||
;
|
||||
|
||||
rS.pipe(myVarStream)
|
||||
.once('finish', function () {
|
||||
if(!process.argv[3]) {
|
||||
process.stdout.write(JSON.stringify(scope.vars));
|
||||
return;
|
||||
}
|
||||
fs.writeFile(process.argv[3],
|
||||
JSON.stringify(scope.vars),
|
||||
function(err) {
|
||||
if(err) {
|
||||
throw err;
|
||||
}
|
||||
console.log('Saved!');
|
||||
});
|
||||
});
|
||||
|
||||
} else {
|
||||
console.log('Usage: ' + process.argv[0] + ' ' + process.argv[1]
|
||||
+ ' path/to/input.dat path/to/output.json');
|
||||
}
|
||||
|
||||
42
static/js/ketcher2/node_modules/varstream/compare/arrays-full.dat
generated
vendored
Executable file
42
static/js/ketcher2/node_modules/varstream/compare/arrays-full.dat
generated
vendored
Executable file
@ -0,0 +1,42 @@
|
||||
arrayValue.!.val1=This is a value 1
|
||||
^.val2=This is a value 2
|
||||
^.val3=This is a value 3
|
||||
arrayValue.+.val1=This is a value 1
|
||||
^.val2=This is a value 2
|
||||
^.val3=This is a value 3
|
||||
arrayValue.+.val1=This is a value 1
|
||||
^.val2=This is a value 2
|
||||
^.val3=This is a value 3
|
||||
arrayValue.+.val1=This is a value 1
|
||||
^.val2=This is a value 2
|
||||
^.val3=This is a value 3
|
||||
arrayValue.+.val1=This is a value 1
|
||||
^.val2=This is a value 2
|
||||
^.val3=This is a value 3
|
||||
arrayValue.+.val1=This is a value 1
|
||||
^.val2=This is a value 2
|
||||
^.val3=This is a value 3
|
||||
arrayValue.+.val1=This is a value 1
|
||||
^.val2=This is a value 2
|
||||
^.val3=This is a value 3
|
||||
arrayValue.+.val1=This is a value 1
|
||||
^.val2=This is a value 2
|
||||
^.val3=This is a value 3
|
||||
arrayValue.+.val1=This is a value 1
|
||||
^.val2=This is a value 2
|
||||
^.val3=This is a value 3
|
||||
arrayValue.+.val1=This is a value 1
|
||||
^.val2=This is a value 2
|
||||
^.val3=This is a value 3
|
||||
arrayValue.+.val1=This is a value 1
|
||||
^.val2=This is a value 2
|
||||
^.val3=This is a value 3
|
||||
arrayValue.+.val1=This is a value 1
|
||||
^.val2=This is a value 2
|
||||
^.val3=This is a value 3
|
||||
arrayValue.+.val1=This is a value 1
|
||||
^.val2=This is a value 2
|
||||
^.val3=This is a value 3
|
||||
arrayValue.+.val1=This is a value 1
|
||||
^.val2=This is a value 2
|
||||
^.val3=This is a value 3
|
||||
1
static/js/ketcher2/node_modules/varstream/compare/arrays-full.json
generated
vendored
Executable file
1
static/js/ketcher2/node_modules/varstream/compare/arrays-full.json
generated
vendored
Executable file
@ -0,0 +1 @@
|
||||
{"arrayValue":[{"val1":"This is a value 1","val2":"This is a value 2","val3":"This is a value 3"},{"val1":"This is a value 1","val2":"This is a value 2","val3":"This is a value 3"},{"val1":"This is a value 1","val2":"This is a value 2","val3":"This is a value 3"},{"val1":"This is a value 1","val2":"This is a value 2","val3":"This is a value 3"},{"val1":"This is a value 1","val2":"This is a value 2","val3":"This is a value 3"},{"val1":"This is a value 1","val2":"This is a value 2","val3":"This is a value 3"},{"val1":"This is a value 1","val2":"This is a value 2","val3":"This is a value 3"},{"val1":"This is a value 1","val2":"This is a value 2","val3":"This is a value 3"},{"val1":"This is a value 1","val2":"This is a value 2","val3":"This is a value 3"},{"val1":"This is a value 1","val2":"This is a value 2","val3":"This is a value 3"},{"val1":"This is a value 1","val2":"This is a value 2","val3":"This is a value 3"},{"val1":"This is a value 1","val2":"This is a value 2","val3":"This is a value 3"},{"val1":"This is a value 1","val2":"This is a value 2","val3":"This is a value 3"}]}
|
||||
42
static/js/ketcher2/node_modules/varstream/compare/arrays.dat
generated
vendored
Executable file
42
static/js/ketcher2/node_modules/varstream/compare/arrays.dat
generated
vendored
Executable file
@ -0,0 +1,42 @@
|
||||
arrayValue.!.val1=This is a value 1
|
||||
^.val2=This is a value 2
|
||||
^.val3=This is a value 3
|
||||
arrayValue.+.val1=This is a value 1
|
||||
^.val2=This is a value 2
|
||||
^.val3=This is a value 3
|
||||
arrayValue.+.val1=This is a value 1
|
||||
^.val2=This is a value 2
|
||||
^.val3=This is a value 3
|
||||
arrayValue.+.val1=This is a value 1
|
||||
^.val2=This is a value 2
|
||||
^.val3=This is a value 3
|
||||
arrayValue.+.val1=This is a value 1
|
||||
^.val2=This is a value 2
|
||||
^.val3=This is a value 3
|
||||
arrayValue.+.val1=This is a value 1
|
||||
^.val2=This is a value 2
|
||||
^.val3=This is a value 3
|
||||
arrayValue.+.val1=This is a value 1
|
||||
^.val2=This is a value 2
|
||||
^.val3=This is a value 3
|
||||
arrayValue.+.val1=This is a value 1
|
||||
^.val2=This is a value 2
|
||||
^.val3=This is a value 3
|
||||
arrayValue.+.val1=This is a value 1
|
||||
^.val2=This is a value 2
|
||||
^.val3=This is a value 3
|
||||
arrayValue.+.val1=This is a value 1
|
||||
^.val2=This is a value 2
|
||||
^.val3=This is a value 3
|
||||
arrayValue.+.val1=This is a value 1
|
||||
^.val2=This is a value 2
|
||||
^.val3=This is a value 3
|
||||
arrayValue.+.val1=This is a value 1
|
||||
^.val2=This is a value 2
|
||||
^.val3=This is a value 3
|
||||
arrayValue.+.val1=This is a value 1
|
||||
^.val2=This is a value 2
|
||||
^.val3=This is a value 3
|
||||
arrayValue.+.val1=This is a value 1
|
||||
^.val2=This is a value 2
|
||||
^.val3=This is a value 3
|
||||
1
static/js/ketcher2/node_modules/varstream/compare/arrays.json
generated
vendored
Executable file
1
static/js/ketcher2/node_modules/varstream/compare/arrays.json
generated
vendored
Executable file
@ -0,0 +1 @@
|
||||
{"arrayValue":[{"val1":"This is a value 1","val2":"This is a value 2","val3":"This is a value 3"},{"val1":"This is a value 1","val2":"This is a value 2","val3":"This is a value 3"},{"val1":"This is a value 1","val2":"This is a value 2","val3":"This is a value 3"},{"val1":"This is a value 1","val2":"This is a value 2","val3":"This is a value 3"},{"val1":"This is a value 1","val2":"This is a value 2","val3":"This is a value 3"},{"val1":"This is a value 1","val2":"This is a value 2","val3":"This is a value 3"},{"val1":"This is a value 1","val2":"This is a value 2","val3":"This is a value 3"},{"val1":"This is a value 1","val2":"This is a value 2","val3":"This is a value 3"},{"val1":"This is a value 1","val2":"This is a value 2","val3":"This is a value 3"},{"val1":"This is a value 1","val2":"This is a value 2","val3":"This is a value 3"},{"val1":"This is a value 1","val2":"This is a value 2","val3":"This is a value 3"},{"val1":"This is a value 1","val2":"This is a value 2","val3":"This is a value 3"},{"val1":"This is a value 1","val2":"This is a value 2","val3":"This is a value 3"},{"val1":"This is a value 1","val2":"This is a value 2","val3":"This is a value 3"}]}
|
||||
100
static/js/ketcher2/node_modules/varstream/compare/entries.dat
generated
vendored
Executable file
100
static/js/ketcher2/node_modules/varstream/compare/entries.dat
generated
vendored
Executable file
@ -0,0 +1,100 @@
|
||||
entries.!.title=This is a blog post title
|
||||
entries.*.description=This is a blog post description that should describe the blog post contents.
|
||||
entries.*.content=This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content.\
|
||||
This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content.\
|
||||
This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content.
|
||||
entries.+.title=This is a blog post title
|
||||
entries.*.description=This is a blog post description that should describe the blog post contents.
|
||||
entries.*.content=This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content.\
|
||||
This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content.\
|
||||
This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content.
|
||||
entries.+.title=This is a blog post title
|
||||
entries.*.description=This is a blog post description that should describe the blog post contents.
|
||||
entries.*.content=This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content.\
|
||||
This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content.\
|
||||
This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content.
|
||||
entries.+.title=This is a blog post title
|
||||
entries.*.description=This is a blog post description that should describe the blog post contents.
|
||||
entries.*.content=This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content.\
|
||||
This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content.\
|
||||
This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content.
|
||||
entries.+.title=This is a blog post title
|
||||
entries.*.description=This is a blog post description that should describe the blog post contents.
|
||||
entries.*.content=This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content.\
|
||||
This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content.\
|
||||
This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content.
|
||||
entries.+.title=This is a blog post title
|
||||
entries.*.description=This is a blog post description that should describe the blog post contents.
|
||||
entries.*.content=This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content.\
|
||||
This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content.\
|
||||
This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content.
|
||||
entries.+.title=This is a blog post title
|
||||
entries.*.description=This is a blog post description that should describe the blog post contents.
|
||||
entries.*.content=This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content.\
|
||||
This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content.\
|
||||
This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content.
|
||||
entries.+.title=This is a blog post title
|
||||
entries.*.description=This is a blog post description that should describe the blog post contents.
|
||||
entries.*.content=This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content.\
|
||||
This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content.\
|
||||
This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content.
|
||||
entries.+.title=This is a blog post title
|
||||
entries.*.description=This is a blog post description that should describe the blog post contents.
|
||||
entries.*.content=This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content.\
|
||||
This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content.\
|
||||
This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content.
|
||||
entries.+.title=This is a blog post title
|
||||
entries.*.description=This is a blog post description that should describe the blog post contents.
|
||||
entries.*.content=This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content.\
|
||||
This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content.\
|
||||
This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content.
|
||||
entries.+.title=This is a blog post title
|
||||
entries.*.description=This is a blog post description that should describe the blog post contents.
|
||||
entries.*.content=This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content.\
|
||||
This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content.\
|
||||
This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content.
|
||||
entries.+.title=This is a blog post title
|
||||
entries.*.description=This is a blog post description that should describe the blog post contents.
|
||||
entries.*.content=This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content.\
|
||||
This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content.\
|
||||
This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content.
|
||||
entries.+.title=This is a blog post title
|
||||
entries.*.description=This is a blog post description that should describe the blog post contents.
|
||||
entries.*.content=This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content.\
|
||||
This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content.\
|
||||
This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content.
|
||||
entries.+.title=This is a blog post title
|
||||
entries.*.description=This is a blog post description that should describe the blog post contents.
|
||||
entries.*.content=This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content.\
|
||||
This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content.\
|
||||
This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content.
|
||||
entries.+.title=This is a blog post title
|
||||
entries.*.description=This is a blog post description that should describe the blog post contents.
|
||||
entries.*.content=This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content.\
|
||||
This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content.\
|
||||
This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content.
|
||||
entries.+.title=This is a blog post title
|
||||
entries.*.description=This is a blog post description that should describe the blog post contents.
|
||||
entries.*.content=This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content.\
|
||||
This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content.\
|
||||
This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content.
|
||||
entries.+.title=This is a blog post title
|
||||
entries.*.description=This is a blog post description that should describe the blog post contents.
|
||||
entries.*.content=This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content.\
|
||||
This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content.\
|
||||
This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content.
|
||||
entries.+.title=This is a blog post title
|
||||
entries.*.description=This is a blog post description that should describe the blog post contents.
|
||||
entries.*.content=This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content.\
|
||||
This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content.\
|
||||
This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content.
|
||||
entries.+.title=This is a blog post title
|
||||
entries.*.description=This is a blog post description that should describe the blog post contents.
|
||||
entries.*.content=This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content.\
|
||||
This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content.\
|
||||
This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content.
|
||||
entries.+.title=This is a blog post title
|
||||
entries.*.description=This is a blog post description that should describe the blog post contents.
|
||||
entries.*.content=This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content.\
|
||||
This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content.\
|
||||
This is the blog post content. This is the blog post content. This is the blog post content. This is the blog post content.
|
||||
1
static/js/ketcher2/node_modules/varstream/compare/entries.json
generated
vendored
Executable file
1
static/js/ketcher2/node_modules/varstream/compare/entries.json
generated
vendored
Executable file
File diff suppressed because one or more lines are too long
11
static/js/ketcher2/node_modules/varstream/compare/linear.dat
generated
vendored
Executable file
11
static/js/ketcher2/node_modules/varstream/compare/linear.dat
generated
vendored
Executable file
@ -0,0 +1,11 @@
|
||||
linearValue1=This is a linear value 1
|
||||
linearValue2=This is a linear value 2
|
||||
linearValue3=This is a linear value 3
|
||||
linearValue4=This is a linear value 4
|
||||
linearValue5=This is a linear value 5
|
||||
linearValue6=This is a linear value 6
|
||||
linearValue7=This is a linear value 7
|
||||
linearValue8=This is a linear value 8
|
||||
linearValue9=This is a linear value 9
|
||||
linearValue10=This is a linear value 10
|
||||
|
||||
1
static/js/ketcher2/node_modules/varstream/compare/linear.json
generated
vendored
Executable file
1
static/js/ketcher2/node_modules/varstream/compare/linear.json
generated
vendored
Executable file
@ -0,0 +1 @@
|
||||
{"linearValue1":"This is a linear value 1","linearValue2":"This is a linear value 2","linearValue3":"This is a linear value 3","linearValue4":"This is a linear value 4","linearValue5":"This is a linear value 5","linearValue6":"This is a linear value 6","linearValue7":"This is a linear value 7","linearValue8":"This is a linear value 8","linearValue9":"This is a linear value 9","linearValue10":"This is a linear value 10"}
|
||||
148
static/js/ketcher2/node_modules/varstream/compare/references.dat
generated
vendored
Executable file
148
static/js/ketcher2/node_modules/varstream/compare/references.dat
generated
vendored
Executable file
@ -0,0 +1,148 @@
|
||||
table.nameField=id
|
||||
table.joinFields.0.name=joined_groups
|
||||
^.input=select
|
||||
^.type=number
|
||||
^.filter=int
|
||||
^.linkedTable=groups
|
||||
^.linkedField=id
|
||||
^.joinedField=id
|
||||
^.joinTable=groups_users
|
||||
^.multiple=true
|
||||
table.joinFields.1.name=joined_rights
|
||||
^.input=select
|
||||
^.type=number
|
||||
^.filter=int
|
||||
^.linkedTable=rights
|
||||
^.linkedField=id
|
||||
^.joinedField=id
|
||||
^.joinTable=rights_users
|
||||
^.multiple=true
|
||||
table.joinFields.2.name=joined_places
|
||||
^.input=select
|
||||
^.type=number
|
||||
^.filter=int
|
||||
^.linkedTable=places
|
||||
^.linkedField=id
|
||||
^.joinedField=id
|
||||
^.joinTable=places_users
|
||||
^.multiple=true
|
||||
table.joinFields.3.name=joined_contacts
|
||||
^.input=select
|
||||
^.type=number
|
||||
^.filter=int
|
||||
^.linkedTable=contacts
|
||||
^.linkedField=id
|
||||
^.joinedField=id
|
||||
^.joinTable=contacts_users
|
||||
^.multiple=true
|
||||
table.labelFields.0=firstname
|
||||
^.1=lastname
|
||||
table.linkedTables.0=groups
|
||||
^.1=rights
|
||||
^.2=places
|
||||
^.3=contacts
|
||||
^.4=organizations
|
||||
table.hasCounter=false
|
||||
^.hasOwner=false
|
||||
^.isLocalized=false
|
||||
^.hasStatus=false
|
||||
^.hasRecipient=false
|
||||
^.hasVote=false
|
||||
^.hasNote=false
|
||||
^.hasLastmodified=false
|
||||
^.hasCreated=false
|
||||
^.hasHierarchy=false
|
||||
^.isGeolocalized=false
|
||||
table.fields.0.name=id
|
||||
^.required=true
|
||||
^.unique=true
|
||||
^.input=input
|
||||
^.type=number
|
||||
^.filter=int
|
||||
^.min=0
|
||||
^.max=16777215
|
||||
table.fields.1.name=login
|
||||
^.required=true
|
||||
^.unique=true
|
||||
^.input=input
|
||||
^.type=text
|
||||
^.filter=cdata
|
||||
^.max=20
|
||||
table.fields.2.name=firstname
|
||||
^.required=true
|
||||
^.unique=false
|
||||
^.input=input
|
||||
^.type=text
|
||||
^.filter=cdata
|
||||
^.max=50
|
||||
table.fields.3.name=lastname
|
||||
^.required=true
|
||||
^.unique=false
|
||||
^.input=input
|
||||
^.type=text
|
||||
^.filter=cdata
|
||||
^.max=50
|
||||
table.fields.4.name=role
|
||||
^.required=true
|
||||
^.unique=false
|
||||
^.input=input
|
||||
^.type=text
|
||||
^.filter=cdata
|
||||
^.max=150
|
||||
table.fields.5.name=password
|
||||
^.required=false
|
||||
^.unique=false
|
||||
^.input=input
|
||||
^.type=text
|
||||
^.filter=iparameter
|
||||
^.max=40
|
||||
^.pattern=[a-zA-Z0-9_]+
|
||||
table.fields.6.name=email
|
||||
^.required=false
|
||||
^.unique=false
|
||||
^.input=input
|
||||
^.type=email
|
||||
^.filter=mail
|
||||
^.max=200
|
||||
table.fields.7.name=group
|
||||
^.required=true
|
||||
^.unique=false
|
||||
^.input=select
|
||||
^.type=number
|
||||
^.filter=int
|
||||
^.min=0
|
||||
^.max=255
|
||||
^.linkedTable=groups
|
||||
^.linkedField=id
|
||||
table.fields.8.name=lastconnection
|
||||
^.required=true
|
||||
^.defaultValue=
|
||||
^.unique=false
|
||||
^.input=input
|
||||
^.type=datetime
|
||||
^.filter=datetime
|
||||
^.min=1000-01-01 00:00:00
|
||||
^.max=9999-12-31 23:59:59
|
||||
table.fields.9.name=organization
|
||||
^.required=true
|
||||
^.unique=false
|
||||
^.input=select
|
||||
^.type=number
|
||||
^.filter=int
|
||||
^.min=0
|
||||
^.max=16777215
|
||||
^.linkedTable=organizations
|
||||
^.linkedField=id
|
||||
table.fields.10.name=active
|
||||
^.required=true
|
||||
^.unique=false
|
||||
table.fields.10.options.0.value=0
|
||||
table.fields.10.options.1.value=1
|
||||
table.fields.10.input=select
|
||||
^.type=text
|
||||
^.filter=iparameter
|
||||
^.multiple=false
|
||||
table.fields.11&=table.joinFields.0
|
||||
^.12&=table.joinFields.1
|
||||
^.13&=table.joinFields.2
|
||||
^.14&=table.joinFields.3
|
||||
1
static/js/ketcher2/node_modules/varstream/compare/references.json
generated
vendored
Executable file
1
static/js/ketcher2/node_modules/varstream/compare/references.json
generated
vendored
Executable file
@ -0,0 +1 @@
|
||||
{"table":{"nameField":"id","joinFields":[{"name":"joined_groups","input":"select","type":"number","filter":"int","linkedTable":"groups","linkedField":"id","joinedField":"id","joinTable":"groups_users","multiple":true},{"name":"joined_rights","input":"select","type":"number","filter":"int","linkedTable":"rights","linkedField":"id","joinedField":"id","joinTable":"rights_users","multiple":true},{"name":"joined_places","input":"select","type":"number","filter":"int","linkedTable":"places","linkedField":"id","joinedField":"id","joinTable":"places_users","multiple":true},{"name":"joined_contacts","input":"select","type":"number","filter":"int","linkedTable":"contacts","linkedField":"id","joinedField":"id","joinTable":"contacts_users","multiple":true}],"labelFields":{"0":"firstname","1":"lastname"},"linkedTables":{"0":"groups","1":"rights","2":"places","3":"contacts","4":"organizations"},"hasCounter":false,"hasOwner":false,"isLocalized":false,"hasStatus":false,"hasRecipient":false,"hasVote":false,"hasNote":false,"hasLastmodified":false,"hasCreated":false,"hasHierarchy":false,"isGeolocalized":false,"fields":[{"name":"id","required":true,"unique":true,"input":"input","type":"number","filter":"int","min":"0","max":"16777215"},{"name":"login","required":true,"unique":true,"input":"input","type":"text","filter":"cdata","max":"20"},{"name":"firstname","required":true,"unique":false,"input":"input","type":"text","filter":"cdata","max":"50"},{"name":"lastname","required":true,"unique":false,"input":"input","type":"text","filter":"cdata","max":"50"},{"name":"role","required":true,"unique":false,"input":"input","type":"text","filter":"cdata","max":"150"},{"name":"password","required":false,"unique":false,"input":"input","type":"text","filter":"iparameter","max":"40","pattern":"[a-zA-Z0-9_]+"},{"name":"email","required":false,"unique":false,"input":"input","type":"email","filter":"mail","max":"200"},{"name":"group","required":true,"unique":false,"input":"select","type":"number","filter":"int","min":"0","max":"255","linkedTable":"groups","linkedField":"id"},{"name":"lastconnection","required":true,"defaultValue":"","unique":false,"input":"input","type":"datetime","filter":"datetime","min":"1000-01-01 00:00:00","max":"9999-12-31 23:59:59"},{"name":"organization","required":true,"unique":false,"input":"select","type":"number","filter":"int","min":"0","max":"16777215","linkedTable":"organizations","linkedField":"id"},{"name":"active","required":true,"unique":false,"options":[{"value":"0"},{"value":"1"}],"input":"select","type":"text","filter":"iparameter","multiple":false},{"name":"joined_groups","input":"select","type":"number","filter":"int","linkedTable":"groups","linkedField":"id","joinedField":"id","joinTable":"groups_users","multiple":true},{"name":"joined_rights","input":"select","type":"number","filter":"int","linkedTable":"rights","linkedField":"id","joinedField":"id","joinTable":"rights_users","multiple":true},{"name":"joined_places","input":"select","type":"number","filter":"int","linkedTable":"places","linkedField":"id","joinedField":"id","joinTable":"places_users","multiple":true},{"name":"joined_contacts","input":"select","type":"number","filter":"int","linkedTable":"contacts","linkedField":"id","joinedField":"id","joinTable":"contacts_users","multiple":true}]}}
|
||||
1095
static/js/ketcher2/node_modules/varstream/compare/stats.dat
generated
vendored
Executable file
1095
static/js/ketcher2/node_modules/varstream/compare/stats.dat
generated
vendored
Executable file
File diff suppressed because it is too large
Load Diff
1
static/js/ketcher2/node_modules/varstream/compare/stats.json
generated
vendored
Executable file
1
static/js/ketcher2/node_modules/varstream/compare/stats.json
generated
vendored
Executable file
File diff suppressed because one or more lines are too long
109
static/js/ketcher2/node_modules/varstream/index.html
generated
vendored
Executable file
109
static/js/ketcher2/node_modules/varstream/index.html
generated
vendored
Executable file
@ -0,0 +1,109 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>VarStream</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Some VarStreams</h1>
|
||||
<p>Open your web console to view what's done on this page.</p>
|
||||
<script type="text/javascript" src="VarStreamReader.js"></script>
|
||||
<script type="text/javascript" src="VarStreamWriter.js"></script>
|
||||
<script type="text/javascript">
|
||||
var myScope={};
|
||||
var myStreamReader=new VarStreamReader(myScope,true);
|
||||
myStreamReader.read('');
|
||||
myStreamReader.read('#comment');
|
||||
myStreamReader.read('# Database'+"\n"
|
||||
+'database.type=mysql'+"\n"
|
||||
+'database.hosts.+.domain=mysql1.example.com'+"\n"
|
||||
+'database.hosts.*.master=true'+"\n"
|
||||
+'database.hosts.+.domain=mysql2.example.com'+"\n"
|
||||
+'database.hosts.*.master=false'+"\n"
|
||||
+'database.hosts.0.master=true'+"\n"
|
||||
+'database.user=root'+"\n"
|
||||
+'database.base=myapp'+"\n"
|
||||
+'database.base=myapp2'+"\n"
|
||||
+'".base=myapp'+"\n"
|
||||
+'# REST servers'+"\n"
|
||||
+'rest.servers.+.domain=api.example.com'+"\n"
|
||||
+'rest.servers.*.auth=basic'+"\n"
|
||||
+'rest.servers.*.user&=database.user');
|
||||
myStreamReader.read('".password=pass');
|
||||
console.log('root=='+myScope.database.user+'=='+myScope.rest.servers[0].user+'!='+myScope.unexistingvar);
|
||||
|
||||
myStreamReader.read('# Date'+"\n"
|
||||
+'l_timezone=Europe/Paris'+"\n"
|
||||
+'l_date_format=l d F Y'+"\n"
|
||||
+'l_day_format=d F'+"\n"
|
||||
+'l_time_format=l d F Y <20> H:i:s'+"\n"
|
||||
+'l_hour_format=H:i:s'+"\n"
|
||||
+'l_days.monday=Lundi'+"\n"
|
||||
+'l_days.tuesday=Mardi'+"\n"
|
||||
+'l_days.wednesday=Mercredi'+"\n"
|
||||
+'l_days.thursday=Jeudi'+"\n"
|
||||
+'l_days.friday=Vendredi'+"\n"
|
||||
+'l_days.saturday=Samedi'+"\n"
|
||||
+'l_days.sunday=Dimanche'+"\n"
|
||||
+'l_months.january=Janvier'+"\n"
|
||||
+'l_months.february=F<>vrier'+"\n"
|
||||
+'l_months.march=Mars'+"\n"
|
||||
+'l_months.april=Avril'+"\n"
|
||||
+'l_months.may=Mai'+"\n"
|
||||
+'l_months.june=Juin'+"\n"
|
||||
+'l_months.july=Juillet'+"\n"
|
||||
+'l_months.august=Ao<41>t'+"\n"
|
||||
+'l_months.september=Septembre'+"\n"
|
||||
+'l_months.october=Octobre'+"\n"
|
||||
+'l_months.november=Novembre'+"\n"
|
||||
+'l_months.december=Decembre'+"\n"
|
||||
+'# Numbers'+"\n"
|
||||
+'l_number_dec_point=,'+"\n"
|
||||
+'l_number_thousands_sep= # Phone numbers'+"\n"
|
||||
+'l_phone_local_indicator=33'+"\n"
|
||||
+'l_phone_local_format=0'+"\n"
|
||||
+'l_phone_indicator_format=+XXXX (0)'+"\n"
|
||||
+'l_phone_number_format=X XX XX XX XX'+"\n"
|
||||
+'# GPS Locations'+"\n"
|
||||
+'l_gps_latitude=N'+"\n"
|
||||
+'l_gps_longitude=O'+"\n"
|
||||
+'# Multiline '+"\n"
|
||||
+'l_multiline=i curently have a \\'+"\n"
|
||||
+'multiline value. \\'+"\n"
|
||||
+'It\'s great !'+"\n"
|
||||
+'l_multiline2=i curently have a \\'+"\n"
|
||||
+'multiline value. \\'+"\n"
|
||||
+'It\'s really great !\\');
|
||||
myStreamReader.read('But i\'m chunked !\\');
|
||||
myStreamReader.read('Will it run ?\\');
|
||||
myStreamReader.read('Yes, it is !');
|
||||
|
||||
console.log('root=='+myScope.database.user+'=='+myScope.rest.servers[0].user+'!='+myScope.unexistingvar);
|
||||
console.log('l_multiline='+myScope.l_multiline);
|
||||
console.log('l_multiline2='+myScope.l_multiline2);
|
||||
|
||||
|
||||
var myScope2={};
|
||||
var myStreamReader=new VarStreamReader(myScope2,true);
|
||||
myStreamReader.read(''); // Reading empty chunk
|
||||
myStreamReader.read('# Comment'); // This is a comment
|
||||
myStreamReader.read('# Database'+"\n"
|
||||
+'database.type=mysql'+"\n"
|
||||
+'database.sync=false'+"\n"
|
||||
+'database.hosts.+.domain=mysql1.example.com'+"\n"
|
||||
+'database.hosts.*.master=true'+"\n"
|
||||
+'database.hosts.+.domain=mysql2.example.com'+"\n"
|
||||
+'".master=false'+"\n"
|
||||
+'database.hosts.+&=database.hosts.0'+"\n"
|
||||
+'database.hosts.+.domain&=database.hosts.1.domain'+"\n"
|
||||
); // A more complicated chunk
|
||||
console.log(myScope2);
|
||||
console.log(myScope2.database.hosts[0].domain); // printsmysql1.example.com
|
||||
console.log(myScope2.database.hosts[1].domain); // printsmysql2.example.com
|
||||
console.log(myScope2.database.hosts[2].domain); // printsmysql1.example.com
|
||||
console.log(myScope2.database.hosts[3].domain); // printsmysql2.example.com
|
||||
|
||||
var myStreamWriter=new VarStreamWriter(function(content) { console.log(content) },true,false);
|
||||
myStreamWriter.write(myScope2);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
54
static/js/ketcher2/node_modules/varstream/node_modules/isarray/README.md
generated
vendored
Normal file
54
static/js/ketcher2/node_modules/varstream/node_modules/isarray/README.md
generated
vendored
Normal file
@ -0,0 +1,54 @@
|
||||
|
||||
# isarray
|
||||
|
||||
`Array#isArray` for older browsers.
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var isArray = require('isarray');
|
||||
|
||||
console.log(isArray([])); // => true
|
||||
console.log(isArray({})); // => false
|
||||
```
|
||||
|
||||
## Installation
|
||||
|
||||
With [npm](http://npmjs.org) do
|
||||
|
||||
```bash
|
||||
$ npm install isarray
|
||||
```
|
||||
|
||||
Then bundle for the browser with
|
||||
[browserify](https://github.com/substack/browserify).
|
||||
|
||||
With [component](http://component.io) do
|
||||
|
||||
```bash
|
||||
$ component install juliangruber/isarray
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
(MIT)
|
||||
|
||||
Copyright (c) 2013 Julian Gruber <julian@juliangruber.com>
|
||||
|
||||
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.
|
||||
209
static/js/ketcher2/node_modules/varstream/node_modules/isarray/build/build.js
generated
vendored
Normal file
209
static/js/ketcher2/node_modules/varstream/node_modules/isarray/build/build.js
generated
vendored
Normal file
@ -0,0 +1,209 @@
|
||||
|
||||
/**
|
||||
* Require the given path.
|
||||
*
|
||||
* @param {String} path
|
||||
* @return {Object} exports
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function require(path, parent, orig) {
|
||||
var resolved = require.resolve(path);
|
||||
|
||||
// lookup failed
|
||||
if (null == resolved) {
|
||||
orig = orig || path;
|
||||
parent = parent || 'root';
|
||||
var err = new Error('Failed to require "' + orig + '" from "' + parent + '"');
|
||||
err.path = orig;
|
||||
err.parent = parent;
|
||||
err.require = true;
|
||||
throw err;
|
||||
}
|
||||
|
||||
var module = require.modules[resolved];
|
||||
|
||||
// perform real require()
|
||||
// by invoking the module's
|
||||
// registered function
|
||||
if (!module.exports) {
|
||||
module.exports = {};
|
||||
module.client = module.component = true;
|
||||
module.call(this, module.exports, require.relative(resolved), module);
|
||||
}
|
||||
|
||||
return module.exports;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registered modules.
|
||||
*/
|
||||
|
||||
require.modules = {};
|
||||
|
||||
/**
|
||||
* Registered aliases.
|
||||
*/
|
||||
|
||||
require.aliases = {};
|
||||
|
||||
/**
|
||||
* Resolve `path`.
|
||||
*
|
||||
* Lookup:
|
||||
*
|
||||
* - PATH/index.js
|
||||
* - PATH.js
|
||||
* - PATH
|
||||
*
|
||||
* @param {String} path
|
||||
* @return {String} path or null
|
||||
* @api private
|
||||
*/
|
||||
|
||||
require.resolve = function(path) {
|
||||
if (path.charAt(0) === '/') path = path.slice(1);
|
||||
var index = path + '/index.js';
|
||||
|
||||
var paths = [
|
||||
path,
|
||||
path + '.js',
|
||||
path + '.json',
|
||||
path + '/index.js',
|
||||
path + '/index.json'
|
||||
];
|
||||
|
||||
for (var i = 0; i < paths.length; i++) {
|
||||
var path = paths[i];
|
||||
if (require.modules.hasOwnProperty(path)) return path;
|
||||
}
|
||||
|
||||
if (require.aliases.hasOwnProperty(index)) {
|
||||
return require.aliases[index];
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Normalize `path` relative to the current path.
|
||||
*
|
||||
* @param {String} curr
|
||||
* @param {String} path
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
require.normalize = function(curr, path) {
|
||||
var segs = [];
|
||||
|
||||
if ('.' != path.charAt(0)) return path;
|
||||
|
||||
curr = curr.split('/');
|
||||
path = path.split('/');
|
||||
|
||||
for (var i = 0; i < path.length; ++i) {
|
||||
if ('..' == path[i]) {
|
||||
curr.pop();
|
||||
} else if ('.' != path[i] && '' != path[i]) {
|
||||
segs.push(path[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return curr.concat(segs).join('/');
|
||||
};
|
||||
|
||||
/**
|
||||
* Register module at `path` with callback `definition`.
|
||||
*
|
||||
* @param {String} path
|
||||
* @param {Function} definition
|
||||
* @api private
|
||||
*/
|
||||
|
||||
require.register = function(path, definition) {
|
||||
require.modules[path] = definition;
|
||||
};
|
||||
|
||||
/**
|
||||
* Alias a module definition.
|
||||
*
|
||||
* @param {String} from
|
||||
* @param {String} to
|
||||
* @api private
|
||||
*/
|
||||
|
||||
require.alias = function(from, to) {
|
||||
if (!require.modules.hasOwnProperty(from)) {
|
||||
throw new Error('Failed to alias "' + from + '", it does not exist');
|
||||
}
|
||||
require.aliases[to] = from;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a require function relative to the `parent` path.
|
||||
*
|
||||
* @param {String} parent
|
||||
* @return {Function}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
require.relative = function(parent) {
|
||||
var p = require.normalize(parent, '..');
|
||||
|
||||
/**
|
||||
* lastIndexOf helper.
|
||||
*/
|
||||
|
||||
function lastIndexOf(arr, obj) {
|
||||
var i = arr.length;
|
||||
while (i--) {
|
||||
if (arr[i] === obj) return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* The relative require() itself.
|
||||
*/
|
||||
|
||||
function localRequire(path) {
|
||||
var resolved = localRequire.resolve(path);
|
||||
return require(resolved, parent, path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve relative to the parent.
|
||||
*/
|
||||
|
||||
localRequire.resolve = function(path) {
|
||||
var c = path.charAt(0);
|
||||
if ('/' == c) return path.slice(1);
|
||||
if ('.' == c) return require.normalize(p, path);
|
||||
|
||||
// resolve deps by returning
|
||||
// the dep in the nearest "deps"
|
||||
// directory
|
||||
var segs = parent.split('/');
|
||||
var i = lastIndexOf(segs, 'deps') + 1;
|
||||
if (!i) i = 0;
|
||||
path = segs.slice(0, i + 1).join('/') + '/deps/' + path;
|
||||
return path;
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if module is defined at `path`.
|
||||
*/
|
||||
|
||||
localRequire.exists = function(path) {
|
||||
return require.modules.hasOwnProperty(localRequire.resolve(path));
|
||||
};
|
||||
|
||||
return localRequire;
|
||||
};
|
||||
require.register("isarray/index.js", function(exports, require, module){
|
||||
module.exports = Array.isArray || function (arr) {
|
||||
return Object.prototype.toString.call(arr) == '[object Array]';
|
||||
};
|
||||
|
||||
});
|
||||
require.alias("isarray/index.js", "isarray/index.js");
|
||||
|
||||
19
static/js/ketcher2/node_modules/varstream/node_modules/isarray/component.json
generated
vendored
Normal file
19
static/js/ketcher2/node_modules/varstream/node_modules/isarray/component.json
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
{
|
||||
"name" : "isarray",
|
||||
"description" : "Array#isArray for older browsers",
|
||||
"version" : "0.0.1",
|
||||
"repository" : "juliangruber/isarray",
|
||||
"homepage": "https://github.com/juliangruber/isarray",
|
||||
"main" : "index.js",
|
||||
"scripts" : [
|
||||
"index.js"
|
||||
],
|
||||
"dependencies" : {},
|
||||
"keywords": ["browser","isarray","array"],
|
||||
"author": {
|
||||
"name": "Julian Gruber",
|
||||
"email": "mail@juliangruber.com",
|
||||
"url": "http://juliangruber.com"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
||||
3
static/js/ketcher2/node_modules/varstream/node_modules/isarray/index.js
generated
vendored
Normal file
3
static/js/ketcher2/node_modules/varstream/node_modules/isarray/index.js
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
module.exports = Array.isArray || function (arr) {
|
||||
return Object.prototype.toString.call(arr) == '[object Array]';
|
||||
};
|
||||
57
static/js/ketcher2/node_modules/varstream/node_modules/isarray/package.json
generated
vendored
Normal file
57
static/js/ketcher2/node_modules/varstream/node_modules/isarray/package.json
generated
vendored
Normal file
@ -0,0 +1,57 @@
|
||||
{
|
||||
"_from": "isarray@0.0.1",
|
||||
"_id": "isarray@0.0.1",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=",
|
||||
"_location": "/varstream/isarray",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "isarray@0.0.1",
|
||||
"name": "isarray",
|
||||
"escapedName": "isarray",
|
||||
"rawSpec": "0.0.1",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "0.0.1"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/varstream/readable-stream"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz",
|
||||
"_shasum": "8a18acfca9a8f4177e09abfc6038939b05d1eedf",
|
||||
"_spec": "isarray@0.0.1",
|
||||
"_where": "/home/manfred/enviPath/ketcher2/ketcher/node_modules/varstream/node_modules/readable-stream",
|
||||
"author": {
|
||||
"name": "Julian Gruber",
|
||||
"email": "mail@juliangruber.com",
|
||||
"url": "http://juliangruber.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/juliangruber/isarray/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {},
|
||||
"deprecated": false,
|
||||
"description": "Array#isArray for older browsers",
|
||||
"devDependencies": {
|
||||
"tap": "*"
|
||||
},
|
||||
"homepage": "https://github.com/juliangruber/isarray",
|
||||
"keywords": [
|
||||
"browser",
|
||||
"isarray",
|
||||
"array"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"name": "isarray",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/juliangruber/isarray.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "tap test/*.js"
|
||||
},
|
||||
"version": "0.0.1"
|
||||
}
|
||||
18
static/js/ketcher2/node_modules/varstream/node_modules/readable-stream/LICENSE
generated
vendored
Normal file
18
static/js/ketcher2/node_modules/varstream/node_modules/readable-stream/LICENSE
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
Copyright Joyent, Inc. and other Node contributors. All rights reserved.
|
||||
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.
|
||||
15
static/js/ketcher2/node_modules/varstream/node_modules/readable-stream/README.md
generated
vendored
Normal file
15
static/js/ketcher2/node_modules/varstream/node_modules/readable-stream/README.md
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
# readable-stream
|
||||
|
||||
***Node-core streams for userland***
|
||||
|
||||
[](https://nodei.co/npm/readable-stream/)
|
||||
[](https://nodei.co/npm/readable-stream/)
|
||||
|
||||
This package is a mirror of the Streams2 and Streams3 implementations in Node-core.
|
||||
|
||||
If you want to guarantee a stable streams base, regardless of what version of Node you, or the users of your libraries are using, use **readable-stream** *only* and avoid the *"stream"* module in Node-core.
|
||||
|
||||
**readable-stream** comes in two major versions, v1.0.x and v1.1.x. The former tracks the Streams2 implementation in Node 0.10, including bug-fixes and minor improvements as they are added. The latter tracks Streams3 as it develops in Node 0.11; we will likely see a v1.2.x branch for Node 0.12.
|
||||
|
||||
**readable-stream** uses proper patch-level versioning so if you pin to `"~1.0.0"` you’ll get the latest Node 0.10 Streams2 implementation, including any fixes and minor non-breaking improvements. The patch-level versions of 1.0.x and 1.1.x should mirror the patch-level versions of Node-core releases. You should prefer the **1.0.x** releases for now and when you’re ready to start using Streams3, pin to `"~1.1.0"`
|
||||
|
||||
1
static/js/ketcher2/node_modules/varstream/node_modules/readable-stream/duplex.js
generated
vendored
Normal file
1
static/js/ketcher2/node_modules/varstream/node_modules/readable-stream/duplex.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
module.exports = require("./lib/_stream_duplex.js")
|
||||
923
static/js/ketcher2/node_modules/varstream/node_modules/readable-stream/float.patch
generated
vendored
Normal file
923
static/js/ketcher2/node_modules/varstream/node_modules/readable-stream/float.patch
generated
vendored
Normal file
@ -0,0 +1,923 @@
|
||||
diff --git a/lib/_stream_duplex.js b/lib/_stream_duplex.js
|
||||
index c5a741c..a2e0d8e 100644
|
||||
--- a/lib/_stream_duplex.js
|
||||
+++ b/lib/_stream_duplex.js
|
||||
@@ -26,8 +26,8 @@
|
||||
|
||||
module.exports = Duplex;
|
||||
var util = require('util');
|
||||
-var Readable = require('_stream_readable');
|
||||
-var Writable = require('_stream_writable');
|
||||
+var Readable = require('./_stream_readable');
|
||||
+var Writable = require('./_stream_writable');
|
||||
|
||||
util.inherits(Duplex, Readable);
|
||||
|
||||
diff --git a/lib/_stream_passthrough.js b/lib/_stream_passthrough.js
|
||||
index a5e9864..330c247 100644
|
||||
--- a/lib/_stream_passthrough.js
|
||||
+++ b/lib/_stream_passthrough.js
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
module.exports = PassThrough;
|
||||
|
||||
-var Transform = require('_stream_transform');
|
||||
+var Transform = require('./_stream_transform');
|
||||
var util = require('util');
|
||||
util.inherits(PassThrough, Transform);
|
||||
|
||||
diff --git a/lib/_stream_readable.js b/lib/_stream_readable.js
|
||||
index 0c3fe3e..90a8298 100644
|
||||
--- a/lib/_stream_readable.js
|
||||
+++ b/lib/_stream_readable.js
|
||||
@@ -23,10 +23,34 @@ module.exports = Readable;
|
||||
Readable.ReadableState = ReadableState;
|
||||
|
||||
var EE = require('events').EventEmitter;
|
||||
+if (!EE.listenerCount) EE.listenerCount = function(emitter, type) {
|
||||
+ return emitter.listeners(type).length;
|
||||
+};
|
||||
+
|
||||
+if (!global.setImmediate) global.setImmediate = function setImmediate(fn) {
|
||||
+ return setTimeout(fn, 0);
|
||||
+};
|
||||
+if (!global.clearImmediate) global.clearImmediate = function clearImmediate(i) {
|
||||
+ return clearTimeout(i);
|
||||
+};
|
||||
+
|
||||
var Stream = require('stream');
|
||||
var util = require('util');
|
||||
+if (!util.isUndefined) {
|
||||
+ var utilIs = require('core-util-is');
|
||||
+ for (var f in utilIs) {
|
||||
+ util[f] = utilIs[f];
|
||||
+ }
|
||||
+}
|
||||
var StringDecoder;
|
||||
-var debug = util.debuglog('stream');
|
||||
+var debug;
|
||||
+if (util.debuglog)
|
||||
+ debug = util.debuglog('stream');
|
||||
+else try {
|
||||
+ debug = require('debuglog')('stream');
|
||||
+} catch (er) {
|
||||
+ debug = function() {};
|
||||
+}
|
||||
|
||||
util.inherits(Readable, Stream);
|
||||
|
||||
@@ -380,7 +404,7 @@ function chunkInvalid(state, chunk) {
|
||||
|
||||
|
||||
function onEofChunk(stream, state) {
|
||||
- if (state.decoder && !state.ended) {
|
||||
+ if (state.decoder && !state.ended && state.decoder.end) {
|
||||
var chunk = state.decoder.end();
|
||||
if (chunk && chunk.length) {
|
||||
state.buffer.push(chunk);
|
||||
diff --git a/lib/_stream_transform.js b/lib/_stream_transform.js
|
||||
index b1f9fcc..b0caf57 100644
|
||||
--- a/lib/_stream_transform.js
|
||||
+++ b/lib/_stream_transform.js
|
||||
@@ -64,8 +64,14 @@
|
||||
|
||||
module.exports = Transform;
|
||||
|
||||
-var Duplex = require('_stream_duplex');
|
||||
+var Duplex = require('./_stream_duplex');
|
||||
var util = require('util');
|
||||
+if (!util.isUndefined) {
|
||||
+ var utilIs = require('core-util-is');
|
||||
+ for (var f in utilIs) {
|
||||
+ util[f] = utilIs[f];
|
||||
+ }
|
||||
+}
|
||||
util.inherits(Transform, Duplex);
|
||||
|
||||
|
||||
diff --git a/lib/_stream_writable.js b/lib/_stream_writable.js
|
||||
index ba2e920..f49288b 100644
|
||||
--- a/lib/_stream_writable.js
|
||||
+++ b/lib/_stream_writable.js
|
||||
@@ -27,6 +27,12 @@ module.exports = Writable;
|
||||
Writable.WritableState = WritableState;
|
||||
|
||||
var util = require('util');
|
||||
+if (!util.isUndefined) {
|
||||
+ var utilIs = require('core-util-is');
|
||||
+ for (var f in utilIs) {
|
||||
+ util[f] = utilIs[f];
|
||||
+ }
|
||||
+}
|
||||
var Stream = require('stream');
|
||||
|
||||
util.inherits(Writable, Stream);
|
||||
@@ -119,7 +125,7 @@ function WritableState(options, stream) {
|
||||
function Writable(options) {
|
||||
// Writable ctor is applied to Duplexes, though they're not
|
||||
// instanceof Writable, they're instanceof Readable.
|
||||
- if (!(this instanceof Writable) && !(this instanceof Stream.Duplex))
|
||||
+ if (!(this instanceof Writable) && !(this instanceof require('./_stream_duplex')))
|
||||
return new Writable(options);
|
||||
|
||||
this._writableState = new WritableState(options, this);
|
||||
diff --git a/test/simple/test-stream-big-push.js b/test/simple/test-stream-big-push.js
|
||||
index e3787e4..8cd2127 100644
|
||||
--- a/test/simple/test-stream-big-push.js
|
||||
+++ b/test/simple/test-stream-big-push.js
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
var common = require('../common');
|
||||
var assert = require('assert');
|
||||
-var stream = require('stream');
|
||||
+var stream = require('../../');
|
||||
var str = 'asdfasdfasdfasdfasdf';
|
||||
|
||||
var r = new stream.Readable({
|
||||
diff --git a/test/simple/test-stream-end-paused.js b/test/simple/test-stream-end-paused.js
|
||||
index bb73777..d40efc7 100644
|
||||
--- a/test/simple/test-stream-end-paused.js
|
||||
+++ b/test/simple/test-stream-end-paused.js
|
||||
@@ -25,7 +25,7 @@ var gotEnd = false;
|
||||
|
||||
// Make sure we don't miss the end event for paused 0-length streams
|
||||
|
||||
-var Readable = require('stream').Readable;
|
||||
+var Readable = require('../../').Readable;
|
||||
var stream = new Readable();
|
||||
var calledRead = false;
|
||||
stream._read = function() {
|
||||
diff --git a/test/simple/test-stream-pipe-after-end.js b/test/simple/test-stream-pipe-after-end.js
|
||||
index b46ee90..0be8366 100644
|
||||
--- a/test/simple/test-stream-pipe-after-end.js
|
||||
+++ b/test/simple/test-stream-pipe-after-end.js
|
||||
@@ -22,8 +22,8 @@
|
||||
var common = require('../common');
|
||||
var assert = require('assert');
|
||||
|
||||
-var Readable = require('_stream_readable');
|
||||
-var Writable = require('_stream_writable');
|
||||
+var Readable = require('../../lib/_stream_readable');
|
||||
+var Writable = require('../../lib/_stream_writable');
|
||||
var util = require('util');
|
||||
|
||||
util.inherits(TestReadable, Readable);
|
||||
diff --git a/test/simple/test-stream-pipe-cleanup.js b/test/simple/test-stream-pipe-cleanup.js
|
||||
deleted file mode 100644
|
||||
index f689358..0000000
|
||||
--- a/test/simple/test-stream-pipe-cleanup.js
|
||||
+++ /dev/null
|
||||
@@ -1,122 +0,0 @@
|
||||
-// Copyright Joyent, Inc. and other Node contributors.
|
||||
-//
|
||||
-// 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.
|
||||
-
|
||||
-// This test asserts that Stream.prototype.pipe does not leave listeners
|
||||
-// hanging on the source or dest.
|
||||
-
|
||||
-var common = require('../common');
|
||||
-var stream = require('stream');
|
||||
-var assert = require('assert');
|
||||
-var util = require('util');
|
||||
-
|
||||
-function Writable() {
|
||||
- this.writable = true;
|
||||
- this.endCalls = 0;
|
||||
- stream.Stream.call(this);
|
||||
-}
|
||||
-util.inherits(Writable, stream.Stream);
|
||||
-Writable.prototype.end = function() {
|
||||
- this.endCalls++;
|
||||
-};
|
||||
-
|
||||
-Writable.prototype.destroy = function() {
|
||||
- this.endCalls++;
|
||||
-};
|
||||
-
|
||||
-function Readable() {
|
||||
- this.readable = true;
|
||||
- stream.Stream.call(this);
|
||||
-}
|
||||
-util.inherits(Readable, stream.Stream);
|
||||
-
|
||||
-function Duplex() {
|
||||
- this.readable = true;
|
||||
- Writable.call(this);
|
||||
-}
|
||||
-util.inherits(Duplex, Writable);
|
||||
-
|
||||
-var i = 0;
|
||||
-var limit = 100;
|
||||
-
|
||||
-var w = new Writable();
|
||||
-
|
||||
-var r;
|
||||
-
|
||||
-for (i = 0; i < limit; i++) {
|
||||
- r = new Readable();
|
||||
- r.pipe(w);
|
||||
- r.emit('end');
|
||||
-}
|
||||
-assert.equal(0, r.listeners('end').length);
|
||||
-assert.equal(limit, w.endCalls);
|
||||
-
|
||||
-w.endCalls = 0;
|
||||
-
|
||||
-for (i = 0; i < limit; i++) {
|
||||
- r = new Readable();
|
||||
- r.pipe(w);
|
||||
- r.emit('close');
|
||||
-}
|
||||
-assert.equal(0, r.listeners('close').length);
|
||||
-assert.equal(limit, w.endCalls);
|
||||
-
|
||||
-w.endCalls = 0;
|
||||
-
|
||||
-r = new Readable();
|
||||
-
|
||||
-for (i = 0; i < limit; i++) {
|
||||
- w = new Writable();
|
||||
- r.pipe(w);
|
||||
- w.emit('close');
|
||||
-}
|
||||
-assert.equal(0, w.listeners('close').length);
|
||||
-
|
||||
-r = new Readable();
|
||||
-w = new Writable();
|
||||
-var d = new Duplex();
|
||||
-r.pipe(d); // pipeline A
|
||||
-d.pipe(w); // pipeline B
|
||||
-assert.equal(r.listeners('end').length, 2); // A.onend, A.cleanup
|
||||
-assert.equal(r.listeners('close').length, 2); // A.onclose, A.cleanup
|
||||
-assert.equal(d.listeners('end').length, 2); // B.onend, B.cleanup
|
||||
-assert.equal(d.listeners('close').length, 3); // A.cleanup, B.onclose, B.cleanup
|
||||
-assert.equal(w.listeners('end').length, 0);
|
||||
-assert.equal(w.listeners('close').length, 1); // B.cleanup
|
||||
-
|
||||
-r.emit('end');
|
||||
-assert.equal(d.endCalls, 1);
|
||||
-assert.equal(w.endCalls, 0);
|
||||
-assert.equal(r.listeners('end').length, 0);
|
||||
-assert.equal(r.listeners('close').length, 0);
|
||||
-assert.equal(d.listeners('end').length, 2); // B.onend, B.cleanup
|
||||
-assert.equal(d.listeners('close').length, 2); // B.onclose, B.cleanup
|
||||
-assert.equal(w.listeners('end').length, 0);
|
||||
-assert.equal(w.listeners('close').length, 1); // B.cleanup
|
||||
-
|
||||
-d.emit('end');
|
||||
-assert.equal(d.endCalls, 1);
|
||||
-assert.equal(w.endCalls, 1);
|
||||
-assert.equal(r.listeners('end').length, 0);
|
||||
-assert.equal(r.listeners('close').length, 0);
|
||||
-assert.equal(d.listeners('end').length, 0);
|
||||
-assert.equal(d.listeners('close').length, 0);
|
||||
-assert.equal(w.listeners('end').length, 0);
|
||||
-assert.equal(w.listeners('close').length, 0);
|
||||
diff --git a/test/simple/test-stream-pipe-error-handling.js b/test/simple/test-stream-pipe-error-handling.js
|
||||
index c5d724b..c7d6b7d 100644
|
||||
--- a/test/simple/test-stream-pipe-error-handling.js
|
||||
+++ b/test/simple/test-stream-pipe-error-handling.js
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
var common = require('../common');
|
||||
var assert = require('assert');
|
||||
-var Stream = require('stream').Stream;
|
||||
+var Stream = require('../../').Stream;
|
||||
|
||||
(function testErrorListenerCatches() {
|
||||
var source = new Stream();
|
||||
diff --git a/test/simple/test-stream-pipe-event.js b/test/simple/test-stream-pipe-event.js
|
||||
index cb9d5fe..56f8d61 100644
|
||||
--- a/test/simple/test-stream-pipe-event.js
|
||||
+++ b/test/simple/test-stream-pipe-event.js
|
||||
@@ -20,7 +20,7 @@
|
||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
var common = require('../common');
|
||||
-var stream = require('stream');
|
||||
+var stream = require('../../');
|
||||
var assert = require('assert');
|
||||
var util = require('util');
|
||||
|
||||
diff --git a/test/simple/test-stream-push-order.js b/test/simple/test-stream-push-order.js
|
||||
index f2e6ec2..a5c9bf9 100644
|
||||
--- a/test/simple/test-stream-push-order.js
|
||||
+++ b/test/simple/test-stream-push-order.js
|
||||
@@ -20,7 +20,7 @@
|
||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
var common = require('../common.js');
|
||||
-var Readable = require('stream').Readable;
|
||||
+var Readable = require('../../').Readable;
|
||||
var assert = require('assert');
|
||||
|
||||
var s = new Readable({
|
||||
diff --git a/test/simple/test-stream-push-strings.js b/test/simple/test-stream-push-strings.js
|
||||
index 06f43dc..1701a9a 100644
|
||||
--- a/test/simple/test-stream-push-strings.js
|
||||
+++ b/test/simple/test-stream-push-strings.js
|
||||
@@ -22,7 +22,7 @@
|
||||
var common = require('../common');
|
||||
var assert = require('assert');
|
||||
|
||||
-var Readable = require('stream').Readable;
|
||||
+var Readable = require('../../').Readable;
|
||||
var util = require('util');
|
||||
|
||||
util.inherits(MyStream, Readable);
|
||||
diff --git a/test/simple/test-stream-readable-event.js b/test/simple/test-stream-readable-event.js
|
||||
index ba6a577..a8e6f7b 100644
|
||||
--- a/test/simple/test-stream-readable-event.js
|
||||
+++ b/test/simple/test-stream-readable-event.js
|
||||
@@ -22,7 +22,7 @@
|
||||
var common = require('../common');
|
||||
var assert = require('assert');
|
||||
|
||||
-var Readable = require('stream').Readable;
|
||||
+var Readable = require('../../').Readable;
|
||||
|
||||
(function first() {
|
||||
// First test, not reading when the readable is added.
|
||||
diff --git a/test/simple/test-stream-readable-flow-recursion.js b/test/simple/test-stream-readable-flow-recursion.js
|
||||
index 2891ad6..11689ba 100644
|
||||
--- a/test/simple/test-stream-readable-flow-recursion.js
|
||||
+++ b/test/simple/test-stream-readable-flow-recursion.js
|
||||
@@ -27,7 +27,7 @@ var assert = require('assert');
|
||||
// more data continuously, but without triggering a nextTick
|
||||
// warning or RangeError.
|
||||
|
||||
-var Readable = require('stream').Readable;
|
||||
+var Readable = require('../../').Readable;
|
||||
|
||||
// throw an error if we trigger a nextTick warning.
|
||||
process.throwDeprecation = true;
|
||||
diff --git a/test/simple/test-stream-unshift-empty-chunk.js b/test/simple/test-stream-unshift-empty-chunk.js
|
||||
index 0c96476..7827538 100644
|
||||
--- a/test/simple/test-stream-unshift-empty-chunk.js
|
||||
+++ b/test/simple/test-stream-unshift-empty-chunk.js
|
||||
@@ -24,7 +24,7 @@ var assert = require('assert');
|
||||
|
||||
// This test verifies that stream.unshift(Buffer(0)) or
|
||||
// stream.unshift('') does not set state.reading=false.
|
||||
-var Readable = require('stream').Readable;
|
||||
+var Readable = require('../../').Readable;
|
||||
|
||||
var r = new Readable();
|
||||
var nChunks = 10;
|
||||
diff --git a/test/simple/test-stream-unshift-read-race.js b/test/simple/test-stream-unshift-read-race.js
|
||||
index 83fd9fa..17c18aa 100644
|
||||
--- a/test/simple/test-stream-unshift-read-race.js
|
||||
+++ b/test/simple/test-stream-unshift-read-race.js
|
||||
@@ -29,7 +29,7 @@ var assert = require('assert');
|
||||
// 3. push() after the EOF signaling null is an error.
|
||||
// 4. _read() is not called after pushing the EOF null chunk.
|
||||
|
||||
-var stream = require('stream');
|
||||
+var stream = require('../../');
|
||||
var hwm = 10;
|
||||
var r = stream.Readable({ highWaterMark: hwm });
|
||||
var chunks = 10;
|
||||
@@ -51,7 +51,14 @@ r._read = function(n) {
|
||||
|
||||
function push(fast) {
|
||||
assert(!pushedNull, 'push() after null push');
|
||||
- var c = pos >= data.length ? null : data.slice(pos, pos + n);
|
||||
+ var c;
|
||||
+ if (pos >= data.length)
|
||||
+ c = null;
|
||||
+ else {
|
||||
+ if (n + pos > data.length)
|
||||
+ n = data.length - pos;
|
||||
+ c = data.slice(pos, pos + n);
|
||||
+ }
|
||||
pushedNull = c === null;
|
||||
if (fast) {
|
||||
pos += n;
|
||||
diff --git a/test/simple/test-stream-writev.js b/test/simple/test-stream-writev.js
|
||||
index 5b49e6e..b5321f3 100644
|
||||
--- a/test/simple/test-stream-writev.js
|
||||
+++ b/test/simple/test-stream-writev.js
|
||||
@@ -22,7 +22,7 @@
|
||||
var common = require('../common');
|
||||
var assert = require('assert');
|
||||
|
||||
-var stream = require('stream');
|
||||
+var stream = require('../../');
|
||||
|
||||
var queue = [];
|
||||
for (var decode = 0; decode < 2; decode++) {
|
||||
diff --git a/test/simple/test-stream2-basic.js b/test/simple/test-stream2-basic.js
|
||||
index 3814bf0..248c1be 100644
|
||||
--- a/test/simple/test-stream2-basic.js
|
||||
+++ b/test/simple/test-stream2-basic.js
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
|
||||
var common = require('../common.js');
|
||||
-var R = require('_stream_readable');
|
||||
+var R = require('../../lib/_stream_readable');
|
||||
var assert = require('assert');
|
||||
|
||||
var util = require('util');
|
||||
diff --git a/test/simple/test-stream2-compatibility.js b/test/simple/test-stream2-compatibility.js
|
||||
index 6cdd4e9..f0fa84b 100644
|
||||
--- a/test/simple/test-stream2-compatibility.js
|
||||
+++ b/test/simple/test-stream2-compatibility.js
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
|
||||
var common = require('../common.js');
|
||||
-var R = require('_stream_readable');
|
||||
+var R = require('../../lib/_stream_readable');
|
||||
var assert = require('assert');
|
||||
|
||||
var util = require('util');
|
||||
diff --git a/test/simple/test-stream2-finish-pipe.js b/test/simple/test-stream2-finish-pipe.js
|
||||
index 39b274f..006a19b 100644
|
||||
--- a/test/simple/test-stream2-finish-pipe.js
|
||||
+++ b/test/simple/test-stream2-finish-pipe.js
|
||||
@@ -20,7 +20,7 @@
|
||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
var common = require('../common.js');
|
||||
-var stream = require('stream');
|
||||
+var stream = require('../../');
|
||||
var Buffer = require('buffer').Buffer;
|
||||
|
||||
var r = new stream.Readable();
|
||||
diff --git a/test/simple/test-stream2-fs.js b/test/simple/test-stream2-fs.js
|
||||
deleted file mode 100644
|
||||
index e162406..0000000
|
||||
--- a/test/simple/test-stream2-fs.js
|
||||
+++ /dev/null
|
||||
@@ -1,72 +0,0 @@
|
||||
-// Copyright Joyent, Inc. and other Node contributors.
|
||||
-//
|
||||
-// 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.
|
||||
-
|
||||
-
|
||||
-var common = require('../common.js');
|
||||
-var R = require('_stream_readable');
|
||||
-var assert = require('assert');
|
||||
-
|
||||
-var fs = require('fs');
|
||||
-var FSReadable = fs.ReadStream;
|
||||
-
|
||||
-var path = require('path');
|
||||
-var file = path.resolve(common.fixturesDir, 'x1024.txt');
|
||||
-
|
||||
-var size = fs.statSync(file).size;
|
||||
-
|
||||
-var expectLengths = [1024];
|
||||
-
|
||||
-var util = require('util');
|
||||
-var Stream = require('stream');
|
||||
-
|
||||
-util.inherits(TestWriter, Stream);
|
||||
-
|
||||
-function TestWriter() {
|
||||
- Stream.apply(this);
|
||||
- this.buffer = [];
|
||||
- this.length = 0;
|
||||
-}
|
||||
-
|
||||
-TestWriter.prototype.write = function(c) {
|
||||
- this.buffer.push(c.toString());
|
||||
- this.length += c.length;
|
||||
- return true;
|
||||
-};
|
||||
-
|
||||
-TestWriter.prototype.end = function(c) {
|
||||
- if (c) this.buffer.push(c.toString());
|
||||
- this.emit('results', this.buffer);
|
||||
-}
|
||||
-
|
||||
-var r = new FSReadable(file);
|
||||
-var w = new TestWriter();
|
||||
-
|
||||
-w.on('results', function(res) {
|
||||
- console.error(res, w.length);
|
||||
- assert.equal(w.length, size);
|
||||
- var l = 0;
|
||||
- assert.deepEqual(res.map(function (c) {
|
||||
- return c.length;
|
||||
- }), expectLengths);
|
||||
- console.log('ok');
|
||||
-});
|
||||
-
|
||||
-r.pipe(w);
|
||||
diff --git a/test/simple/test-stream2-httpclient-response-end.js b/test/simple/test-stream2-httpclient-response-end.js
|
||||
deleted file mode 100644
|
||||
index 15cffc2..0000000
|
||||
--- a/test/simple/test-stream2-httpclient-response-end.js
|
||||
+++ /dev/null
|
||||
@@ -1,52 +0,0 @@
|
||||
-// Copyright Joyent, Inc. and other Node contributors.
|
||||
-//
|
||||
-// 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.
|
||||
-
|
||||
-var common = require('../common.js');
|
||||
-var assert = require('assert');
|
||||
-var http = require('http');
|
||||
-var msg = 'Hello';
|
||||
-var readable_event = false;
|
||||
-var end_event = false;
|
||||
-var server = http.createServer(function(req, res) {
|
||||
- res.writeHead(200, {'Content-Type': 'text/plain'});
|
||||
- res.end(msg);
|
||||
-}).listen(common.PORT, function() {
|
||||
- http.get({port: common.PORT}, function(res) {
|
||||
- var data = '';
|
||||
- res.on('readable', function() {
|
||||
- console.log('readable event');
|
||||
- readable_event = true;
|
||||
- data += res.read();
|
||||
- });
|
||||
- res.on('end', function() {
|
||||
- console.log('end event');
|
||||
- end_event = true;
|
||||
- assert.strictEqual(msg, data);
|
||||
- server.close();
|
||||
- });
|
||||
- });
|
||||
-});
|
||||
-
|
||||
-process.on('exit', function() {
|
||||
- assert(readable_event);
|
||||
- assert(end_event);
|
||||
-});
|
||||
-
|
||||
diff --git a/test/simple/test-stream2-large-read-stall.js b/test/simple/test-stream2-large-read-stall.js
|
||||
index 2fbfbca..667985b 100644
|
||||
--- a/test/simple/test-stream2-large-read-stall.js
|
||||
+++ b/test/simple/test-stream2-large-read-stall.js
|
||||
@@ -30,7 +30,7 @@ var PUSHSIZE = 20;
|
||||
var PUSHCOUNT = 1000;
|
||||
var HWM = 50;
|
||||
|
||||
-var Readable = require('stream').Readable;
|
||||
+var Readable = require('../../').Readable;
|
||||
var r = new Readable({
|
||||
highWaterMark: HWM
|
||||
});
|
||||
@@ -39,23 +39,23 @@ var rs = r._readableState;
|
||||
r._read = push;
|
||||
|
||||
r.on('readable', function() {
|
||||
- console.error('>> readable');
|
||||
+ //console.error('>> readable');
|
||||
do {
|
||||
- console.error(' > read(%d)', READSIZE);
|
||||
+ //console.error(' > read(%d)', READSIZE);
|
||||
var ret = r.read(READSIZE);
|
||||
- console.error(' < %j (%d remain)', ret && ret.length, rs.length);
|
||||
+ //console.error(' < %j (%d remain)', ret && ret.length, rs.length);
|
||||
} while (ret && ret.length === READSIZE);
|
||||
|
||||
- console.error('<< after read()',
|
||||
- ret && ret.length,
|
||||
- rs.needReadable,
|
||||
- rs.length);
|
||||
+ //console.error('<< after read()',
|
||||
+ // ret && ret.length,
|
||||
+ // rs.needReadable,
|
||||
+ // rs.length);
|
||||
});
|
||||
|
||||
var endEmitted = false;
|
||||
r.on('end', function() {
|
||||
endEmitted = true;
|
||||
- console.error('end');
|
||||
+ //console.error('end');
|
||||
});
|
||||
|
||||
var pushes = 0;
|
||||
@@ -64,11 +64,11 @@ function push() {
|
||||
return;
|
||||
|
||||
if (pushes++ === PUSHCOUNT) {
|
||||
- console.error(' push(EOF)');
|
||||
+ //console.error(' push(EOF)');
|
||||
return r.push(null);
|
||||
}
|
||||
|
||||
- console.error(' push #%d', pushes);
|
||||
+ //console.error(' push #%d', pushes);
|
||||
if (r.push(new Buffer(PUSHSIZE)))
|
||||
setTimeout(push);
|
||||
}
|
||||
diff --git a/test/simple/test-stream2-objects.js b/test/simple/test-stream2-objects.js
|
||||
index 3e6931d..ff47d89 100644
|
||||
--- a/test/simple/test-stream2-objects.js
|
||||
+++ b/test/simple/test-stream2-objects.js
|
||||
@@ -21,8 +21,8 @@
|
||||
|
||||
|
||||
var common = require('../common.js');
|
||||
-var Readable = require('_stream_readable');
|
||||
-var Writable = require('_stream_writable');
|
||||
+var Readable = require('../../lib/_stream_readable');
|
||||
+var Writable = require('../../lib/_stream_writable');
|
||||
var assert = require('assert');
|
||||
|
||||
// tiny node-tap lookalike.
|
||||
diff --git a/test/simple/test-stream2-pipe-error-handling.js b/test/simple/test-stream2-pipe-error-handling.js
|
||||
index cf7531c..e3f3e4e 100644
|
||||
--- a/test/simple/test-stream2-pipe-error-handling.js
|
||||
+++ b/test/simple/test-stream2-pipe-error-handling.js
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
var common = require('../common');
|
||||
var assert = require('assert');
|
||||
-var stream = require('stream');
|
||||
+var stream = require('../../');
|
||||
|
||||
(function testErrorListenerCatches() {
|
||||
var count = 1000;
|
||||
diff --git a/test/simple/test-stream2-pipe-error-once-listener.js b/test/simple/test-stream2-pipe-error-once-listener.js
|
||||
index 5e8e3cb..53b2616 100755
|
||||
--- a/test/simple/test-stream2-pipe-error-once-listener.js
|
||||
+++ b/test/simple/test-stream2-pipe-error-once-listener.js
|
||||
@@ -24,7 +24,7 @@ var common = require('../common.js');
|
||||
var assert = require('assert');
|
||||
|
||||
var util = require('util');
|
||||
-var stream = require('stream');
|
||||
+var stream = require('../../');
|
||||
|
||||
|
||||
var Read = function() {
|
||||
diff --git a/test/simple/test-stream2-push.js b/test/simple/test-stream2-push.js
|
||||
index b63edc3..eb2b0e9 100644
|
||||
--- a/test/simple/test-stream2-push.js
|
||||
+++ b/test/simple/test-stream2-push.js
|
||||
@@ -20,7 +20,7 @@
|
||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
var common = require('../common.js');
|
||||
-var stream = require('stream');
|
||||
+var stream = require('../../');
|
||||
var Readable = stream.Readable;
|
||||
var Writable = stream.Writable;
|
||||
var assert = require('assert');
|
||||
diff --git a/test/simple/test-stream2-read-sync-stack.js b/test/simple/test-stream2-read-sync-stack.js
|
||||
index e8a7305..9740a47 100644
|
||||
--- a/test/simple/test-stream2-read-sync-stack.js
|
||||
+++ b/test/simple/test-stream2-read-sync-stack.js
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
var common = require('../common');
|
||||
var assert = require('assert');
|
||||
-var Readable = require('stream').Readable;
|
||||
+var Readable = require('../../').Readable;
|
||||
var r = new Readable();
|
||||
var N = 256 * 1024;
|
||||
|
||||
diff --git a/test/simple/test-stream2-readable-empty-buffer-no-eof.js b/test/simple/test-stream2-readable-empty-buffer-no-eof.js
|
||||
index cd30178..4b1659d 100644
|
||||
--- a/test/simple/test-stream2-readable-empty-buffer-no-eof.js
|
||||
+++ b/test/simple/test-stream2-readable-empty-buffer-no-eof.js
|
||||
@@ -22,10 +22,9 @@
|
||||
var common = require('../common');
|
||||
var assert = require('assert');
|
||||
|
||||
-var Readable = require('stream').Readable;
|
||||
+var Readable = require('../../').Readable;
|
||||
|
||||
test1();
|
||||
-test2();
|
||||
|
||||
function test1() {
|
||||
var r = new Readable();
|
||||
@@ -88,31 +87,3 @@ function test1() {
|
||||
console.log('ok');
|
||||
});
|
||||
}
|
||||
-
|
||||
-function test2() {
|
||||
- var r = new Readable({ encoding: 'base64' });
|
||||
- var reads = 5;
|
||||
- r._read = function(n) {
|
||||
- if (!reads--)
|
||||
- return r.push(null); // EOF
|
||||
- else
|
||||
- return r.push(new Buffer('x'));
|
||||
- };
|
||||
-
|
||||
- var results = [];
|
||||
- function flow() {
|
||||
- var chunk;
|
||||
- while (null !== (chunk = r.read()))
|
||||
- results.push(chunk + '');
|
||||
- }
|
||||
- r.on('readable', flow);
|
||||
- r.on('end', function() {
|
||||
- results.push('EOF');
|
||||
- });
|
||||
- flow();
|
||||
-
|
||||
- process.on('exit', function() {
|
||||
- assert.deepEqual(results, [ 'eHh4', 'eHg=', 'EOF' ]);
|
||||
- console.log('ok');
|
||||
- });
|
||||
-}
|
||||
diff --git a/test/simple/test-stream2-readable-from-list.js b/test/simple/test-stream2-readable-from-list.js
|
||||
index 7c96ffe..04a96f5 100644
|
||||
--- a/test/simple/test-stream2-readable-from-list.js
|
||||
+++ b/test/simple/test-stream2-readable-from-list.js
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
var assert = require('assert');
|
||||
var common = require('../common.js');
|
||||
-var fromList = require('_stream_readable')._fromList;
|
||||
+var fromList = require('../../lib/_stream_readable')._fromList;
|
||||
|
||||
// tiny node-tap lookalike.
|
||||
var tests = [];
|
||||
diff --git a/test/simple/test-stream2-readable-legacy-drain.js b/test/simple/test-stream2-readable-legacy-drain.js
|
||||
index 675da8e..51fd3d5 100644
|
||||
--- a/test/simple/test-stream2-readable-legacy-drain.js
|
||||
+++ b/test/simple/test-stream2-readable-legacy-drain.js
|
||||
@@ -22,7 +22,7 @@
|
||||
var common = require('../common');
|
||||
var assert = require('assert');
|
||||
|
||||
-var Stream = require('stream');
|
||||
+var Stream = require('../../');
|
||||
var Readable = Stream.Readable;
|
||||
|
||||
var r = new Readable();
|
||||
diff --git a/test/simple/test-stream2-readable-non-empty-end.js b/test/simple/test-stream2-readable-non-empty-end.js
|
||||
index 7314ae7..c971898 100644
|
||||
--- a/test/simple/test-stream2-readable-non-empty-end.js
|
||||
+++ b/test/simple/test-stream2-readable-non-empty-end.js
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
var assert = require('assert');
|
||||
var common = require('../common.js');
|
||||
-var Readable = require('_stream_readable');
|
||||
+var Readable = require('../../lib/_stream_readable');
|
||||
|
||||
var len = 0;
|
||||
var chunks = new Array(10);
|
||||
diff --git a/test/simple/test-stream2-readable-wrap-empty.js b/test/simple/test-stream2-readable-wrap-empty.js
|
||||
index 2e5cf25..fd8a3dc 100644
|
||||
--- a/test/simple/test-stream2-readable-wrap-empty.js
|
||||
+++ b/test/simple/test-stream2-readable-wrap-empty.js
|
||||
@@ -22,7 +22,7 @@
|
||||
var common = require('../common');
|
||||
var assert = require('assert');
|
||||
|
||||
-var Readable = require('_stream_readable');
|
||||
+var Readable = require('../../lib/_stream_readable');
|
||||
var EE = require('events').EventEmitter;
|
||||
|
||||
var oldStream = new EE();
|
||||
diff --git a/test/simple/test-stream2-readable-wrap.js b/test/simple/test-stream2-readable-wrap.js
|
||||
index 90eea01..6b177f7 100644
|
||||
--- a/test/simple/test-stream2-readable-wrap.js
|
||||
+++ b/test/simple/test-stream2-readable-wrap.js
|
||||
@@ -22,8 +22,8 @@
|
||||
var common = require('../common');
|
||||
var assert = require('assert');
|
||||
|
||||
-var Readable = require('_stream_readable');
|
||||
-var Writable = require('_stream_writable');
|
||||
+var Readable = require('../../lib/_stream_readable');
|
||||
+var Writable = require('../../lib/_stream_writable');
|
||||
var EE = require('events').EventEmitter;
|
||||
|
||||
var testRuns = 0, completedRuns = 0;
|
||||
diff --git a/test/simple/test-stream2-set-encoding.js b/test/simple/test-stream2-set-encoding.js
|
||||
index 5d2c32a..685531b 100644
|
||||
--- a/test/simple/test-stream2-set-encoding.js
|
||||
+++ b/test/simple/test-stream2-set-encoding.js
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
var common = require('../common.js');
|
||||
var assert = require('assert');
|
||||
-var R = require('_stream_readable');
|
||||
+var R = require('../../lib/_stream_readable');
|
||||
var util = require('util');
|
||||
|
||||
// tiny node-tap lookalike.
|
||||
diff --git a/test/simple/test-stream2-transform.js b/test/simple/test-stream2-transform.js
|
||||
index 9c9ddd8..a0cacc6 100644
|
||||
--- a/test/simple/test-stream2-transform.js
|
||||
+++ b/test/simple/test-stream2-transform.js
|
||||
@@ -21,8 +21,8 @@
|
||||
|
||||
var assert = require('assert');
|
||||
var common = require('../common.js');
|
||||
-var PassThrough = require('_stream_passthrough');
|
||||
-var Transform = require('_stream_transform');
|
||||
+var PassThrough = require('../../').PassThrough;
|
||||
+var Transform = require('../../').Transform;
|
||||
|
||||
// tiny node-tap lookalike.
|
||||
var tests = [];
|
||||
diff --git a/test/simple/test-stream2-unpipe-drain.js b/test/simple/test-stream2-unpipe-drain.js
|
||||
index d66dc3c..365b327 100644
|
||||
--- a/test/simple/test-stream2-unpipe-drain.js
|
||||
+++ b/test/simple/test-stream2-unpipe-drain.js
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
var common = require('../common.js');
|
||||
var assert = require('assert');
|
||||
-var stream = require('stream');
|
||||
+var stream = require('../../');
|
||||
var crypto = require('crypto');
|
||||
|
||||
var util = require('util');
|
||||
diff --git a/test/simple/test-stream2-unpipe-leak.js b/test/simple/test-stream2-unpipe-leak.js
|
||||
index 99f8746..17c92ae 100644
|
||||
--- a/test/simple/test-stream2-unpipe-leak.js
|
||||
+++ b/test/simple/test-stream2-unpipe-leak.js
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
var common = require('../common.js');
|
||||
var assert = require('assert');
|
||||
-var stream = require('stream');
|
||||
+var stream = require('../../');
|
||||
|
||||
var chunk = new Buffer('hallo');
|
||||
|
||||
diff --git a/test/simple/test-stream2-writable.js b/test/simple/test-stream2-writable.js
|
||||
index 704100c..209c3a6 100644
|
||||
--- a/test/simple/test-stream2-writable.js
|
||||
+++ b/test/simple/test-stream2-writable.js
|
||||
@@ -20,8 +20,8 @@
|
||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
var common = require('../common.js');
|
||||
-var W = require('_stream_writable');
|
||||
-var D = require('_stream_duplex');
|
||||
+var W = require('../../').Writable;
|
||||
+var D = require('../../').Duplex;
|
||||
var assert = require('assert');
|
||||
|
||||
var util = require('util');
|
||||
diff --git a/test/simple/test-stream3-pause-then-read.js b/test/simple/test-stream3-pause-then-read.js
|
||||
index b91bde3..2f72c15 100644
|
||||
--- a/test/simple/test-stream3-pause-then-read.js
|
||||
+++ b/test/simple/test-stream3-pause-then-read.js
|
||||
@@ -22,7 +22,7 @@
|
||||
var common = require('../common');
|
||||
var assert = require('assert');
|
||||
|
||||
-var stream = require('stream');
|
||||
+var stream = require('../../');
|
||||
var Readable = stream.Readable;
|
||||
var Writable = stream.Writable;
|
||||
|
||||
89
static/js/ketcher2/node_modules/varstream/node_modules/readable-stream/lib/_stream_duplex.js
generated
vendored
Normal file
89
static/js/ketcher2/node_modules/varstream/node_modules/readable-stream/lib/_stream_duplex.js
generated
vendored
Normal file
@ -0,0 +1,89 @@
|
||||
// Copyright Joyent, Inc. and other Node contributors.
|
||||
//
|
||||
// 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.
|
||||
|
||||
// a duplex stream is just a stream that is both readable and writable.
|
||||
// Since JS doesn't have multiple prototypal inheritance, this class
|
||||
// prototypally inherits from Readable, and then parasitically from
|
||||
// Writable.
|
||||
|
||||
module.exports = Duplex;
|
||||
|
||||
/*<replacement>*/
|
||||
var objectKeys = Object.keys || function (obj) {
|
||||
var keys = [];
|
||||
for (var key in obj) keys.push(key);
|
||||
return keys;
|
||||
}
|
||||
/*</replacement>*/
|
||||
|
||||
|
||||
/*<replacement>*/
|
||||
var util = require('core-util-is');
|
||||
util.inherits = require('inherits');
|
||||
/*</replacement>*/
|
||||
|
||||
var Readable = require('./_stream_readable');
|
||||
var Writable = require('./_stream_writable');
|
||||
|
||||
util.inherits(Duplex, Readable);
|
||||
|
||||
forEach(objectKeys(Writable.prototype), function(method) {
|
||||
if (!Duplex.prototype[method])
|
||||
Duplex.prototype[method] = Writable.prototype[method];
|
||||
});
|
||||
|
||||
function Duplex(options) {
|
||||
if (!(this instanceof Duplex))
|
||||
return new Duplex(options);
|
||||
|
||||
Readable.call(this, options);
|
||||
Writable.call(this, options);
|
||||
|
||||
if (options && options.readable === false)
|
||||
this.readable = false;
|
||||
|
||||
if (options && options.writable === false)
|
||||
this.writable = false;
|
||||
|
||||
this.allowHalfOpen = true;
|
||||
if (options && options.allowHalfOpen === false)
|
||||
this.allowHalfOpen = false;
|
||||
|
||||
this.once('end', onend);
|
||||
}
|
||||
|
||||
// the no-half-open enforcer
|
||||
function onend() {
|
||||
// if we allow half-open state, or if the writable side ended,
|
||||
// then we're ok.
|
||||
if (this.allowHalfOpen || this._writableState.ended)
|
||||
return;
|
||||
|
||||
// no more data can be written.
|
||||
// But allow more writes to happen in this tick.
|
||||
process.nextTick(this.end.bind(this));
|
||||
}
|
||||
|
||||
function forEach (xs, f) {
|
||||
for (var i = 0, l = xs.length; i < l; i++) {
|
||||
f(xs[i], i);
|
||||
}
|
||||
}
|
||||
46
static/js/ketcher2/node_modules/varstream/node_modules/readable-stream/lib/_stream_passthrough.js
generated
vendored
Normal file
46
static/js/ketcher2/node_modules/varstream/node_modules/readable-stream/lib/_stream_passthrough.js
generated
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
// Copyright Joyent, Inc. and other Node contributors.
|
||||
//
|
||||
// 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.
|
||||
|
||||
// a passthrough stream.
|
||||
// basically just the most minimal sort of Transform stream.
|
||||
// Every written chunk gets output as-is.
|
||||
|
||||
module.exports = PassThrough;
|
||||
|
||||
var Transform = require('./_stream_transform');
|
||||
|
||||
/*<replacement>*/
|
||||
var util = require('core-util-is');
|
||||
util.inherits = require('inherits');
|
||||
/*</replacement>*/
|
||||
|
||||
util.inherits(PassThrough, Transform);
|
||||
|
||||
function PassThrough(options) {
|
||||
if (!(this instanceof PassThrough))
|
||||
return new PassThrough(options);
|
||||
|
||||
Transform.call(this, options);
|
||||
}
|
||||
|
||||
PassThrough.prototype._transform = function(chunk, encoding, cb) {
|
||||
cb(null, chunk);
|
||||
};
|
||||
951
static/js/ketcher2/node_modules/varstream/node_modules/readable-stream/lib/_stream_readable.js
generated
vendored
Normal file
951
static/js/ketcher2/node_modules/varstream/node_modules/readable-stream/lib/_stream_readable.js
generated
vendored
Normal file
@ -0,0 +1,951 @@
|
||||
// Copyright Joyent, Inc. and other Node contributors.
|
||||
//
|
||||
// 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.
|
||||
|
||||
module.exports = Readable;
|
||||
|
||||
/*<replacement>*/
|
||||
var isArray = require('isarray');
|
||||
/*</replacement>*/
|
||||
|
||||
|
||||
/*<replacement>*/
|
||||
var Buffer = require('buffer').Buffer;
|
||||
/*</replacement>*/
|
||||
|
||||
Readable.ReadableState = ReadableState;
|
||||
|
||||
var EE = require('events').EventEmitter;
|
||||
|
||||
/*<replacement>*/
|
||||
if (!EE.listenerCount) EE.listenerCount = function(emitter, type) {
|
||||
return emitter.listeners(type).length;
|
||||
};
|
||||
/*</replacement>*/
|
||||
|
||||
var Stream = require('stream');
|
||||
|
||||
/*<replacement>*/
|
||||
var util = require('core-util-is');
|
||||
util.inherits = require('inherits');
|
||||
/*</replacement>*/
|
||||
|
||||
var StringDecoder;
|
||||
|
||||
|
||||
/*<replacement>*/
|
||||
var debug = require('util');
|
||||
if (debug && debug.debuglog) {
|
||||
debug = debug.debuglog('stream');
|
||||
} else {
|
||||
debug = function () {};
|
||||
}
|
||||
/*</replacement>*/
|
||||
|
||||
|
||||
util.inherits(Readable, Stream);
|
||||
|
||||
function ReadableState(options, stream) {
|
||||
var Duplex = require('./_stream_duplex');
|
||||
|
||||
options = options || {};
|
||||
|
||||
// the point at which it stops calling _read() to fill the buffer
|
||||
// Note: 0 is a valid value, means "don't call _read preemptively ever"
|
||||
var hwm = options.highWaterMark;
|
||||
var defaultHwm = options.objectMode ? 16 : 16 * 1024;
|
||||
this.highWaterMark = (hwm || hwm === 0) ? hwm : defaultHwm;
|
||||
|
||||
// cast to ints.
|
||||
this.highWaterMark = ~~this.highWaterMark;
|
||||
|
||||
this.buffer = [];
|
||||
this.length = 0;
|
||||
this.pipes = null;
|
||||
this.pipesCount = 0;
|
||||
this.flowing = null;
|
||||
this.ended = false;
|
||||
this.endEmitted = false;
|
||||
this.reading = false;
|
||||
|
||||
// a flag to be able to tell if the onwrite cb is called immediately,
|
||||
// or on a later tick. We set this to true at first, because any
|
||||
// actions that shouldn't happen until "later" should generally also
|
||||
// not happen before the first write call.
|
||||
this.sync = true;
|
||||
|
||||
// whenever we return null, then we set a flag to say
|
||||
// that we're awaiting a 'readable' event emission.
|
||||
this.needReadable = false;
|
||||
this.emittedReadable = false;
|
||||
this.readableListening = false;
|
||||
|
||||
|
||||
// object stream flag. Used to make read(n) ignore n and to
|
||||
// make all the buffer merging and length checks go away
|
||||
this.objectMode = !!options.objectMode;
|
||||
|
||||
if (stream instanceof Duplex)
|
||||
this.objectMode = this.objectMode || !!options.readableObjectMode;
|
||||
|
||||
// Crypto is kind of old and crusty. Historically, its default string
|
||||
// encoding is 'binary' so we have to make this configurable.
|
||||
// Everything else in the universe uses 'utf8', though.
|
||||
this.defaultEncoding = options.defaultEncoding || 'utf8';
|
||||
|
||||
// when piping, we only care about 'readable' events that happen
|
||||
// after read()ing all the bytes and not getting any pushback.
|
||||
this.ranOut = false;
|
||||
|
||||
// the number of writers that are awaiting a drain event in .pipe()s
|
||||
this.awaitDrain = 0;
|
||||
|
||||
// if true, a maybeReadMore has been scheduled
|
||||
this.readingMore = false;
|
||||
|
||||
this.decoder = null;
|
||||
this.encoding = null;
|
||||
if (options.encoding) {
|
||||
if (!StringDecoder)
|
||||
StringDecoder = require('string_decoder/').StringDecoder;
|
||||
this.decoder = new StringDecoder(options.encoding);
|
||||
this.encoding = options.encoding;
|
||||
}
|
||||
}
|
||||
|
||||
function Readable(options) {
|
||||
var Duplex = require('./_stream_duplex');
|
||||
|
||||
if (!(this instanceof Readable))
|
||||
return new Readable(options);
|
||||
|
||||
this._readableState = new ReadableState(options, this);
|
||||
|
||||
// legacy
|
||||
this.readable = true;
|
||||
|
||||
Stream.call(this);
|
||||
}
|
||||
|
||||
// Manually shove something into the read() buffer.
|
||||
// This returns true if the highWaterMark has not been hit yet,
|
||||
// similar to how Writable.write() returns true if you should
|
||||
// write() some more.
|
||||
Readable.prototype.push = function(chunk, encoding) {
|
||||
var state = this._readableState;
|
||||
|
||||
if (util.isString(chunk) && !state.objectMode) {
|
||||
encoding = encoding || state.defaultEncoding;
|
||||
if (encoding !== state.encoding) {
|
||||
chunk = new Buffer(chunk, encoding);
|
||||
encoding = '';
|
||||
}
|
||||
}
|
||||
|
||||
return readableAddChunk(this, state, chunk, encoding, false);
|
||||
};
|
||||
|
||||
// Unshift should *always* be something directly out of read()
|
||||
Readable.prototype.unshift = function(chunk) {
|
||||
var state = this._readableState;
|
||||
return readableAddChunk(this, state, chunk, '', true);
|
||||
};
|
||||
|
||||
function readableAddChunk(stream, state, chunk, encoding, addToFront) {
|
||||
var er = chunkInvalid(state, chunk);
|
||||
if (er) {
|
||||
stream.emit('error', er);
|
||||
} else if (util.isNullOrUndefined(chunk)) {
|
||||
state.reading = false;
|
||||
if (!state.ended)
|
||||
onEofChunk(stream, state);
|
||||
} else if (state.objectMode || chunk && chunk.length > 0) {
|
||||
if (state.ended && !addToFront) {
|
||||
var e = new Error('stream.push() after EOF');
|
||||
stream.emit('error', e);
|
||||
} else if (state.endEmitted && addToFront) {
|
||||
var e = new Error('stream.unshift() after end event');
|
||||
stream.emit('error', e);
|
||||
} else {
|
||||
if (state.decoder && !addToFront && !encoding)
|
||||
chunk = state.decoder.write(chunk);
|
||||
|
||||
if (!addToFront)
|
||||
state.reading = false;
|
||||
|
||||
// if we want the data now, just emit it.
|
||||
if (state.flowing && state.length === 0 && !state.sync) {
|
||||
stream.emit('data', chunk);
|
||||
stream.read(0);
|
||||
} else {
|
||||
// update the buffer info.
|
||||
state.length += state.objectMode ? 1 : chunk.length;
|
||||
if (addToFront)
|
||||
state.buffer.unshift(chunk);
|
||||
else
|
||||
state.buffer.push(chunk);
|
||||
|
||||
if (state.needReadable)
|
||||
emitReadable(stream);
|
||||
}
|
||||
|
||||
maybeReadMore(stream, state);
|
||||
}
|
||||
} else if (!addToFront) {
|
||||
state.reading = false;
|
||||
}
|
||||
|
||||
return needMoreData(state);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// if it's past the high water mark, we can push in some more.
|
||||
// Also, if we have no data yet, we can stand some
|
||||
// more bytes. This is to work around cases where hwm=0,
|
||||
// such as the repl. Also, if the push() triggered a
|
||||
// readable event, and the user called read(largeNumber) such that
|
||||
// needReadable was set, then we ought to push more, so that another
|
||||
// 'readable' event will be triggered.
|
||||
function needMoreData(state) {
|
||||
return !state.ended &&
|
||||
(state.needReadable ||
|
||||
state.length < state.highWaterMark ||
|
||||
state.length === 0);
|
||||
}
|
||||
|
||||
// backwards compatibility.
|
||||
Readable.prototype.setEncoding = function(enc) {
|
||||
if (!StringDecoder)
|
||||
StringDecoder = require('string_decoder/').StringDecoder;
|
||||
this._readableState.decoder = new StringDecoder(enc);
|
||||
this._readableState.encoding = enc;
|
||||
return this;
|
||||
};
|
||||
|
||||
// Don't raise the hwm > 128MB
|
||||
var MAX_HWM = 0x800000;
|
||||
function roundUpToNextPowerOf2(n) {
|
||||
if (n >= MAX_HWM) {
|
||||
n = MAX_HWM;
|
||||
} else {
|
||||
// Get the next highest power of 2
|
||||
n--;
|
||||
for (var p = 1; p < 32; p <<= 1) n |= n >> p;
|
||||
n++;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
function howMuchToRead(n, state) {
|
||||
if (state.length === 0 && state.ended)
|
||||
return 0;
|
||||
|
||||
if (state.objectMode)
|
||||
return n === 0 ? 0 : 1;
|
||||
|
||||
if (isNaN(n) || util.isNull(n)) {
|
||||
// only flow one buffer at a time
|
||||
if (state.flowing && state.buffer.length)
|
||||
return state.buffer[0].length;
|
||||
else
|
||||
return state.length;
|
||||
}
|
||||
|
||||
if (n <= 0)
|
||||
return 0;
|
||||
|
||||
// If we're asking for more than the target buffer level,
|
||||
// then raise the water mark. Bump up to the next highest
|
||||
// power of 2, to prevent increasing it excessively in tiny
|
||||
// amounts.
|
||||
if (n > state.highWaterMark)
|
||||
state.highWaterMark = roundUpToNextPowerOf2(n);
|
||||
|
||||
// don't have that much. return null, unless we've ended.
|
||||
if (n > state.length) {
|
||||
if (!state.ended) {
|
||||
state.needReadable = true;
|
||||
return 0;
|
||||
} else
|
||||
return state.length;
|
||||
}
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
// you can override either this method, or the async _read(n) below.
|
||||
Readable.prototype.read = function(n) {
|
||||
debug('read', n);
|
||||
var state = this._readableState;
|
||||
var nOrig = n;
|
||||
|
||||
if (!util.isNumber(n) || n > 0)
|
||||
state.emittedReadable = false;
|
||||
|
||||
// if we're doing read(0) to trigger a readable event, but we
|
||||
// already have a bunch of data in the buffer, then just trigger
|
||||
// the 'readable' event and move on.
|
||||
if (n === 0 &&
|
||||
state.needReadable &&
|
||||
(state.length >= state.highWaterMark || state.ended)) {
|
||||
debug('read: emitReadable', state.length, state.ended);
|
||||
if (state.length === 0 && state.ended)
|
||||
endReadable(this);
|
||||
else
|
||||
emitReadable(this);
|
||||
return null;
|
||||
}
|
||||
|
||||
n = howMuchToRead(n, state);
|
||||
|
||||
// if we've ended, and we're now clear, then finish it up.
|
||||
if (n === 0 && state.ended) {
|
||||
if (state.length === 0)
|
||||
endReadable(this);
|
||||
return null;
|
||||
}
|
||||
|
||||
// All the actual chunk generation logic needs to be
|
||||
// *below* the call to _read. The reason is that in certain
|
||||
// synthetic stream cases, such as passthrough streams, _read
|
||||
// may be a completely synchronous operation which may change
|
||||
// the state of the read buffer, providing enough data when
|
||||
// before there was *not* enough.
|
||||
//
|
||||
// So, the steps are:
|
||||
// 1. Figure out what the state of things will be after we do
|
||||
// a read from the buffer.
|
||||
//
|
||||
// 2. If that resulting state will trigger a _read, then call _read.
|
||||
// Note that this may be asynchronous, or synchronous. Yes, it is
|
||||
// deeply ugly to write APIs this way, but that still doesn't mean
|
||||
// that the Readable class should behave improperly, as streams are
|
||||
// designed to be sync/async agnostic.
|
||||
// Take note if the _read call is sync or async (ie, if the read call
|
||||
// has returned yet), so that we know whether or not it's safe to emit
|
||||
// 'readable' etc.
|
||||
//
|
||||
// 3. Actually pull the requested chunks out of the buffer and return.
|
||||
|
||||
// if we need a readable event, then we need to do some reading.
|
||||
var doRead = state.needReadable;
|
||||
debug('need readable', doRead);
|
||||
|
||||
// if we currently have less than the highWaterMark, then also read some
|
||||
if (state.length === 0 || state.length - n < state.highWaterMark) {
|
||||
doRead = true;
|
||||
debug('length less than watermark', doRead);
|
||||
}
|
||||
|
||||
// however, if we've ended, then there's no point, and if we're already
|
||||
// reading, then it's unnecessary.
|
||||
if (state.ended || state.reading) {
|
||||
doRead = false;
|
||||
debug('reading or ended', doRead);
|
||||
}
|
||||
|
||||
if (doRead) {
|
||||
debug('do read');
|
||||
state.reading = true;
|
||||
state.sync = true;
|
||||
// if the length is currently zero, then we *need* a readable event.
|
||||
if (state.length === 0)
|
||||
state.needReadable = true;
|
||||
// call internal read method
|
||||
this._read(state.highWaterMark);
|
||||
state.sync = false;
|
||||
}
|
||||
|
||||
// If _read pushed data synchronously, then `reading` will be false,
|
||||
// and we need to re-evaluate how much data we can return to the user.
|
||||
if (doRead && !state.reading)
|
||||
n = howMuchToRead(nOrig, state);
|
||||
|
||||
var ret;
|
||||
if (n > 0)
|
||||
ret = fromList(n, state);
|
||||
else
|
||||
ret = null;
|
||||
|
||||
if (util.isNull(ret)) {
|
||||
state.needReadable = true;
|
||||
n = 0;
|
||||
}
|
||||
|
||||
state.length -= n;
|
||||
|
||||
// If we have nothing in the buffer, then we want to know
|
||||
// as soon as we *do* get something into the buffer.
|
||||
if (state.length === 0 && !state.ended)
|
||||
state.needReadable = true;
|
||||
|
||||
// If we tried to read() past the EOF, then emit end on the next tick.
|
||||
if (nOrig !== n && state.ended && state.length === 0)
|
||||
endReadable(this);
|
||||
|
||||
if (!util.isNull(ret))
|
||||
this.emit('data', ret);
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
function chunkInvalid(state, chunk) {
|
||||
var er = null;
|
||||
if (!util.isBuffer(chunk) &&
|
||||
!util.isString(chunk) &&
|
||||
!util.isNullOrUndefined(chunk) &&
|
||||
!state.objectMode) {
|
||||
er = new TypeError('Invalid non-string/buffer chunk');
|
||||
}
|
||||
return er;
|
||||
}
|
||||
|
||||
|
||||
function onEofChunk(stream, state) {
|
||||
if (state.decoder && !state.ended) {
|
||||
var chunk = state.decoder.end();
|
||||
if (chunk && chunk.length) {
|
||||
state.buffer.push(chunk);
|
||||
state.length += state.objectMode ? 1 : chunk.length;
|
||||
}
|
||||
}
|
||||
state.ended = true;
|
||||
|
||||
// emit 'readable' now to make sure it gets picked up.
|
||||
emitReadable(stream);
|
||||
}
|
||||
|
||||
// Don't emit readable right away in sync mode, because this can trigger
|
||||
// another read() call => stack overflow. This way, it might trigger
|
||||
// a nextTick recursion warning, but that's not so bad.
|
||||
function emitReadable(stream) {
|
||||
var state = stream._readableState;
|
||||
state.needReadable = false;
|
||||
if (!state.emittedReadable) {
|
||||
debug('emitReadable', state.flowing);
|
||||
state.emittedReadable = true;
|
||||
if (state.sync)
|
||||
process.nextTick(function() {
|
||||
emitReadable_(stream);
|
||||
});
|
||||
else
|
||||
emitReadable_(stream);
|
||||
}
|
||||
}
|
||||
|
||||
function emitReadable_(stream) {
|
||||
debug('emit readable');
|
||||
stream.emit('readable');
|
||||
flow(stream);
|
||||
}
|
||||
|
||||
|
||||
// at this point, the user has presumably seen the 'readable' event,
|
||||
// and called read() to consume some data. that may have triggered
|
||||
// in turn another _read(n) call, in which case reading = true if
|
||||
// it's in progress.
|
||||
// However, if we're not ended, or reading, and the length < hwm,
|
||||
// then go ahead and try to read some more preemptively.
|
||||
function maybeReadMore(stream, state) {
|
||||
if (!state.readingMore) {
|
||||
state.readingMore = true;
|
||||
process.nextTick(function() {
|
||||
maybeReadMore_(stream, state);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function maybeReadMore_(stream, state) {
|
||||
var len = state.length;
|
||||
while (!state.reading && !state.flowing && !state.ended &&
|
||||
state.length < state.highWaterMark) {
|
||||
debug('maybeReadMore read 0');
|
||||
stream.read(0);
|
||||
if (len === state.length)
|
||||
// didn't get any data, stop spinning.
|
||||
break;
|
||||
else
|
||||
len = state.length;
|
||||
}
|
||||
state.readingMore = false;
|
||||
}
|
||||
|
||||
// abstract method. to be overridden in specific implementation classes.
|
||||
// call cb(er, data) where data is <= n in length.
|
||||
// for virtual (non-string, non-buffer) streams, "length" is somewhat
|
||||
// arbitrary, and perhaps not very meaningful.
|
||||
Readable.prototype._read = function(n) {
|
||||
this.emit('error', new Error('not implemented'));
|
||||
};
|
||||
|
||||
Readable.prototype.pipe = function(dest, pipeOpts) {
|
||||
var src = this;
|
||||
var state = this._readableState;
|
||||
|
||||
switch (state.pipesCount) {
|
||||
case 0:
|
||||
state.pipes = dest;
|
||||
break;
|
||||
case 1:
|
||||
state.pipes = [state.pipes, dest];
|
||||
break;
|
||||
default:
|
||||
state.pipes.push(dest);
|
||||
break;
|
||||
}
|
||||
state.pipesCount += 1;
|
||||
debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);
|
||||
|
||||
var doEnd = (!pipeOpts || pipeOpts.end !== false) &&
|
||||
dest !== process.stdout &&
|
||||
dest !== process.stderr;
|
||||
|
||||
var endFn = doEnd ? onend : cleanup;
|
||||
if (state.endEmitted)
|
||||
process.nextTick(endFn);
|
||||
else
|
||||
src.once('end', endFn);
|
||||
|
||||
dest.on('unpipe', onunpipe);
|
||||
function onunpipe(readable) {
|
||||
debug('onunpipe');
|
||||
if (readable === src) {
|
||||
cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
function onend() {
|
||||
debug('onend');
|
||||
dest.end();
|
||||
}
|
||||
|
||||
// when the dest drains, it reduces the awaitDrain counter
|
||||
// on the source. This would be more elegant with a .once()
|
||||
// handler in flow(), but adding and removing repeatedly is
|
||||
// too slow.
|
||||
var ondrain = pipeOnDrain(src);
|
||||
dest.on('drain', ondrain);
|
||||
|
||||
function cleanup() {
|
||||
debug('cleanup');
|
||||
// cleanup event handlers once the pipe is broken
|
||||
dest.removeListener('close', onclose);
|
||||
dest.removeListener('finish', onfinish);
|
||||
dest.removeListener('drain', ondrain);
|
||||
dest.removeListener('error', onerror);
|
||||
dest.removeListener('unpipe', onunpipe);
|
||||
src.removeListener('end', onend);
|
||||
src.removeListener('end', cleanup);
|
||||
src.removeListener('data', ondata);
|
||||
|
||||
// if the reader is waiting for a drain event from this
|
||||
// specific writer, then it would cause it to never start
|
||||
// flowing again.
|
||||
// So, if this is awaiting a drain, then we just call it now.
|
||||
// If we don't know, then assume that we are waiting for one.
|
||||
if (state.awaitDrain &&
|
||||
(!dest._writableState || dest._writableState.needDrain))
|
||||
ondrain();
|
||||
}
|
||||
|
||||
src.on('data', ondata);
|
||||
function ondata(chunk) {
|
||||
debug('ondata');
|
||||
var ret = dest.write(chunk);
|
||||
if (false === ret) {
|
||||
debug('false write response, pause',
|
||||
src._readableState.awaitDrain);
|
||||
src._readableState.awaitDrain++;
|
||||
src.pause();
|
||||
}
|
||||
}
|
||||
|
||||
// if the dest has an error, then stop piping into it.
|
||||
// however, don't suppress the throwing behavior for this.
|
||||
function onerror(er) {
|
||||
debug('onerror', er);
|
||||
unpipe();
|
||||
dest.removeListener('error', onerror);
|
||||
if (EE.listenerCount(dest, 'error') === 0)
|
||||
dest.emit('error', er);
|
||||
}
|
||||
// This is a brutally ugly hack to make sure that our error handler
|
||||
// is attached before any userland ones. NEVER DO THIS.
|
||||
if (!dest._events || !dest._events.error)
|
||||
dest.on('error', onerror);
|
||||
else if (isArray(dest._events.error))
|
||||
dest._events.error.unshift(onerror);
|
||||
else
|
||||
dest._events.error = [onerror, dest._events.error];
|
||||
|
||||
|
||||
|
||||
// Both close and finish should trigger unpipe, but only once.
|
||||
function onclose() {
|
||||
dest.removeListener('finish', onfinish);
|
||||
unpipe();
|
||||
}
|
||||
dest.once('close', onclose);
|
||||
function onfinish() {
|
||||
debug('onfinish');
|
||||
dest.removeListener('close', onclose);
|
||||
unpipe();
|
||||
}
|
||||
dest.once('finish', onfinish);
|
||||
|
||||
function unpipe() {
|
||||
debug('unpipe');
|
||||
src.unpipe(dest);
|
||||
}
|
||||
|
||||
// tell the dest that it's being piped to
|
||||
dest.emit('pipe', src);
|
||||
|
||||
// start the flow if it hasn't been started already.
|
||||
if (!state.flowing) {
|
||||
debug('pipe resume');
|
||||
src.resume();
|
||||
}
|
||||
|
||||
return dest;
|
||||
};
|
||||
|
||||
function pipeOnDrain(src) {
|
||||
return function() {
|
||||
var state = src._readableState;
|
||||
debug('pipeOnDrain', state.awaitDrain);
|
||||
if (state.awaitDrain)
|
||||
state.awaitDrain--;
|
||||
if (state.awaitDrain === 0 && EE.listenerCount(src, 'data')) {
|
||||
state.flowing = true;
|
||||
flow(src);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Readable.prototype.unpipe = function(dest) {
|
||||
var state = this._readableState;
|
||||
|
||||
// if we're not piping anywhere, then do nothing.
|
||||
if (state.pipesCount === 0)
|
||||
return this;
|
||||
|
||||
// just one destination. most common case.
|
||||
if (state.pipesCount === 1) {
|
||||
// passed in one, but it's not the right one.
|
||||
if (dest && dest !== state.pipes)
|
||||
return this;
|
||||
|
||||
if (!dest)
|
||||
dest = state.pipes;
|
||||
|
||||
// got a match.
|
||||
state.pipes = null;
|
||||
state.pipesCount = 0;
|
||||
state.flowing = false;
|
||||
if (dest)
|
||||
dest.emit('unpipe', this);
|
||||
return this;
|
||||
}
|
||||
|
||||
// slow case. multiple pipe destinations.
|
||||
|
||||
if (!dest) {
|
||||
// remove all.
|
||||
var dests = state.pipes;
|
||||
var len = state.pipesCount;
|
||||
state.pipes = null;
|
||||
state.pipesCount = 0;
|
||||
state.flowing = false;
|
||||
|
||||
for (var i = 0; i < len; i++)
|
||||
dests[i].emit('unpipe', this);
|
||||
return this;
|
||||
}
|
||||
|
||||
// try to find the right one.
|
||||
var i = indexOf(state.pipes, dest);
|
||||
if (i === -1)
|
||||
return this;
|
||||
|
||||
state.pipes.splice(i, 1);
|
||||
state.pipesCount -= 1;
|
||||
if (state.pipesCount === 1)
|
||||
state.pipes = state.pipes[0];
|
||||
|
||||
dest.emit('unpipe', this);
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
// set up data events if they are asked for
|
||||
// Ensure readable listeners eventually get something
|
||||
Readable.prototype.on = function(ev, fn) {
|
||||
var res = Stream.prototype.on.call(this, ev, fn);
|
||||
|
||||
// If listening to data, and it has not explicitly been paused,
|
||||
// then call resume to start the flow of data on the next tick.
|
||||
if (ev === 'data' && false !== this._readableState.flowing) {
|
||||
this.resume();
|
||||
}
|
||||
|
||||
if (ev === 'readable' && this.readable) {
|
||||
var state = this._readableState;
|
||||
if (!state.readableListening) {
|
||||
state.readableListening = true;
|
||||
state.emittedReadable = false;
|
||||
state.needReadable = true;
|
||||
if (!state.reading) {
|
||||
var self = this;
|
||||
process.nextTick(function() {
|
||||
debug('readable nexttick read 0');
|
||||
self.read(0);
|
||||
});
|
||||
} else if (state.length) {
|
||||
emitReadable(this, state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
};
|
||||
Readable.prototype.addListener = Readable.prototype.on;
|
||||
|
||||
// pause() and resume() are remnants of the legacy readable stream API
|
||||
// If the user uses them, then switch into old mode.
|
||||
Readable.prototype.resume = function() {
|
||||
var state = this._readableState;
|
||||
if (!state.flowing) {
|
||||
debug('resume');
|
||||
state.flowing = true;
|
||||
if (!state.reading) {
|
||||
debug('resume read 0');
|
||||
this.read(0);
|
||||
}
|
||||
resume(this, state);
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
function resume(stream, state) {
|
||||
if (!state.resumeScheduled) {
|
||||
state.resumeScheduled = true;
|
||||
process.nextTick(function() {
|
||||
resume_(stream, state);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function resume_(stream, state) {
|
||||
state.resumeScheduled = false;
|
||||
stream.emit('resume');
|
||||
flow(stream);
|
||||
if (state.flowing && !state.reading)
|
||||
stream.read(0);
|
||||
}
|
||||
|
||||
Readable.prototype.pause = function() {
|
||||
debug('call pause flowing=%j', this._readableState.flowing);
|
||||
if (false !== this._readableState.flowing) {
|
||||
debug('pause');
|
||||
this._readableState.flowing = false;
|
||||
this.emit('pause');
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
function flow(stream) {
|
||||
var state = stream._readableState;
|
||||
debug('flow', state.flowing);
|
||||
if (state.flowing) {
|
||||
do {
|
||||
var chunk = stream.read();
|
||||
} while (null !== chunk && state.flowing);
|
||||
}
|
||||
}
|
||||
|
||||
// wrap an old-style stream as the async data source.
|
||||
// This is *not* part of the readable stream interface.
|
||||
// It is an ugly unfortunate mess of history.
|
||||
Readable.prototype.wrap = function(stream) {
|
||||
var state = this._readableState;
|
||||
var paused = false;
|
||||
|
||||
var self = this;
|
||||
stream.on('end', function() {
|
||||
debug('wrapped end');
|
||||
if (state.decoder && !state.ended) {
|
||||
var chunk = state.decoder.end();
|
||||
if (chunk && chunk.length)
|
||||
self.push(chunk);
|
||||
}
|
||||
|
||||
self.push(null);
|
||||
});
|
||||
|
||||
stream.on('data', function(chunk) {
|
||||
debug('wrapped data');
|
||||
if (state.decoder)
|
||||
chunk = state.decoder.write(chunk);
|
||||
if (!chunk || !state.objectMode && !chunk.length)
|
||||
return;
|
||||
|
||||
var ret = self.push(chunk);
|
||||
if (!ret) {
|
||||
paused = true;
|
||||
stream.pause();
|
||||
}
|
||||
});
|
||||
|
||||
// proxy all the other methods.
|
||||
// important when wrapping filters and duplexes.
|
||||
for (var i in stream) {
|
||||
if (util.isFunction(stream[i]) && util.isUndefined(this[i])) {
|
||||
this[i] = function(method) { return function() {
|
||||
return stream[method].apply(stream, arguments);
|
||||
}}(i);
|
||||
}
|
||||
}
|
||||
|
||||
// proxy certain important events.
|
||||
var events = ['error', 'close', 'destroy', 'pause', 'resume'];
|
||||
forEach(events, function(ev) {
|
||||
stream.on(ev, self.emit.bind(self, ev));
|
||||
});
|
||||
|
||||
// when we try to consume some more bytes, simply unpause the
|
||||
// underlying stream.
|
||||
self._read = function(n) {
|
||||
debug('wrapped _read', n);
|
||||
if (paused) {
|
||||
paused = false;
|
||||
stream.resume();
|
||||
}
|
||||
};
|
||||
|
||||
return self;
|
||||
};
|
||||
|
||||
|
||||
|
||||
// exposed for testing purposes only.
|
||||
Readable._fromList = fromList;
|
||||
|
||||
// Pluck off n bytes from an array of buffers.
|
||||
// Length is the combined lengths of all the buffers in the list.
|
||||
function fromList(n, state) {
|
||||
var list = state.buffer;
|
||||
var length = state.length;
|
||||
var stringMode = !!state.decoder;
|
||||
var objectMode = !!state.objectMode;
|
||||
var ret;
|
||||
|
||||
// nothing in the list, definitely empty.
|
||||
if (list.length === 0)
|
||||
return null;
|
||||
|
||||
if (length === 0)
|
||||
ret = null;
|
||||
else if (objectMode)
|
||||
ret = list.shift();
|
||||
else if (!n || n >= length) {
|
||||
// read it all, truncate the array.
|
||||
if (stringMode)
|
||||
ret = list.join('');
|
||||
else
|
||||
ret = Buffer.concat(list, length);
|
||||
list.length = 0;
|
||||
} else {
|
||||
// read just some of it.
|
||||
if (n < list[0].length) {
|
||||
// just take a part of the first list item.
|
||||
// slice is the same for buffers and strings.
|
||||
var buf = list[0];
|
||||
ret = buf.slice(0, n);
|
||||
list[0] = buf.slice(n);
|
||||
} else if (n === list[0].length) {
|
||||
// first list is a perfect match
|
||||
ret = list.shift();
|
||||
} else {
|
||||
// complex case.
|
||||
// we have enough to cover it, but it spans past the first buffer.
|
||||
if (stringMode)
|
||||
ret = '';
|
||||
else
|
||||
ret = new Buffer(n);
|
||||
|
||||
var c = 0;
|
||||
for (var i = 0, l = list.length; i < l && c < n; i++) {
|
||||
var buf = list[0];
|
||||
var cpy = Math.min(n - c, buf.length);
|
||||
|
||||
if (stringMode)
|
||||
ret += buf.slice(0, cpy);
|
||||
else
|
||||
buf.copy(ret, c, 0, cpy);
|
||||
|
||||
if (cpy < buf.length)
|
||||
list[0] = buf.slice(cpy);
|
||||
else
|
||||
list.shift();
|
||||
|
||||
c += cpy;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
function endReadable(stream) {
|
||||
var state = stream._readableState;
|
||||
|
||||
// If we get here before consuming all the bytes, then that is a
|
||||
// bug in node. Should never happen.
|
||||
if (state.length > 0)
|
||||
throw new Error('endReadable called on non-empty stream');
|
||||
|
||||
if (!state.endEmitted) {
|
||||
state.ended = true;
|
||||
process.nextTick(function() {
|
||||
// Check that we didn't get one last unshift.
|
||||
if (!state.endEmitted && state.length === 0) {
|
||||
state.endEmitted = true;
|
||||
stream.readable = false;
|
||||
stream.emit('end');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function forEach (xs, f) {
|
||||
for (var i = 0, l = xs.length; i < l; i++) {
|
||||
f(xs[i], i);
|
||||
}
|
||||
}
|
||||
|
||||
function indexOf (xs, x) {
|
||||
for (var i = 0, l = xs.length; i < l; i++) {
|
||||
if (xs[i] === x) return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
209
static/js/ketcher2/node_modules/varstream/node_modules/readable-stream/lib/_stream_transform.js
generated
vendored
Normal file
209
static/js/ketcher2/node_modules/varstream/node_modules/readable-stream/lib/_stream_transform.js
generated
vendored
Normal file
@ -0,0 +1,209 @@
|
||||
// Copyright Joyent, Inc. and other Node contributors.
|
||||
//
|
||||
// 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.
|
||||
|
||||
|
||||
// a transform stream is a readable/writable stream where you do
|
||||
// something with the data. Sometimes it's called a "filter",
|
||||
// but that's not a great name for it, since that implies a thing where
|
||||
// some bits pass through, and others are simply ignored. (That would
|
||||
// be a valid example of a transform, of course.)
|
||||
//
|
||||
// While the output is causally related to the input, it's not a
|
||||
// necessarily symmetric or synchronous transformation. For example,
|
||||
// a zlib stream might take multiple plain-text writes(), and then
|
||||
// emit a single compressed chunk some time in the future.
|
||||
//
|
||||
// Here's how this works:
|
||||
//
|
||||
// The Transform stream has all the aspects of the readable and writable
|
||||
// stream classes. When you write(chunk), that calls _write(chunk,cb)
|
||||
// internally, and returns false if there's a lot of pending writes
|
||||
// buffered up. When you call read(), that calls _read(n) until
|
||||
// there's enough pending readable data buffered up.
|
||||
//
|
||||
// In a transform stream, the written data is placed in a buffer. When
|
||||
// _read(n) is called, it transforms the queued up data, calling the
|
||||
// buffered _write cb's as it consumes chunks. If consuming a single
|
||||
// written chunk would result in multiple output chunks, then the first
|
||||
// outputted bit calls the readcb, and subsequent chunks just go into
|
||||
// the read buffer, and will cause it to emit 'readable' if necessary.
|
||||
//
|
||||
// This way, back-pressure is actually determined by the reading side,
|
||||
// since _read has to be called to start processing a new chunk. However,
|
||||
// a pathological inflate type of transform can cause excessive buffering
|
||||
// here. For example, imagine a stream where every byte of input is
|
||||
// interpreted as an integer from 0-255, and then results in that many
|
||||
// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in
|
||||
// 1kb of data being output. In this case, you could write a very small
|
||||
// amount of input, and end up with a very large amount of output. In
|
||||
// such a pathological inflating mechanism, there'd be no way to tell
|
||||
// the system to stop doing the transform. A single 4MB write could
|
||||
// cause the system to run out of memory.
|
||||
//
|
||||
// However, even in such a pathological case, only a single written chunk
|
||||
// would be consumed, and then the rest would wait (un-transformed) until
|
||||
// the results of the previous transformed chunk were consumed.
|
||||
|
||||
module.exports = Transform;
|
||||
|
||||
var Duplex = require('./_stream_duplex');
|
||||
|
||||
/*<replacement>*/
|
||||
var util = require('core-util-is');
|
||||
util.inherits = require('inherits');
|
||||
/*</replacement>*/
|
||||
|
||||
util.inherits(Transform, Duplex);
|
||||
|
||||
|
||||
function TransformState(options, stream) {
|
||||
this.afterTransform = function(er, data) {
|
||||
return afterTransform(stream, er, data);
|
||||
};
|
||||
|
||||
this.needTransform = false;
|
||||
this.transforming = false;
|
||||
this.writecb = null;
|
||||
this.writechunk = null;
|
||||
}
|
||||
|
||||
function afterTransform(stream, er, data) {
|
||||
var ts = stream._transformState;
|
||||
ts.transforming = false;
|
||||
|
||||
var cb = ts.writecb;
|
||||
|
||||
if (!cb)
|
||||
return stream.emit('error', new Error('no writecb in Transform class'));
|
||||
|
||||
ts.writechunk = null;
|
||||
ts.writecb = null;
|
||||
|
||||
if (!util.isNullOrUndefined(data))
|
||||
stream.push(data);
|
||||
|
||||
if (cb)
|
||||
cb(er);
|
||||
|
||||
var rs = stream._readableState;
|
||||
rs.reading = false;
|
||||
if (rs.needReadable || rs.length < rs.highWaterMark) {
|
||||
stream._read(rs.highWaterMark);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function Transform(options) {
|
||||
if (!(this instanceof Transform))
|
||||
return new Transform(options);
|
||||
|
||||
Duplex.call(this, options);
|
||||
|
||||
this._transformState = new TransformState(options, this);
|
||||
|
||||
// when the writable side finishes, then flush out anything remaining.
|
||||
var stream = this;
|
||||
|
||||
// start out asking for a readable event once data is transformed.
|
||||
this._readableState.needReadable = true;
|
||||
|
||||
// we have implemented the _read method, and done the other things
|
||||
// that Readable wants before the first _read call, so unset the
|
||||
// sync guard flag.
|
||||
this._readableState.sync = false;
|
||||
|
||||
this.once('prefinish', function() {
|
||||
if (util.isFunction(this._flush))
|
||||
this._flush(function(er) {
|
||||
done(stream, er);
|
||||
});
|
||||
else
|
||||
done(stream);
|
||||
});
|
||||
}
|
||||
|
||||
Transform.prototype.push = function(chunk, encoding) {
|
||||
this._transformState.needTransform = false;
|
||||
return Duplex.prototype.push.call(this, chunk, encoding);
|
||||
};
|
||||
|
||||
// This is the part where you do stuff!
|
||||
// override this function in implementation classes.
|
||||
// 'chunk' is an input chunk.
|
||||
//
|
||||
// Call `push(newChunk)` to pass along transformed output
|
||||
// to the readable side. You may call 'push' zero or more times.
|
||||
//
|
||||
// Call `cb(err)` when you are done with this chunk. If you pass
|
||||
// an error, then that'll put the hurt on the whole operation. If you
|
||||
// never call cb(), then you'll never get another chunk.
|
||||
Transform.prototype._transform = function(chunk, encoding, cb) {
|
||||
throw new Error('not implemented');
|
||||
};
|
||||
|
||||
Transform.prototype._write = function(chunk, encoding, cb) {
|
||||
var ts = this._transformState;
|
||||
ts.writecb = cb;
|
||||
ts.writechunk = chunk;
|
||||
ts.writeencoding = encoding;
|
||||
if (!ts.transforming) {
|
||||
var rs = this._readableState;
|
||||
if (ts.needTransform ||
|
||||
rs.needReadable ||
|
||||
rs.length < rs.highWaterMark)
|
||||
this._read(rs.highWaterMark);
|
||||
}
|
||||
};
|
||||
|
||||
// Doesn't matter what the args are here.
|
||||
// _transform does all the work.
|
||||
// That we got here means that the readable side wants more data.
|
||||
Transform.prototype._read = function(n) {
|
||||
var ts = this._transformState;
|
||||
|
||||
if (!util.isNull(ts.writechunk) && ts.writecb && !ts.transforming) {
|
||||
ts.transforming = true;
|
||||
this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
|
||||
} else {
|
||||
// mark that we need a transform, so that any data that comes in
|
||||
// will get processed, now that we've asked for it.
|
||||
ts.needTransform = true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
function done(stream, er) {
|
||||
if (er)
|
||||
return stream.emit('error', er);
|
||||
|
||||
// if there's nothing in the write buffer, then that means
|
||||
// that nothing more will ever be provided
|
||||
var ws = stream._writableState;
|
||||
var ts = stream._transformState;
|
||||
|
||||
if (ws.length)
|
||||
throw new Error('calling transform done when ws.length != 0');
|
||||
|
||||
if (ts.transforming)
|
||||
throw new Error('calling transform done when still transforming');
|
||||
|
||||
return stream.push(null);
|
||||
}
|
||||
477
static/js/ketcher2/node_modules/varstream/node_modules/readable-stream/lib/_stream_writable.js
generated
vendored
Normal file
477
static/js/ketcher2/node_modules/varstream/node_modules/readable-stream/lib/_stream_writable.js
generated
vendored
Normal file
@ -0,0 +1,477 @@
|
||||
// Copyright Joyent, Inc. and other Node contributors.
|
||||
//
|
||||
// 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.
|
||||
|
||||
// A bit simpler than readable streams.
|
||||
// Implement an async ._write(chunk, cb), and it'll handle all
|
||||
// the drain event emission and buffering.
|
||||
|
||||
module.exports = Writable;
|
||||
|
||||
/*<replacement>*/
|
||||
var Buffer = require('buffer').Buffer;
|
||||
/*</replacement>*/
|
||||
|
||||
Writable.WritableState = WritableState;
|
||||
|
||||
|
||||
/*<replacement>*/
|
||||
var util = require('core-util-is');
|
||||
util.inherits = require('inherits');
|
||||
/*</replacement>*/
|
||||
|
||||
var Stream = require('stream');
|
||||
|
||||
util.inherits(Writable, Stream);
|
||||
|
||||
function WriteReq(chunk, encoding, cb) {
|
||||
this.chunk = chunk;
|
||||
this.encoding = encoding;
|
||||
this.callback = cb;
|
||||
}
|
||||
|
||||
function WritableState(options, stream) {
|
||||
var Duplex = require('./_stream_duplex');
|
||||
|
||||
options = options || {};
|
||||
|
||||
// the point at which write() starts returning false
|
||||
// Note: 0 is a valid value, means that we always return false if
|
||||
// the entire buffer is not flushed immediately on write()
|
||||
var hwm = options.highWaterMark;
|
||||
var defaultHwm = options.objectMode ? 16 : 16 * 1024;
|
||||
this.highWaterMark = (hwm || hwm === 0) ? hwm : defaultHwm;
|
||||
|
||||
// object stream flag to indicate whether or not this stream
|
||||
// contains buffers or objects.
|
||||
this.objectMode = !!options.objectMode;
|
||||
|
||||
if (stream instanceof Duplex)
|
||||
this.objectMode = this.objectMode || !!options.writableObjectMode;
|
||||
|
||||
// cast to ints.
|
||||
this.highWaterMark = ~~this.highWaterMark;
|
||||
|
||||
this.needDrain = false;
|
||||
// at the start of calling end()
|
||||
this.ending = false;
|
||||
// when end() has been called, and returned
|
||||
this.ended = false;
|
||||
// when 'finish' is emitted
|
||||
this.finished = false;
|
||||
|
||||
// should we decode strings into buffers before passing to _write?
|
||||
// this is here so that some node-core streams can optimize string
|
||||
// handling at a lower level.
|
||||
var noDecode = options.decodeStrings === false;
|
||||
this.decodeStrings = !noDecode;
|
||||
|
||||
// Crypto is kind of old and crusty. Historically, its default string
|
||||
// encoding is 'binary' so we have to make this configurable.
|
||||
// Everything else in the universe uses 'utf8', though.
|
||||
this.defaultEncoding = options.defaultEncoding || 'utf8';
|
||||
|
||||
// not an actual buffer we keep track of, but a measurement
|
||||
// of how much we're waiting to get pushed to some underlying
|
||||
// socket or file.
|
||||
this.length = 0;
|
||||
|
||||
// a flag to see when we're in the middle of a write.
|
||||
this.writing = false;
|
||||
|
||||
// when true all writes will be buffered until .uncork() call
|
||||
this.corked = 0;
|
||||
|
||||
// a flag to be able to tell if the onwrite cb is called immediately,
|
||||
// or on a later tick. We set this to true at first, because any
|
||||
// actions that shouldn't happen until "later" should generally also
|
||||
// not happen before the first write call.
|
||||
this.sync = true;
|
||||
|
||||
// a flag to know if we're processing previously buffered items, which
|
||||
// may call the _write() callback in the same tick, so that we don't
|
||||
// end up in an overlapped onwrite situation.
|
||||
this.bufferProcessing = false;
|
||||
|
||||
// the callback that's passed to _write(chunk,cb)
|
||||
this.onwrite = function(er) {
|
||||
onwrite(stream, er);
|
||||
};
|
||||
|
||||
// the callback that the user supplies to write(chunk,encoding,cb)
|
||||
this.writecb = null;
|
||||
|
||||
// the amount that is being written when _write is called.
|
||||
this.writelen = 0;
|
||||
|
||||
this.buffer = [];
|
||||
|
||||
// number of pending user-supplied write callbacks
|
||||
// this must be 0 before 'finish' can be emitted
|
||||
this.pendingcb = 0;
|
||||
|
||||
// emit prefinish if the only thing we're waiting for is _write cbs
|
||||
// This is relevant for synchronous Transform streams
|
||||
this.prefinished = false;
|
||||
|
||||
// True if the error was already emitted and should not be thrown again
|
||||
this.errorEmitted = false;
|
||||
}
|
||||
|
||||
function Writable(options) {
|
||||
var Duplex = require('./_stream_duplex');
|
||||
|
||||
// Writable ctor is applied to Duplexes, though they're not
|
||||
// instanceof Writable, they're instanceof Readable.
|
||||
if (!(this instanceof Writable) && !(this instanceof Duplex))
|
||||
return new Writable(options);
|
||||
|
||||
this._writableState = new WritableState(options, this);
|
||||
|
||||
// legacy.
|
||||
this.writable = true;
|
||||
|
||||
Stream.call(this);
|
||||
}
|
||||
|
||||
// Otherwise people can pipe Writable streams, which is just wrong.
|
||||
Writable.prototype.pipe = function() {
|
||||
this.emit('error', new Error('Cannot pipe. Not readable.'));
|
||||
};
|
||||
|
||||
|
||||
function writeAfterEnd(stream, state, cb) {
|
||||
var er = new Error('write after end');
|
||||
// TODO: defer error events consistently everywhere, not just the cb
|
||||
stream.emit('error', er);
|
||||
process.nextTick(function() {
|
||||
cb(er);
|
||||
});
|
||||
}
|
||||
|
||||
// If we get something that is not a buffer, string, null, or undefined,
|
||||
// and we're not in objectMode, then that's an error.
|
||||
// Otherwise stream chunks are all considered to be of length=1, and the
|
||||
// watermarks determine how many objects to keep in the buffer, rather than
|
||||
// how many bytes or characters.
|
||||
function validChunk(stream, state, chunk, cb) {
|
||||
var valid = true;
|
||||
if (!util.isBuffer(chunk) &&
|
||||
!util.isString(chunk) &&
|
||||
!util.isNullOrUndefined(chunk) &&
|
||||
!state.objectMode) {
|
||||
var er = new TypeError('Invalid non-string/buffer chunk');
|
||||
stream.emit('error', er);
|
||||
process.nextTick(function() {
|
||||
cb(er);
|
||||
});
|
||||
valid = false;
|
||||
}
|
||||
return valid;
|
||||
}
|
||||
|
||||
Writable.prototype.write = function(chunk, encoding, cb) {
|
||||
var state = this._writableState;
|
||||
var ret = false;
|
||||
|
||||
if (util.isFunction(encoding)) {
|
||||
cb = encoding;
|
||||
encoding = null;
|
||||
}
|
||||
|
||||
if (util.isBuffer(chunk))
|
||||
encoding = 'buffer';
|
||||
else if (!encoding)
|
||||
encoding = state.defaultEncoding;
|
||||
|
||||
if (!util.isFunction(cb))
|
||||
cb = function() {};
|
||||
|
||||
if (state.ended)
|
||||
writeAfterEnd(this, state, cb);
|
||||
else if (validChunk(this, state, chunk, cb)) {
|
||||
state.pendingcb++;
|
||||
ret = writeOrBuffer(this, state, chunk, encoding, cb);
|
||||
}
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
Writable.prototype.cork = function() {
|
||||
var state = this._writableState;
|
||||
|
||||
state.corked++;
|
||||
};
|
||||
|
||||
Writable.prototype.uncork = function() {
|
||||
var state = this._writableState;
|
||||
|
||||
if (state.corked) {
|
||||
state.corked--;
|
||||
|
||||
if (!state.writing &&
|
||||
!state.corked &&
|
||||
!state.finished &&
|
||||
!state.bufferProcessing &&
|
||||
state.buffer.length)
|
||||
clearBuffer(this, state);
|
||||
}
|
||||
};
|
||||
|
||||
function decodeChunk(state, chunk, encoding) {
|
||||
if (!state.objectMode &&
|
||||
state.decodeStrings !== false &&
|
||||
util.isString(chunk)) {
|
||||
chunk = new Buffer(chunk, encoding);
|
||||
}
|
||||
return chunk;
|
||||
}
|
||||
|
||||
// if we're already writing something, then just put this
|
||||
// in the queue, and wait our turn. Otherwise, call _write
|
||||
// If we return false, then we need a drain event, so set that flag.
|
||||
function writeOrBuffer(stream, state, chunk, encoding, cb) {
|
||||
chunk = decodeChunk(state, chunk, encoding);
|
||||
if (util.isBuffer(chunk))
|
||||
encoding = 'buffer';
|
||||
var len = state.objectMode ? 1 : chunk.length;
|
||||
|
||||
state.length += len;
|
||||
|
||||
var ret = state.length < state.highWaterMark;
|
||||
// we must ensure that previous needDrain will not be reset to false.
|
||||
if (!ret)
|
||||
state.needDrain = true;
|
||||
|
||||
if (state.writing || state.corked)
|
||||
state.buffer.push(new WriteReq(chunk, encoding, cb));
|
||||
else
|
||||
doWrite(stream, state, false, len, chunk, encoding, cb);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
function doWrite(stream, state, writev, len, chunk, encoding, cb) {
|
||||
state.writelen = len;
|
||||
state.writecb = cb;
|
||||
state.writing = true;
|
||||
state.sync = true;
|
||||
if (writev)
|
||||
stream._writev(chunk, state.onwrite);
|
||||
else
|
||||
stream._write(chunk, encoding, state.onwrite);
|
||||
state.sync = false;
|
||||
}
|
||||
|
||||
function onwriteError(stream, state, sync, er, cb) {
|
||||
if (sync)
|
||||
process.nextTick(function() {
|
||||
state.pendingcb--;
|
||||
cb(er);
|
||||
});
|
||||
else {
|
||||
state.pendingcb--;
|
||||
cb(er);
|
||||
}
|
||||
|
||||
stream._writableState.errorEmitted = true;
|
||||
stream.emit('error', er);
|
||||
}
|
||||
|
||||
function onwriteStateUpdate(state) {
|
||||
state.writing = false;
|
||||
state.writecb = null;
|
||||
state.length -= state.writelen;
|
||||
state.writelen = 0;
|
||||
}
|
||||
|
||||
function onwrite(stream, er) {
|
||||
var state = stream._writableState;
|
||||
var sync = state.sync;
|
||||
var cb = state.writecb;
|
||||
|
||||
onwriteStateUpdate(state);
|
||||
|
||||
if (er)
|
||||
onwriteError(stream, state, sync, er, cb);
|
||||
else {
|
||||
// Check if we're actually ready to finish, but don't emit yet
|
||||
var finished = needFinish(stream, state);
|
||||
|
||||
if (!finished &&
|
||||
!state.corked &&
|
||||
!state.bufferProcessing &&
|
||||
state.buffer.length) {
|
||||
clearBuffer(stream, state);
|
||||
}
|
||||
|
||||
if (sync) {
|
||||
process.nextTick(function() {
|
||||
afterWrite(stream, state, finished, cb);
|
||||
});
|
||||
} else {
|
||||
afterWrite(stream, state, finished, cb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function afterWrite(stream, state, finished, cb) {
|
||||
if (!finished)
|
||||
onwriteDrain(stream, state);
|
||||
state.pendingcb--;
|
||||
cb();
|
||||
finishMaybe(stream, state);
|
||||
}
|
||||
|
||||
// Must force callback to be called on nextTick, so that we don't
|
||||
// emit 'drain' before the write() consumer gets the 'false' return
|
||||
// value, and has a chance to attach a 'drain' listener.
|
||||
function onwriteDrain(stream, state) {
|
||||
if (state.length === 0 && state.needDrain) {
|
||||
state.needDrain = false;
|
||||
stream.emit('drain');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// if there's something in the buffer waiting, then process it
|
||||
function clearBuffer(stream, state) {
|
||||
state.bufferProcessing = true;
|
||||
|
||||
if (stream._writev && state.buffer.length > 1) {
|
||||
// Fast case, write everything using _writev()
|
||||
var cbs = [];
|
||||
for (var c = 0; c < state.buffer.length; c++)
|
||||
cbs.push(state.buffer[c].callback);
|
||||
|
||||
// count the one we are adding, as well.
|
||||
// TODO(isaacs) clean this up
|
||||
state.pendingcb++;
|
||||
doWrite(stream, state, true, state.length, state.buffer, '', function(err) {
|
||||
for (var i = 0; i < cbs.length; i++) {
|
||||
state.pendingcb--;
|
||||
cbs[i](err);
|
||||
}
|
||||
});
|
||||
|
||||
// Clear buffer
|
||||
state.buffer = [];
|
||||
} else {
|
||||
// Slow case, write chunks one-by-one
|
||||
for (var c = 0; c < state.buffer.length; c++) {
|
||||
var entry = state.buffer[c];
|
||||
var chunk = entry.chunk;
|
||||
var encoding = entry.encoding;
|
||||
var cb = entry.callback;
|
||||
var len = state.objectMode ? 1 : chunk.length;
|
||||
|
||||
doWrite(stream, state, false, len, chunk, encoding, cb);
|
||||
|
||||
// if we didn't call the onwrite immediately, then
|
||||
// it means that we need to wait until it does.
|
||||
// also, that means that the chunk and cb are currently
|
||||
// being processed, so move the buffer counter past them.
|
||||
if (state.writing) {
|
||||
c++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (c < state.buffer.length)
|
||||
state.buffer = state.buffer.slice(c);
|
||||
else
|
||||
state.buffer.length = 0;
|
||||
}
|
||||
|
||||
state.bufferProcessing = false;
|
||||
}
|
||||
|
||||
Writable.prototype._write = function(chunk, encoding, cb) {
|
||||
cb(new Error('not implemented'));
|
||||
|
||||
};
|
||||
|
||||
Writable.prototype._writev = null;
|
||||
|
||||
Writable.prototype.end = function(chunk, encoding, cb) {
|
||||
var state = this._writableState;
|
||||
|
||||
if (util.isFunction(chunk)) {
|
||||
cb = chunk;
|
||||
chunk = null;
|
||||
encoding = null;
|
||||
} else if (util.isFunction(encoding)) {
|
||||
cb = encoding;
|
||||
encoding = null;
|
||||
}
|
||||
|
||||
if (!util.isNullOrUndefined(chunk))
|
||||
this.write(chunk, encoding);
|
||||
|
||||
// .end() fully uncorks
|
||||
if (state.corked) {
|
||||
state.corked = 1;
|
||||
this.uncork();
|
||||
}
|
||||
|
||||
// ignore unnecessary end() calls.
|
||||
if (!state.ending && !state.finished)
|
||||
endWritable(this, state, cb);
|
||||
};
|
||||
|
||||
|
||||
function needFinish(stream, state) {
|
||||
return (state.ending &&
|
||||
state.length === 0 &&
|
||||
!state.finished &&
|
||||
!state.writing);
|
||||
}
|
||||
|
||||
function prefinish(stream, state) {
|
||||
if (!state.prefinished) {
|
||||
state.prefinished = true;
|
||||
stream.emit('prefinish');
|
||||
}
|
||||
}
|
||||
|
||||
function finishMaybe(stream, state) {
|
||||
var need = needFinish(stream, state);
|
||||
if (need) {
|
||||
if (state.pendingcb === 0) {
|
||||
prefinish(stream, state);
|
||||
state.finished = true;
|
||||
stream.emit('finish');
|
||||
} else
|
||||
prefinish(stream, state);
|
||||
}
|
||||
return need;
|
||||
}
|
||||
|
||||
function endWritable(stream, state, cb) {
|
||||
state.ending = true;
|
||||
finishMaybe(stream, state);
|
||||
if (cb) {
|
||||
if (state.finished)
|
||||
process.nextTick(cb);
|
||||
else
|
||||
stream.once('finish', cb);
|
||||
}
|
||||
state.ended = true;
|
||||
}
|
||||
65
static/js/ketcher2/node_modules/varstream/node_modules/readable-stream/package.json
generated
vendored
Normal file
65
static/js/ketcher2/node_modules/varstream/node_modules/readable-stream/package.json
generated
vendored
Normal file
@ -0,0 +1,65 @@
|
||||
{
|
||||
"_from": "readable-stream@^1.0.33",
|
||||
"_id": "readable-stream@1.1.14",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=",
|
||||
"_location": "/varstream/readable-stream",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "readable-stream@^1.0.33",
|
||||
"name": "readable-stream",
|
||||
"escapedName": "readable-stream",
|
||||
"rawSpec": "^1.0.33",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^1.0.33"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/varstream"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz",
|
||||
"_shasum": "7cf4c54ef648e3813084c636dd2079e166c081d9",
|
||||
"_spec": "readable-stream@^1.0.33",
|
||||
"_where": "/home/manfred/enviPath/ketcher2/ketcher/node_modules/varstream",
|
||||
"author": {
|
||||
"name": "Isaac Z. Schlueter",
|
||||
"email": "i@izs.me",
|
||||
"url": "http://blog.izs.me/"
|
||||
},
|
||||
"browser": {
|
||||
"util": false
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/isaacs/readable-stream/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"core-util-is": "~1.0.0",
|
||||
"inherits": "~2.0.1",
|
||||
"isarray": "0.0.1",
|
||||
"string_decoder": "~0.10.x"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Streams3, a user-land copy of the stream library from Node.js v0.11.x",
|
||||
"devDependencies": {
|
||||
"tap": "~0.2.6"
|
||||
},
|
||||
"homepage": "https://github.com/isaacs/readable-stream#readme",
|
||||
"keywords": [
|
||||
"readable",
|
||||
"stream",
|
||||
"pipe"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "readable.js",
|
||||
"name": "readable-stream",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/isaacs/readable-stream.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "tap test/simple/*.js"
|
||||
},
|
||||
"version": "1.1.14"
|
||||
}
|
||||
1
static/js/ketcher2/node_modules/varstream/node_modules/readable-stream/passthrough.js
generated
vendored
Normal file
1
static/js/ketcher2/node_modules/varstream/node_modules/readable-stream/passthrough.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
module.exports = require("./lib/_stream_passthrough.js")
|
||||
10
static/js/ketcher2/node_modules/varstream/node_modules/readable-stream/readable.js
generated
vendored
Normal file
10
static/js/ketcher2/node_modules/varstream/node_modules/readable-stream/readable.js
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
exports = module.exports = require('./lib/_stream_readable.js');
|
||||
exports.Stream = require('stream');
|
||||
exports.Readable = exports;
|
||||
exports.Writable = require('./lib/_stream_writable.js');
|
||||
exports.Duplex = require('./lib/_stream_duplex.js');
|
||||
exports.Transform = require('./lib/_stream_transform.js');
|
||||
exports.PassThrough = require('./lib/_stream_passthrough.js');
|
||||
if (!process.browser && process.env.READABLE_STREAM === 'disable') {
|
||||
module.exports = require('stream');
|
||||
}
|
||||
1
static/js/ketcher2/node_modules/varstream/node_modules/readable-stream/transform.js
generated
vendored
Normal file
1
static/js/ketcher2/node_modules/varstream/node_modules/readable-stream/transform.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
module.exports = require("./lib/_stream_transform.js")
|
||||
1
static/js/ketcher2/node_modules/varstream/node_modules/readable-stream/writable.js
generated
vendored
Normal file
1
static/js/ketcher2/node_modules/varstream/node_modules/readable-stream/writable.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
module.exports = require("./lib/_stream_writable.js")
|
||||
81
static/js/ketcher2/node_modules/varstream/package.json
generated
vendored
Normal file
81
static/js/ketcher2/node_modules/varstream/package.json
generated
vendored
Normal file
@ -0,0 +1,81 @@
|
||||
{
|
||||
"_from": "varstream@^0.3.2",
|
||||
"_id": "varstream@0.3.2",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-GKxklHZfP/GjWtmkvgU77BiKXeE=",
|
||||
"_location": "/varstream",
|
||||
"_phantomChildren": {
|
||||
"core-util-is": "1.0.2",
|
||||
"inherits": "2.0.3",
|
||||
"string_decoder": "0.10.31"
|
||||
},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "varstream@^0.3.2",
|
||||
"name": "varstream",
|
||||
"escapedName": "varstream",
|
||||
"rawSpec": "^0.3.2",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^0.3.2"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/neatequal"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/varstream/-/varstream-0.3.2.tgz",
|
||||
"_shasum": "18ac6494765f3ff1a35ad9a4be053bec188a5de1",
|
||||
"_spec": "varstream@^0.3.2",
|
||||
"_where": "/home/manfred/enviPath/ketcher2/ketcher/node_modules/neatequal",
|
||||
"author": {
|
||||
"name": "Nicolas Froidure"
|
||||
},
|
||||
"bin": {
|
||||
"varstream2json": "cli/varstream2json.js",
|
||||
"json2varstream": "cli/json2varstream.js"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/nfroidure/VarStream/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"readable-stream": "^1.0.33"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Stream variables beetween 2 JavaScript threads (client/server, ipc, worker/main thread).",
|
||||
"devDependencies": {
|
||||
"coveralls": "~2.11.2",
|
||||
"istanbul": "~0.3.5",
|
||||
"mocha": "~2.1.0",
|
||||
"mocha-lcov-reporter": "0.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.*"
|
||||
},
|
||||
"homepage": "https://github.com/nfroidure/VarStream#readme",
|
||||
"keywords": [
|
||||
"variable",
|
||||
"file",
|
||||
"stream",
|
||||
"json",
|
||||
"ipc",
|
||||
"pipe",
|
||||
"format",
|
||||
"read",
|
||||
"write",
|
||||
"localization",
|
||||
"configuration"
|
||||
],
|
||||
"main": "./src/VarStream",
|
||||
"name": "varstream",
|
||||
"preferGlobal": "true",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+ssh://git@github.com/nfroidure/VarStream.git"
|
||||
},
|
||||
"scripts": {
|
||||
"cover": "./node_modules/istanbul/lib/cli.js cover --report html ./node_modules/mocha/bin/_mocha -- tests/*.mocha.js -R spec -t 5000",
|
||||
"coveralls": "./node_modules/istanbul/lib/cli.js cover ./node_modules/mocha/bin/_mocha --report lcovonly -- tests/*.mocha.js -R spec -t 5000 && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage",
|
||||
"test": "node_modules/mocha/bin/mocha tests/*.mocha.js"
|
||||
},
|
||||
"version": "0.3.2"
|
||||
}
|
||||
87
static/js/ketcher2/node_modules/varstream/src/VarStream.js
generated
vendored
Executable file
87
static/js/ketcher2/node_modules/varstream/src/VarStream.js
generated
vendored
Executable file
@ -0,0 +1,87 @@
|
||||
'use strict';
|
||||
/*
|
||||
* Copyright (C) 2012 Nicolas Froidure
|
||||
*
|
||||
* This file is free software;
|
||||
* you can redistribute it and/or modify it under the terms of the GNU
|
||||
* General Public License (GPL) as published by the Free Software
|
||||
* Foundation, in version 3. It is distributed in the
|
||||
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
||||
*
|
||||
*/
|
||||
var DuplexStream = require('readable-stream').Duplex
|
||||
, util = require('util')
|
||||
, VarStreamReader = require('./VarStreamReader')
|
||||
, VarStreamWriter = require('./VarStreamWriter')
|
||||
;
|
||||
|
||||
// Inherit of duplex stream
|
||||
util.inherits(VarStream, DuplexStream);
|
||||
|
||||
// Constructor
|
||||
function VarStream(rootObject, rootProperty, options) {
|
||||
var self = this;
|
||||
|
||||
// Ensure new were used
|
||||
if(!(this instanceof VarStream)) {
|
||||
return new VarStream(rootObject, rootProperty, options);
|
||||
}
|
||||
|
||||
// Ensure we had root object and property
|
||||
if(!(rootObject instanceof Object)) {
|
||||
throw new Error('No root object provided.');
|
||||
}
|
||||
if('string' !== typeof rootProperty || rootProperty == '') {
|
||||
throw new Error('No root property name given.');
|
||||
}
|
||||
|
||||
// Parent constructor
|
||||
DuplexStream.call(this);
|
||||
|
||||
this._varstreamReader=new VarStreamReader(rootObject, rootProperty,
|
||||
options ? options&VarStreamReader.OPTIONS : 0);
|
||||
|
||||
this._varstreamWriter = new VarStreamWriter(function(str) {
|
||||
self.push(new Buffer(str, 'utf8'));
|
||||
}, options ? options&VarStreamWriter.OPTIONS : 0);
|
||||
|
||||
// Parse input
|
||||
this._write = function _write(chunk, encoding, done) {
|
||||
this._varstreamReader.read(chunk.toString(
|
||||
encoding !== 'buffer' ? encoding : 'utf8'
|
||||
));
|
||||
done();
|
||||
};
|
||||
|
||||
// Output data
|
||||
this._read = function _read() {
|
||||
this._varstreamWriter.write(rootObject[rootProperty]);
|
||||
this.push(null);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
// Parse helper
|
||||
VarStream.parse = function(content) {
|
||||
var root = {};
|
||||
var stream = new VarStream(root, 'prop');
|
||||
stream.write(Buffer(content));
|
||||
stream.end();
|
||||
return root.prop || {};
|
||||
};
|
||||
|
||||
// Export helper
|
||||
VarStream.stringify = function(obj) {
|
||||
var root = {prop: obj}, stream, content;
|
||||
if('object' !== typeof obj) {
|
||||
throw new Error('The stringified object must be an instance of Object.');
|
||||
}
|
||||
stream = new VarStream(root, 'prop');
|
||||
content = stream.read();
|
||||
return String(content);
|
||||
};
|
||||
|
||||
// Exporting
|
||||
VarStream.VarStreamReader = VarStream.Reader = VarStreamReader;
|
||||
VarStream.VarStreamWriter = VarStream.Writer = VarStreamWriter;
|
||||
module.exports = VarStream;
|
||||
438
static/js/ketcher2/node_modules/varstream/src/VarStreamReader.js
generated
vendored
Executable file
438
static/js/ketcher2/node_modules/varstream/src/VarStreamReader.js
generated
vendored
Executable file
@ -0,0 +1,438 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2013 Nicolas Froidure
|
||||
*
|
||||
* This file is free software;
|
||||
* you can redistribute it and/or modify it under the terms of the GNU
|
||||
* General Public License (GPL) as published by the Free Software
|
||||
* Foundation, in version 3. It is distributed in the
|
||||
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
||||
*
|
||||
*/
|
||||
|
||||
// AMD + global + NodeJS : You can use this object by inserting a script
|
||||
// or using an AMD loader (like RequireJS) or using NodeJS
|
||||
(function(root,define){ define([], function() {
|
||||
'use strict';
|
||||
// START: Module logic start
|
||||
|
||||
// Constructor
|
||||
function VarStreamReader (scope, prop, options) {
|
||||
// Keep a ref to the root scope
|
||||
this.rootScope={root: scope, prop: prop};
|
||||
// Save the options
|
||||
this.options=options;
|
||||
// Store current scopes for backward references
|
||||
this.previousNodes=[];
|
||||
// The parse state
|
||||
this.state=PARSE_NEWLINE;
|
||||
// The current values
|
||||
this.leftValue='';
|
||||
this.rightValue='';
|
||||
this.operator='';
|
||||
this.escaped=ESC_NONE;
|
||||
}
|
||||
|
||||
// Static consts
|
||||
VarStreamReader.STRICT_MODE=1;
|
||||
VarStreamReader.OPTIONS=VarStreamReader.STRICT_MODE;
|
||||
|
||||
// Constants
|
||||
// Chars
|
||||
var CHR_ENDL = '\n'
|
||||
, CHR_CR = '\r'
|
||||
, CHR_SEP = '.'
|
||||
, CHR_BCK = '^'
|
||||
, CHR_EQ = '='
|
||||
, CHR_ESC = '\\'
|
||||
, CHR_PLU = '+'
|
||||
, CHR_MIN = '-'
|
||||
, CHR_MUL = '*'
|
||||
, CHR_DIV = '/'
|
||||
, CHR_MOD = '%'
|
||||
, CHR_REF = '&'
|
||||
, CHR_NEW = '!'
|
||||
, CHR_COM = '#'
|
||||
// Chars sets
|
||||
, EQ_OPS = [CHR_PLU,CHR_MIN,CHR_MUL,CHR_DIV,CHR_MOD,CHR_REF]
|
||||
, ARRAY_OPS = [CHR_PLU,CHR_MUL,CHR_NEW]
|
||||
, ARRAY_NODE_CHARS = /^[0-9]+$/
|
||||
, PROP_NODE_CHARS = /^[a-zA-Z0-9_]+$/
|
||||
, BCK_CHARS = /^\^[0-9]*$/
|
||||
// Parsing status
|
||||
, PARSE_NEWLINE = 1
|
||||
, PARSE_LVAL = 2
|
||||
, PARSE_OPERATOR = 3
|
||||
, PARSE_RVAL = 4
|
||||
, PARSE_MLSTRING = 5
|
||||
, PARSE_COMMENT = 6
|
||||
, PARSE_SILENT = 7
|
||||
// Escape status
|
||||
, ESC_NONE = 0
|
||||
, ESC_LF = 1
|
||||
, ESC_ALL = 3
|
||||
;
|
||||
|
||||
VarStreamReader.prototype.resolveScope = function (val) {
|
||||
var nodes = val.split(CHR_SEP)
|
||||
, scope = this.rootScope
|
||||
, n = 0
|
||||
;
|
||||
|
||||
// Looking for backward refs in the first node
|
||||
if(nodes[0] && nodes[0][0] == CHR_BCK) {
|
||||
// if no numbers adding every previous nodes
|
||||
if(nodes[0] == CHR_BCK) {
|
||||
n = this.previousNodes.length ? this.previousNodes.length - 1 : 0;
|
||||
// if numbers
|
||||
} else {
|
||||
// check it
|
||||
if(!BCK_CHARS.test(nodes[0])) {
|
||||
if(this.options&VarStreamReader.STRICT_MODE) {
|
||||
throw new Error('Malformed backward reference.');
|
||||
}
|
||||
return null;
|
||||
}
|
||||
n = parseInt(nodes[0].substring(1), 10);
|
||||
}
|
||||
if(n > this.previousNodes.length) {
|
||||
if(this.options&VarStreamReader.STRICT_MODE) {
|
||||
throw new SyntaxError('Backward reference index is greater than the'
|
||||
+ ' previous node max index.');
|
||||
}
|
||||
return null;
|
||||
}
|
||||
this.previousNodes.length = n;
|
||||
nodes.shift();
|
||||
nodes.unshift.apply(nodes,this.previousNodes);
|
||||
}
|
||||
|
||||
// Looping throught each nodes
|
||||
for(var i=0, j=nodes.length; i<j; i++) {
|
||||
// Checking if the node is not empty
|
||||
if(''===nodes[i]) {
|
||||
if(this.options&VarStreamReader.STRICT_MODE) {
|
||||
throw new Error('The leftValue can\'t have empty nodes ('+val+').');
|
||||
}
|
||||
return null;
|
||||
}
|
||||
// Array operators
|
||||
if(-1!==ARRAY_OPS.indexOf(nodes[i])||ARRAY_NODE_CHARS.test(nodes[i])) {
|
||||
// Ensure the scope is an array
|
||||
if('undefined'=== typeof scope.root[scope.prop]
|
||||
||!(scope.root[scope.prop] instanceof Array)) {
|
||||
scope.root[scope.prop]=[];
|
||||
}
|
||||
if(nodes[i]===CHR_PLU) {
|
||||
nodes[i]=scope.root[scope.prop].length;
|
||||
}
|
||||
if(nodes[i]===CHR_MUL) {
|
||||
nodes[i]=scope.root[scope.prop].length-1;
|
||||
}
|
||||
if(nodes[i]===CHR_NEW) {
|
||||
nodes[i]=scope.root[scope.prop].length=0;
|
||||
}
|
||||
} else {
|
||||
// Checking node chars
|
||||
if(!PROP_NODE_CHARS.test(nodes[i])) {
|
||||
if(this.options&VarStreamReader.STRICT_MODE) {
|
||||
throw new SyntaxError('Illegal chars found in a the node'
|
||||
+ ' "'+nodes[i]+'".');
|
||||
}
|
||||
return null;
|
||||
}
|
||||
// Ensure the scope is an object
|
||||
if('undefined'=== typeof scope.root[scope.prop]
|
||||
||!(scope.root[scope.prop] instanceof Object)) {
|
||||
scope.root[scope.prop]={};
|
||||
}
|
||||
}
|
||||
// Resolving the node scope
|
||||
scope={
|
||||
root : scope.root[scope.prop],
|
||||
prop : nodes[i]
|
||||
};
|
||||
}
|
||||
|
||||
// Keep previous nodes for backwards references
|
||||
this.previousNodes = nodes;
|
||||
|
||||
return scope;
|
||||
};
|
||||
|
||||
VarStreamReader.prototype.read = function (chunk) {
|
||||
// Looping throught chunk chars
|
||||
for(var i=0, j=chunk.length; i<j; i++) {
|
||||
// detect escaped chars
|
||||
if(chunk[i]===CHR_ESC && (
|
||||
this.state===PARSE_RVAL
|
||||
||this.state===PARSE_SILENT
|
||||
||this.state===PARSE_MLSTRING
|
||||
)
|
||||
) {
|
||||
if(this.escaped) {
|
||||
this.escaped=ESC_NONE;
|
||||
} else {
|
||||
this.escaped=ESC_ALL;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
// parsing chars according to the current state
|
||||
switch(this.state) {
|
||||
// Continue while newlines
|
||||
case PARSE_NEWLINE:
|
||||
this.escaped=ESC_NONE;
|
||||
this.operator='';
|
||||
this.leftValue='';
|
||||
this.rightValue='';
|
||||
if(chunk[i]===CHR_ENDL||chunk[i]===CHR_CR) {
|
||||
continue;
|
||||
}
|
||||
// Read left value content
|
||||
case PARSE_LVAL:
|
||||
// Detect comments
|
||||
if(chunk[i]===CHR_COM) {
|
||||
this.state=PARSE_COMMENT;
|
||||
continue;
|
||||
}
|
||||
// Detect special operators
|
||||
if(this.leftValue.lastIndexOf(CHR_SEP)!=this.leftValue.length-1
|
||||
&&-1!==EQ_OPS.indexOf(chunk[i])) {
|
||||
this.state=PARSE_OPERATOR;
|
||||
this.operator=chunk[i];
|
||||
continue;
|
||||
}
|
||||
// Detect the = operator
|
||||
if(CHR_EQ===chunk[i]) {
|
||||
this.state=PARSE_RVAL;
|
||||
this.operator=chunk[i];
|
||||
continue;
|
||||
}
|
||||
// Fail if a new line is found
|
||||
if(chunk[i]===CHR_ENDL||chunk[i]===CHR_CR) {
|
||||
if(this.options&VarStreamReader.STRICT_MODE) {
|
||||
throw SyntaxError('Unexpected new line found while parsing '
|
||||
+' a leftValue.');
|
||||
}
|
||||
this.state=PARSE_NEWLINE;
|
||||
continue;
|
||||
}
|
||||
// Store LVAL chars
|
||||
this.state=PARSE_LVAL;
|
||||
this.leftValue+=chunk[i];
|
||||
continue;
|
||||
// Read right value content
|
||||
case PARSE_RVAL:
|
||||
// Left value should not be empty
|
||||
if(''===this.leftValue) {
|
||||
if(this.options&VarStreamReader.STRICT_MODE) {
|
||||
throw SyntaxError('Found an empty leftValue.');
|
||||
}
|
||||
this.state=PARSE_SILENT;
|
||||
}
|
||||
// Stop if a new line is found
|
||||
if(chunk[i]===CHR_ENDL||chunk[i]===CHR_CR) {
|
||||
// rightValue can be empty only with the = operator
|
||||
// or if the string is multiline
|
||||
if(this.operator!=CHR_EQ&&''===this.rightValue
|
||||
&&this.escaped===ESC_NONE) {
|
||||
if(this.options&VarStreamReader.STRICT_MODE) {
|
||||
throw SyntaxError('Found an empty rightValue.');
|
||||
}
|
||||
this.state=PARSE_NEWLINE;
|
||||
continue;
|
||||
}
|
||||
// Compute rval
|
||||
// if it's a ref
|
||||
if(this.operator===CHR_REF) {
|
||||
this.rightValue=this.resolveScope(this.rightValue);
|
||||
} else if('null'===this.rightValue) {
|
||||
this.rightValue=null;
|
||||
// Booleans
|
||||
} else if('true'===this.rightValue) {
|
||||
this.rightValue=true;
|
||||
} else if('false'===this.rightValue) {
|
||||
this.rightValue=false;
|
||||
// Numbers
|
||||
} else if('NaN'===this.rightValue) {
|
||||
this.rightValue=NaN;
|
||||
} else if(/^\-?([0-9]+(\.[0-9]+)?|Infinity)$/
|
||||
.test(this.rightValue)) {
|
||||
this.rightValue=Number(this.rightValue);
|
||||
}
|
||||
// Compute lval
|
||||
this.leftValue=this.resolveScope(this.leftValue);
|
||||
// set rval in lval (with operators)
|
||||
if(null!==this.leftValue) {
|
||||
switch(this.operator) {
|
||||
case CHR_REF:
|
||||
this.leftValue.root[this.leftValue.prop] = this.rightValue ?
|
||||
this.rightValue.root[this.rightValue.prop] :
|
||||
null;
|
||||
break;
|
||||
case CHR_EQ:
|
||||
if(this.rightValue!=='' || 'string' ===
|
||||
typeof this.leftValue.root[this.leftValue.prop]) {
|
||||
this.leftValue.root[this.leftValue.prop]=this.rightValue;
|
||||
} else {
|
||||
delete this.leftValue.root[this.leftValue.prop];
|
||||
}
|
||||
break;
|
||||
case CHR_PLU:
|
||||
this.leftValue.root[this.leftValue.prop] +=
|
||||
null === this.rightValue ? NaN : this.rightValue;
|
||||
break;
|
||||
case CHR_MIN:
|
||||
this.leftValue.root[this.leftValue.prop] -=
|
||||
null === this.rightValue ? NaN : this.rightValue;
|
||||
break;
|
||||
case CHR_MUL:
|
||||
this.leftValue.root[this.leftValue.prop] *=
|
||||
null === this.rightValue ? NaN : this.rightValue;
|
||||
break;
|
||||
case CHR_DIV:
|
||||
this.leftValue.root[this.leftValue.prop] /=
|
||||
null === this.rightValue ? NaN : this.rightValue;
|
||||
break;
|
||||
case CHR_MOD:
|
||||
this.leftValue.root[this.leftValue.prop] %=
|
||||
null === this.rightValue ? NaN : this.rightValue;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// if the newline was escaped, continue to read the string
|
||||
if(this.escaped) {
|
||||
if(chunk[i]===CHR_CR) {
|
||||
this.escaped=ESC_LF;
|
||||
} else {
|
||||
this.escaped=ESC_NONE;
|
||||
}
|
||||
if(null!==this.leftValue) {
|
||||
this.state=PARSE_MLSTRING;
|
||||
this.leftValue.root[this.leftValue.prop]+=chunk[i];
|
||||
} else {
|
||||
this.state=PARSE_SILENT;
|
||||
}
|
||||
} else {
|
||||
this.state=PARSE_NEWLINE;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
// Store RVAL chars
|
||||
if(this.escaped) {
|
||||
if(this.escaped==ESC_ALL) {
|
||||
if(this.options&VarStreamReader.STRICT_MODE) {
|
||||
throw Error('Found an escape char but there was nothing to escape.');
|
||||
}
|
||||
this.rightValue+='\\';
|
||||
}
|
||||
this.escaped=ESC_NONE;
|
||||
}
|
||||
this.rightValue+=chunk[i];
|
||||
continue;
|
||||
// Parse the content of a multiline value
|
||||
case PARSE_MLSTRING:
|
||||
if(this.escaped) {
|
||||
if(this.escaped===ESC_ALL&&chunk[i]===CHR_CR) {
|
||||
this.escaped=ESC_LF;
|
||||
} else if(chunk[i]===CHR_ENDL) {
|
||||
this.escaped=ESC_NONE;
|
||||
} else {
|
||||
if(this.escaped===ESC_LF) {
|
||||
if(this.options&VarStreamReader.STRICT_MODE) {
|
||||
throw new SyntaxError('Assuming a LF after an escaped CR, '
|
||||
+chunk[i]+' found instead.');
|
||||
}
|
||||
} else {
|
||||
if(this.options&VarStreamReader.STRICT_MODE) {
|
||||
throw new SyntaxError('Found an escape char but there was'
|
||||
+ ' nothing to escape.');
|
||||
}
|
||||
this.leftValue.root[this.leftValue.prop]+='\\';
|
||||
}
|
||||
this.escaped=ESC_NONE;
|
||||
}
|
||||
} else if(chunk[i]===CHR_ENDL||chunk[i]===CHR_CR) {
|
||||
this.state=PARSE_NEWLINE;
|
||||
continue;
|
||||
}
|
||||
// Store RVAL chars
|
||||
this.leftValue.root[this.leftValue.prop]+=chunk[i];
|
||||
continue;
|
||||
// Finding the = char after an operator
|
||||
case PARSE_OPERATOR:
|
||||
if(chunk[i]===CHR_EQ) {
|
||||
this.state=PARSE_RVAL;
|
||||
continue;
|
||||
}
|
||||
if(this.options&VarStreamReader.STRICT_MODE) {
|
||||
throw new SyntaxError('Unexpected char after the'
|
||||
+ ' "'+this.operator+'" operator. Expected "="'
|
||||
+ ' found "'+chunk[i]+'".');
|
||||
}
|
||||
if(chunk[i]===CHR_ENDL || chunk[i]===CHR_CR) {
|
||||
this.state=PARSE_NEWLINE;
|
||||
} else {
|
||||
this.state=PARSE_SILENT;
|
||||
}
|
||||
continue;
|
||||
// Parsing a comment content
|
||||
case PARSE_COMMENT:
|
||||
if((chunk[i]===CHR_ENDL&&!(this.escaped&ESC_LF))
|
||||
||(chunk[i]===CHR_CR&&!(this.escaped&ESC_ALL))) {
|
||||
this.state=PARSE_NEWLINE;
|
||||
continue;
|
||||
}
|
||||
if(chunk[i]===CHR_CR&&(this.escaped&ESC_ALL)) {
|
||||
this.escaped=ESC_LF;
|
||||
}
|
||||
if(chunk[i]===CHR_ENDL&&(this.escaped&ESC_LF)) {
|
||||
this.escaped=ESC_NONE;
|
||||
}
|
||||
continue;
|
||||
// Something was wrong, waiting for a newline to continue parsing
|
||||
case PARSE_SILENT:
|
||||
if((chunk[i]===CHR_ENDL&&!(this.escaped&ESC_LF))
|
||||
||(chunk[i]===CHR_CR&&!(this.escaped&ESC_ALL))) {
|
||||
this.state=PARSE_NEWLINE;
|
||||
continue;
|
||||
}
|
||||
if(chunk[i]===CHR_CR&&(this.escaped&ESC_ALL)) {
|
||||
this.escaped=ESC_LF;
|
||||
}
|
||||
if(chunk[i]===CHR_ENDL&&(this.escaped&ESC_LF)) {
|
||||
this.escaped=ESC_NONE;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// END: Module logic end
|
||||
|
||||
return VarStreamReader;
|
||||
|
||||
});})(this,typeof define === 'function' && define.amd ?
|
||||
// AMD
|
||||
define :
|
||||
// NodeJS
|
||||
(typeof exports === 'object'?function (name, deps, factory) {
|
||||
var root=this;
|
||||
if(typeof name === 'object') {
|
||||
factory=deps; deps=name;
|
||||
}
|
||||
module.exports=factory.apply(this, deps.map(function(dep){
|
||||
return require(dep);
|
||||
}));
|
||||
}:
|
||||
// Global
|
||||
function (name, deps, factory) {
|
||||
var root=this;
|
||||
if(typeof name === 'object') {
|
||||
factory=deps; deps=name;
|
||||
}
|
||||
this.VarStreamReader=factory.apply(this, deps.map(function(dep){
|
||||
return root[dep.substring(dep.lastIndexOf('/')+1)];
|
||||
}));
|
||||
}.bind(this)
|
||||
)
|
||||
);
|
||||
135
static/js/ketcher2/node_modules/varstream/src/VarStreamWriter.js
generated
vendored
Executable file
135
static/js/ketcher2/node_modules/varstream/src/VarStreamWriter.js
generated
vendored
Executable file
@ -0,0 +1,135 @@
|
||||
'use strict';
|
||||
/*
|
||||
* Copyright (C) 2012-2013 Nicolas Froidure
|
||||
*
|
||||
* This file is free software;
|
||||
* you can redistribute it and/or modify it under the terms of the GNU
|
||||
* General Public License (GPL) as published by the Free Software
|
||||
* Foundation, in version 3. It is distributed in the
|
||||
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
||||
*
|
||||
*/
|
||||
'use strict';
|
||||
// AMD + global + NodeJS : You can use this object by inserting a script
|
||||
// or using an AMD loader (like RequireJS) or using NodeJS
|
||||
(function(root,define){ define([], function() {
|
||||
// START: Module logic start
|
||||
|
||||
function VarStreamWriter(callback, options) {
|
||||
this.lastContext='';
|
||||
this.callback=callback; // Output stream callback
|
||||
this.options=options;
|
||||
this.imbricatedArrayEntries=new Array();
|
||||
this.scopes=new Array();
|
||||
this.contexts=new Array();
|
||||
this.previousContext='';
|
||||
}
|
||||
|
||||
// Static consts
|
||||
VarStreamWriter.MORPH_CONTEXTS=2;
|
||||
VarStreamWriter.MERGE_ARRAYS=4;
|
||||
VarStreamWriter.OPTIONS=
|
||||
VarStreamWriter.MORPH_CONTEXTS|VarStreamWriter.MERGE_ARRAYS;
|
||||
|
||||
VarStreamWriter.prototype.write = function (scope, context, root) {
|
||||
context = context || '';
|
||||
if('' === context) {
|
||||
root = scope;
|
||||
}
|
||||
if(scope instanceof Object) {
|
||||
if(-1 !== this.scopes.indexOf(scope)) {
|
||||
if(root == scope) {
|
||||
this.callback(context+'&=^0'+"\n");
|
||||
} else {
|
||||
this.callback(context+'&='+this.contexts[this.scopes.indexOf(scope)]+"\n");
|
||||
}
|
||||
this.previousContext = context;
|
||||
return;
|
||||
}
|
||||
this.scopes.push(scope);
|
||||
this.contexts.push(context);
|
||||
}
|
||||
if(scope instanceof Array) {
|
||||
for(var i=0, j=scope.length; i<j; i++) {
|
||||
this.imbricatedArrayEntries.push(true);
|
||||
this.write(scope[i],(context?context+'.':'')
|
||||
+(this.options&VarStreamWriter.MERGE_ARRAYS?'?':i), root);
|
||||
this.imbricatedArrayEntries.pop();
|
||||
}
|
||||
} else if(scope instanceof Object) {
|
||||
for (var prop in scope) {
|
||||
if (scope.hasOwnProperty(prop)&&(!(scope instanceof Function))
|
||||
&&/^([a-z0-9_]+)$/i.test(prop)) {
|
||||
this.write(scope[prop],(context?context+'.':'')+prop, root);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if('' === context) {
|
||||
throw new Error('The root scope must be an Object or an Array.');
|
||||
}
|
||||
// Changing context with imbricated arrays
|
||||
for(var i=this.imbricatedArrayEntries.length-1; i>=0; i--) {
|
||||
var index=context.lastIndexOf('?');
|
||||
if(-1 === index) {
|
||||
continue;
|
||||
}
|
||||
if(this.imbricatedArrayEntries[i]) {
|
||||
context=context.substr(0,index)+'+'+context.substr(index+1);
|
||||
this.imbricatedArrayEntries[i]=false;
|
||||
} else {
|
||||
context=context.substr(0,index)+'*'+context.substr(index+1);
|
||||
}
|
||||
}
|
||||
// Trying to reduce context with ^
|
||||
var morphedContext=context;
|
||||
if(this.options&VarStreamWriter.MORPH_CONTEXTS&&this.lastContext
|
||||
&&morphedContext.indexOf(this.lastContext+'.')===0) {
|
||||
morphedContext=morphedContext.replace(this.lastContext,'^')
|
||||
}
|
||||
// Saving this context for later use
|
||||
var index=context.lastIndexOf('.');
|
||||
this.lastContext=(index!==false?context.substr(0,index):'');
|
||||
// Export the value
|
||||
if('undefined' === typeof scope) {
|
||||
scope = '';
|
||||
} else if(null === scope) {
|
||||
scope = 'null';
|
||||
} else {
|
||||
scope = (scope+'').replace(/(\r?\n)/gm,'\\'+"\n");
|
||||
}
|
||||
// Calling back
|
||||
this.callback(morphedContext+'='+scope+"\n");
|
||||
this.previousContext = context;
|
||||
}
|
||||
};
|
||||
|
||||
// END: Module logic end
|
||||
|
||||
return VarStreamWriter;
|
||||
|
||||
});})(this,typeof define === 'function' && define.amd ?
|
||||
// AMD
|
||||
define :
|
||||
// NodeJS
|
||||
(typeof exports === 'object'?function (name, deps, factory) {
|
||||
var root=this;
|
||||
if(typeof name === 'object') {
|
||||
factory=deps; deps=name;
|
||||
}
|
||||
module.exports=factory.apply(this, deps.map(function(dep){
|
||||
return require(dep);
|
||||
}));
|
||||
}:
|
||||
// Global
|
||||
function (name, deps, factory) {
|
||||
var root=this;
|
||||
if(typeof name === 'object') {
|
||||
factory=deps; deps=name;
|
||||
}
|
||||
this.VarStreamWriter=factory.apply(this, deps.map(function(dep){
|
||||
return root[dep.substring(dep.lastIndexOf('/')+1)];
|
||||
}));
|
||||
}.bind(this)
|
||||
)
|
||||
);
|
||||
|
||||
356
static/js/ketcher2/node_modules/varstream/tests/encoder.mocha.js
generated
vendored
Executable file
356
static/js/ketcher2/node_modules/varstream/tests/encoder.mocha.js
generated
vendored
Executable file
@ -0,0 +1,356 @@
|
||||
var VarStream = require('../src/VarStream')
|
||||
, fs = require('fs')
|
||||
, assert = require('assert')
|
||||
, StringDecoder = require('string_decoder').StringDecoder;
|
||||
|
||||
// Tests
|
||||
describe('Writing varstreams', function() {
|
||||
|
||||
describe("should work when", function() {
|
||||
|
||||
it("outputting simple values", function() {
|
||||
var data = '';
|
||||
new VarStream.Writer(function(str) {
|
||||
data += str;
|
||||
},
|
||||
VarStream.Reader.STRICT_MODE).write({
|
||||
'var1': 'machin',
|
||||
'var2': 'bidule',
|
||||
'var3': 'truc'
|
||||
});
|
||||
assert.equal(data,
|
||||
'var1=machin\nvar2=bidule\nvar3=truc\n');
|
||||
});
|
||||
|
||||
it("outputting variable trees", function() {
|
||||
var data = '';
|
||||
new VarStream.Writer(function(str) {
|
||||
data += str;
|
||||
}).write({
|
||||
'var1': {
|
||||
'var11': {
|
||||
'var111':'machin'
|
||||
},
|
||||
'var12': 'bidule',
|
||||
'var13': 'truc'
|
||||
}
|
||||
});
|
||||
assert.equal(data,
|
||||
'var1.var11.var111=machin\nvar1.var12=bidule\nvar1.var13=truc\n');
|
||||
});
|
||||
|
||||
it("outputting variable trees and optimizing it", function() {
|
||||
var data = '';
|
||||
new VarStream.Writer(function(str) {
|
||||
data += str;
|
||||
},
|
||||
VarStream.Writer.MORPH_CONTEXTS
|
||||
).write({
|
||||
'var1': {
|
||||
'var11': {
|
||||
'var111':'machin'
|
||||
},
|
||||
'var12': 'bidule',
|
||||
'var13': 'truc'
|
||||
}
|
||||
});
|
||||
assert.equal(data,
|
||||
'var1.var11.var111=machin\nvar1.var12=bidule\n^.var13=truc\n');
|
||||
});
|
||||
|
||||
it("outputting simple arrays", function() {
|
||||
var data = '';
|
||||
new VarStream.Writer(function(str) {
|
||||
data += str;
|
||||
}).write({
|
||||
'var1': {
|
||||
'var11': {
|
||||
'var111': ['machin', 'bidule', 'truc']
|
||||
},
|
||||
'var12': ['machin', 'bidule', 'truc'],
|
||||
'var13': ['machin', 'bidule', 'truc']
|
||||
}
|
||||
});
|
||||
assert.equal(data,
|
||||
'var1.var11.var111.0=machin\n' +
|
||||
'var1.var11.var111.1=bidule\n' +
|
||||
'var1.var11.var111.2=truc\n' +
|
||||
'var1.var12.0=machin\n' +
|
||||
'var1.var12.1=bidule\n' +
|
||||
'var1.var12.2=truc\n' +
|
||||
'var1.var13.0=machin\n' +
|
||||
'var1.var13.1=bidule\n' +
|
||||
'var1.var13.2=truc\n'
|
||||
);
|
||||
});
|
||||
|
||||
it("outputting simple arrays in merging mode", function() {
|
||||
var data = '';
|
||||
new VarStream.Writer(function(str) {
|
||||
data += str;
|
||||
},
|
||||
VarStream.Writer.MERGE_ARRAYS
|
||||
).write({
|
||||
'var1': {
|
||||
'var11': {
|
||||
'var111': ['machin', 'bidule', 'truc']
|
||||
},
|
||||
'var12': ['machin', 'bidule', 'truc'],
|
||||
'var13': ['machin', 'bidule', 'truc']
|
||||
}
|
||||
});
|
||||
assert.equal(data,
|
||||
'var1.var11.var111.+=machin\n' +
|
||||
'var1.var11.var111.+=bidule\n' +
|
||||
'var1.var11.var111.+=truc\n' +
|
||||
'var1.var12.+=machin\n' +
|
||||
'var1.var12.+=bidule\n' +
|
||||
'var1.var12.+=truc\n' +
|
||||
'var1.var13.+=machin\n' +
|
||||
'var1.var13.+=bidule\n' +
|
||||
'var1.var13.+=truc\n'
|
||||
);
|
||||
});
|
||||
|
||||
it("outputting simple arrays and optimizing", function() {
|
||||
var data = '';
|
||||
new VarStream.Writer(function(str) {
|
||||
data += str;
|
||||
},
|
||||
VarStream.Writer.MORPH_CONTEXTS
|
||||
).write({
|
||||
'var1': {
|
||||
'var11': {
|
||||
'var111': ['machin', 'bidule', 'truc']
|
||||
},
|
||||
'var12': ['machin', 'bidule', 'truc'],
|
||||
'var13': ['machin', 'bidule', 'truc']
|
||||
}
|
||||
});
|
||||
assert.equal(data,
|
||||
'var1.var11.var111.0=machin\n' +
|
||||
'^.1=bidule\n' +
|
||||
'^.2=truc\n' +
|
||||
'var1.var12.0=machin\n' +
|
||||
'^.1=bidule\n' +
|
||||
'^.2=truc\n' +
|
||||
'var1.var13.0=machin\n' +
|
||||
'^.1=bidule\n' +
|
||||
'^.2=truc\n'
|
||||
);
|
||||
});
|
||||
|
||||
it("outputting object collections", function() {
|
||||
var data = '';
|
||||
new VarStream.Writer(function(str) {
|
||||
data += str;
|
||||
}).write({
|
||||
'var1': {
|
||||
'var11': {
|
||||
'var111': [{
|
||||
name: 'machin',
|
||||
type: 'obj'
|
||||
}, {
|
||||
name: 'bidule',
|
||||
type: 'obj'
|
||||
}, {
|
||||
name: 'truc',
|
||||
type: 'obj'
|
||||
}]
|
||||
},
|
||||
'var12': [{
|
||||
name: 'machin',
|
||||
type: 'obj'
|
||||
}, {
|
||||
name: 'bidule',
|
||||
type: 'obj'
|
||||
}, {
|
||||
name: 'truc',
|
||||
type: 'obj'
|
||||
}],
|
||||
'var13': [{
|
||||
name: 'machin',
|
||||
type: 'obj'
|
||||
}, {
|
||||
name: 'bidule',
|
||||
type: 'obj'
|
||||
}, {
|
||||
name: 'truc',
|
||||
type: 'obj'
|
||||
}]
|
||||
}
|
||||
});
|
||||
assert.equal(data,
|
||||
'var1.var11.var111.0.name=machin\n' +
|
||||
'var1.var11.var111.0.type=obj\n' +
|
||||
'var1.var11.var111.1.name=bidule\n' +
|
||||
'var1.var11.var111.1.type=obj\n' +
|
||||
'var1.var11.var111.2.name=truc\n' +
|
||||
'var1.var11.var111.2.type=obj\n' +
|
||||
'var1.var12.0.name=machin\n' +
|
||||
'var1.var12.0.type=obj\n' +
|
||||
'var1.var12.1.name=bidule\n' +
|
||||
'var1.var12.1.type=obj\n' +
|
||||
'var1.var12.2.name=truc\n' +
|
||||
'var1.var12.2.type=obj\n' +
|
||||
'var1.var13.0.name=machin\n' +
|
||||
'var1.var13.0.type=obj\n' +
|
||||
'var1.var13.1.name=bidule\n' +
|
||||
'var1.var13.1.type=obj\n' +
|
||||
'var1.var13.2.name=truc\n' +
|
||||
'var1.var13.2.type=obj\n'
|
||||
);
|
||||
});
|
||||
|
||||
it("outputting object collections in merging mode", function() {
|
||||
var data = '';
|
||||
new VarStream.Writer(function(str) {
|
||||
data += str;
|
||||
},
|
||||
VarStream.Writer.MERGE_ARRAYS
|
||||
).write({
|
||||
'var1': {
|
||||
'var11': {
|
||||
'var111': [{
|
||||
name: 'machin',
|
||||
type: 'obj'
|
||||
}, {
|
||||
name: 'bidule',
|
||||
type: 'obj'
|
||||
}, {
|
||||
name: 'truc',
|
||||
type: 'obj'
|
||||
}]
|
||||
},
|
||||
'var12': [{
|
||||
name: 'machin',
|
||||
type: 'obj'
|
||||
}, {
|
||||
name: 'bidule',
|
||||
type: 'obj'
|
||||
}, {
|
||||
name: 'truc',
|
||||
type: 'obj'
|
||||
}],
|
||||
'var13': [{
|
||||
name: 'machin',
|
||||
type: 'obj'
|
||||
}, {
|
||||
name: 'bidule',
|
||||
type: 'obj'
|
||||
}, {
|
||||
name: 'truc',
|
||||
type: 'obj'
|
||||
}]
|
||||
}
|
||||
});
|
||||
assert.equal(data,
|
||||
'var1.var11.var111.+.name=machin\n' +
|
||||
'var1.var11.var111.*.type=obj\n' +
|
||||
'var1.var11.var111.+.name=bidule\n' +
|
||||
'var1.var11.var111.*.type=obj\n' +
|
||||
'var1.var11.var111.+.name=truc\n' +
|
||||
'var1.var11.var111.*.type=obj\n' +
|
||||
'var1.var12.+.name=machin\n' +
|
||||
'var1.var12.*.type=obj\n' +
|
||||
'var1.var12.+.name=bidule\n' +
|
||||
'var1.var12.*.type=obj\n' +
|
||||
'var1.var12.+.name=truc\n' +
|
||||
'var1.var12.*.type=obj\n' +
|
||||
'var1.var13.+.name=machin\n' +
|
||||
'var1.var13.*.type=obj\n' +
|
||||
'var1.var13.+.name=bidule\n' +
|
||||
'var1.var13.*.type=obj\n' +
|
||||
'var1.var13.+.name=truc\n' +
|
||||
'var1.var13.*.type=obj\n'
|
||||
);
|
||||
});
|
||||
|
||||
it("outputting object collections and optimizing", function() {
|
||||
var data = '';
|
||||
new VarStream.Writer(function(str) {
|
||||
data += str;
|
||||
},
|
||||
VarStream.Writer.MORPH_CONTEXTS
|
||||
).write({
|
||||
'var1': {
|
||||
'var11': {
|
||||
'var111': [{
|
||||
name: 'machin',
|
||||
type: 'obj'
|
||||
}, {
|
||||
name: 'bidule',
|
||||
type: 'obj'
|
||||
}, {
|
||||
name: 'truc',
|
||||
type: 'obj'
|
||||
}]
|
||||
},
|
||||
'var12': [{
|
||||
name: 'machin',
|
||||
type: 'obj'
|
||||
}, {
|
||||
name: 'bidule',
|
||||
type: 'obj'
|
||||
}, {
|
||||
name: 'truc',
|
||||
type: 'obj'
|
||||
}],
|
||||
'var13': [{
|
||||
name: 'machin',
|
||||
type: 'obj'
|
||||
}, {
|
||||
name: 'bidule',
|
||||
type: 'obj'
|
||||
}, {
|
||||
name: 'truc',
|
||||
type: 'obj'
|
||||
}]
|
||||
}
|
||||
});
|
||||
assert.equal(data,
|
||||
'var1.var11.var111.0.name=machin\n' +
|
||||
'^.type=obj\n' +
|
||||
'var1.var11.var111.1.name=bidule\n' +
|
||||
'^.type=obj\n' +
|
||||
'var1.var11.var111.2.name=truc\n' +
|
||||
'^.type=obj\n' +
|
||||
'var1.var12.0.name=machin\n' +
|
||||
'^.type=obj\n' +
|
||||
'var1.var12.1.name=bidule\n' +
|
||||
'^.type=obj\n' +
|
||||
'var1.var12.2.name=truc\n' +
|
||||
'^.type=obj\n' +
|
||||
'var1.var13.0.name=machin\n' +
|
||||
'^.type=obj\n' +
|
||||
'var1.var13.1.name=bidule\n' +
|
||||
'^.type=obj\n' +
|
||||
'var1.var13.2.name=truc\n' +
|
||||
'^.type=obj\n'
|
||||
);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
describe('Writing bad varstreams', function() {
|
||||
|
||||
describe("should raise exceptions when in strict mode and", function() {
|
||||
|
||||
it("the given root object is not an object or an array", function() {
|
||||
assert.throws(
|
||||
function() {
|
||||
new VarStream.Writer(function() {}).write('');
|
||||
},
|
||||
function(err) {
|
||||
if(err instanceof Error
|
||||
&&err.message==='The root scope must be an Object or an Array.') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
32
static/js/ketcher2/node_modules/varstream/tests/fixtures/0-result.dat
generated
vendored
Executable file
32
static/js/ketcher2/node_modules/varstream/tests/fixtures/0-result.dat
generated
vendored
Executable file
@ -0,0 +1,32 @@
|
||||
aSimpleIntValue=7
|
||||
aSimpleIntNegativeValue=4988
|
||||
aSimpleFloatValue=401.99999999999994
|
||||
aSimpleFloatNegativeValue=476400
|
||||
aSimpleBoolValueTrue=true
|
||||
aSimpleBoolValueFalse=false
|
||||
aSimpleNullValue=null
|
||||
aSimpleStringValue=I'm the king of the world! Yep!
|
||||
aSimpleStringMultilineValue=I'm the king of the world!\
|
||||
You know!\
|
||||
It's true.\
|
||||
Yep.
|
||||
treeRoot.branch1.aSimpleIntValue=2000
|
||||
treeRoot.branch1.aSimpleIntNegativeValue=-2000
|
||||
treeRoot.branch3.aSimpleBoolValueFalse=false
|
||||
treeRoot.branch3.branch1.aSimpleNullValue=null
|
||||
treeRoot.branch3.branch1.aSimpleStringValue=I'm not the king of the world!
|
||||
treeRoot.branch3.branch2.aSimpleStringMultilineValue=I'm not the king of the world!\
|
||||
You know!\
|
||||
It's true.
|
||||
treeRoot.branch3.branch2.aSimpleWellDeclaredStringValue="I'm not the king of the world!"
|
||||
treeRoot.branch3.branch2.branch1.aSimpleWellDeclaredStringMultilineValue="I'm not the king of the world!
|
||||
treeRoot.branch3.aSimpleBoolValueTrue=true
|
||||
treeRoot.branch3.branch4&=treeRoot.branch3.branch2
|
||||
treeRoot.branch2.aSimpleFloatValue=2.0001
|
||||
treeRoot.branch2.aSimpleFloatNegativeValue=-1000.0002
|
||||
aSimpleWellDeclaredStringValue=undefined" Yep!"
|
||||
aSimpleWellDeclaredStringMultilineValue=undefined"
|
||||
aSimpleArray.0=10
|
||||
aSimpleArray.1=10
|
||||
aSimpleArray2.0.value=9
|
||||
aSimpleArray2.1.value=9
|
||||
12
static/js/ketcher2/node_modules/varstream/tests/fixtures/1-simple.dat
generated
vendored
Executable file
12
static/js/ketcher2/node_modules/varstream/tests/fixtures/1-simple.dat
generated
vendored
Executable file
@ -0,0 +1,12 @@
|
||||
# Simple values
|
||||
aSimpleIntValue=1898
|
||||
aSimpleIntNegativeValue=-1669
|
||||
aSimpleFloatValue=1.0025
|
||||
aSimpleFloatNegativeValue=-1191.0025
|
||||
aSimpleBoolValueTrue=true
|
||||
aSimpleBoolValueFalse=false
|
||||
aSimpleNullValue=null
|
||||
aSimpleStringValue=I'm the king of the world!
|
||||
aSimpleStringMultilineValue=I'm the king of the world!\
|
||||
You know!\
|
||||
It's true.
|
||||
16
static/js/ketcher2/node_modules/varstream/tests/fixtures/2-trees.dat
generated
vendored
Executable file
16
static/js/ketcher2/node_modules/varstream/tests/fixtures/2-trees.dat
generated
vendored
Executable file
@ -0,0 +1,16 @@
|
||||
# Simple values in a tree
|
||||
treeRoot.branch1.aSimpleIntValue=1898
|
||||
treeRoot.branch1.aSimpleIntNegativeValue=-1669
|
||||
treeRoot.branch2.aSimpleFloatValue=1.0025
|
||||
treeRoot.branch2.aSimpleFloatNegativeValue=-1191.0025
|
||||
treeRoot.branch3.aSimpleBoolValueTrue=true
|
||||
treeRoot.branch3.aSimpleBoolValueFalse=false
|
||||
treeRoot.branch3.branch1.aSimpleNullValue=null
|
||||
treeRoot.branch3.branch1.aSimpleStringValue=I'm the king of the world!
|
||||
treeRoot.branch3.branch2.aSimpleStringMultilineValue=I'm the king of the world!\
|
||||
You know!\
|
||||
It's true.
|
||||
treeRoot.branch3.branch2.aSimpleWellDeclaredStringValue="I'm the king of the world!"
|
||||
treeRoot.branch3.branch2.branch1.aSimpleWellDeclaredStringMultilineValue="I'm the king of the world!
|
||||
You \"know\"!
|
||||
It's true."
|
||||
5
static/js/ketcher2/node_modules/varstream/tests/fixtures/3-delete.dat
generated
vendored
Executable file
5
static/js/ketcher2/node_modules/varstream/tests/fixtures/3-delete.dat
generated
vendored
Executable file
@ -0,0 +1,5 @@
|
||||
treeRoot.branch1.aSimpleIntNegativeValue=
|
||||
treeRoot.branch2=
|
||||
treeRoot.branch3.aSimpleBoolValueTrue=
|
||||
treeRoot.branch3.branch1.aSimpleStringValue=
|
||||
# above lines should delete indexes
|
||||
16
static/js/ketcher2/node_modules/varstream/tests/fixtures/4-backward.dat
generated
vendored
Executable file
16
static/js/ketcher2/node_modules/varstream/tests/fixtures/4-backward.dat
generated
vendored
Executable file
@ -0,0 +1,16 @@
|
||||
# Simple values in a tree with backward references
|
||||
treeRoot.branch1.aSimpleIntValue=2000
|
||||
^.aSimpleIntNegativeValue=-2000
|
||||
treeRoot.branch2.aSimpleFloatValue=2.0001
|
||||
^.aSimpleFloatNegativeValue=-1000.0002
|
||||
treeRoot.branch3.aSimpleBoolValueTrue=true
|
||||
^1.branch3.aSimpleBoolValueFalse=false
|
||||
^2.branch1.aSimpleNullValue=null
|
||||
^.aSimpleStringValue=I'm not the king of the world!
|
||||
^2.branch2.aSimpleStringMultilineValue=I'm not the king of the world!\
|
||||
You know!\
|
||||
It's true.
|
||||
^.aSimpleWellDeclaredStringValue="I'm not the king of the world!"
|
||||
^.branch1.aSimpleWellDeclaredStringMultilineValue="I'm not the king of the world!
|
||||
You \"know\"!
|
||||
It's true."
|
||||
22
static/js/ketcher2/node_modules/varstream/tests/fixtures/5-operators.dat
generated
vendored
Executable file
22
static/js/ketcher2/node_modules/varstream/tests/fixtures/5-operators.dat
generated
vendored
Executable file
@ -0,0 +1,22 @@
|
||||
# Simple values in a tree with operators
|
||||
# Numbers
|
||||
aSimpleIntValue+=5
|
||||
aSimpleIntValue*=2
|
||||
aSimpleIntValue-=15
|
||||
aSimpleIntValue%=8
|
||||
aSimpleIntNegativeValue+=6
|
||||
aSimpleIntNegativeValue*=-3
|
||||
aSimpleIntNegativeValue-=1
|
||||
aSimpleFloatValue+=0.0025
|
||||
aSimpleFloatValue/=0.0025
|
||||
aSimpleFloatNegativeValue-=-0.0025
|
||||
aSimpleFloatNegativeValue/=-0.0025
|
||||
# Strings
|
||||
aSimpleStringValue+= Yep!
|
||||
aSimpleStringMultilineValue+=\
|
||||
Yep.
|
||||
aSimpleWellDeclaredStringValue+=" Yep!"
|
||||
aSimpleWellDeclaredStringMultilineValue+="
|
||||
Yep."
|
||||
# Objects
|
||||
treeRoot.branch3.branch4&=treeRoot.branch3.branch2
|
||||
20
static/js/ketcher2/node_modules/varstream/tests/fixtures/6-arrays.dat
generated
vendored
Executable file
20
static/js/ketcher2/node_modules/varstream/tests/fixtures/6-arrays.dat
generated
vendored
Executable file
@ -0,0 +1,20 @@
|
||||
# Playing with arrays
|
||||
aSimpleArray.!=0
|
||||
aSimpleArray.+=1
|
||||
aSimpleArray.+=2
|
||||
aSimpleArray.+=3
|
||||
^.+=4
|
||||
^.+=5
|
||||
^.+=6
|
||||
^.+=7
|
||||
^.*=8
|
||||
^.*=9
|
||||
aSimpleArray.+=9
|
||||
aSimpleArray.*=8
|
||||
aSimpleArray2.!.value=0
|
||||
aSimpleArray2.+.value=1
|
||||
aSimpleArray2.!.value=2
|
||||
aSimpleArray2.+.value=3
|
||||
aSimpleArray2.*.value=4
|
||||
aSimpleArray2.0.value=5
|
||||
aSimpleArray2.9.value=5
|
||||
5
static/js/ketcher2/node_modules/varstream/tests/fixtures/7-truncated-part1.dat
generated
vendored
Executable file
5
static/js/ketcher2/node_modules/varstream/tests/fixtures/7-truncated-part1.dat
generated
vendored
Executable file
@ -0,0 +1,5 @@
|
||||
# More complicated backward references
|
||||
aSimpleArray.+.test.test=Final pop !
|
||||
"-1.test.test=Final pop modified !
|
||||
aSimpleArray.+.test.test=New final pop !
|
||||
"-2.+.test.test=New final pop modified !
|
||||
5
static/js/ketcher2/node_modules/varstream/tests/fixtures/7-truncated-part2.dat
generated
vendored
Executable file
5
static/js/ketcher2/node_modules/varstream/tests/fixtures/7-truncated-part2.dat
generated
vendored
Executable file
@ -0,0 +1,5 @@
|
||||
# More complicated backward references
|
||||
aSimpleArray.+.test.test=Final pop !
|
||||
"-1.test.test=Final pop modified !
|
||||
aSimpleArray.+.test.test=New final pop !
|
||||
"-2.+.test.test=New final pop modified !
|
||||
5
static/js/ketcher2/node_modules/varstream/tests/fixtures/8-rightval.dat
generated
vendored
Executable file
5
static/js/ketcher2/node_modules/varstream/tests/fixtures/8-rightval.dat
generated
vendored
Executable file
@ -0,0 +1,5 @@
|
||||
aSimpleArray.!=10
|
||||
aSimpleArray.+&=aSimpleArray.*
|
||||
aSimpleArray2.!.value=9
|
||||
aSimpleArray2.+.value&=aSimpleArray2.*.value
|
||||
|
||||
16
static/js/ketcher2/node_modules/varstream/tests/fixtures/9-othertext.dat
generated
vendored
Executable file
16
static/js/ketcher2/node_modules/varstream/tests/fixtures/9-othertext.dat
generated
vendored
Executable file
@ -0,0 +1,16 @@
|
||||
# Simple values
|
||||
aSimpleIntValue=1898
|
||||
aSimpleIntNegativeValue=-1669
|
||||
aSimpleFloatValue=1.0025
|
||||
aSimpleFloatNegativeValue=-1191.0025
|
||||
aSimpleBoolValueTrue=true
|
||||
aSimpleBoolValueFalse=false
|
||||
aSimpleNullValue=null
|
||||
aSimpleStringValue=I'm the king of the world!
|
||||
aSimpleStringMultilineValue=I'm the king of the world!\
|
||||
You know!\
|
||||
It's true.
|
||||
aSimpleWellDeclaredStringValue="I'm the king of the world!"
|
||||
aSimpleWellDeclaredStringMultilineValue="I'm the king of the world!
|
||||
You \"know\"!
|
||||
It's true."
|
||||
18
static/js/ketcher2/node_modules/varstream/tests/fixtures/y-complexarray.dat
generated
vendored
Normal file
18
static/js/ketcher2/node_modules/varstream/tests/fixtures/y-complexarray.dat
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
aComplexerArray.+.value=plop
|
||||
aComplexerArray.*.value2=plip
|
||||
aComplexerArray.*.subarray.+.value=plop
|
||||
aComplexerArray.*.subarray.*.value=plip
|
||||
aComplexerArray.*.subarray.+.value=plop
|
||||
aComplexerArray.*.subarray.*.value=plip
|
||||
aComplexerArray.*.subarray.+.value=plop
|
||||
aComplexerArray.*.subarray.*.value=plip
|
||||
aComplexerArray.*.subarray.*.subarray.+.value=plop
|
||||
aComplexerArray.*.subarray.*.subarray.*.value=plip
|
||||
aComplexerArray.+.value=plop
|
||||
aComplexerArray.*.value2=plip
|
||||
aComplexerArray.*.+=plop
|
||||
aComplexerArray.*.+=plip
|
||||
aComplexerArray.*.*.+=plop
|
||||
aComplexerArray.*.*.+=plip
|
||||
aComplexerArray.+.value=plop
|
||||
aComplexerArray.*.value2=plip
|
||||
6
static/js/ketcher2/node_modules/varstream/tests/fixtures/z-circular.dat
generated
vendored
Normal file
6
static/js/ketcher2/node_modules/varstream/tests/fixtures/z-circular.dat
generated
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
childs.+.childs.+.title=test-file1
|
||||
childs.*.childs.*.parent&=childs.*
|
||||
childs.*.childs.+.title=test-file2
|
||||
childs.*.childs.*.parent&=childs.*
|
||||
childs.*.index.title=test-index
|
||||
# voir avec root scope
|
||||
9
static/js/ketcher2/node_modules/varstream/tests/index.html
generated
vendored
Executable file
9
static/js/ketcher2/node_modules/varstream/tests/index.html
generated
vendored
Executable file
@ -0,0 +1,9 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Test page</title>
|
||||
<script type="text/javascript" src="./../src/VarStreamReader.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
Helper for debug / tests
|
||||
</body>
|
||||
</html>
|
||||
993
static/js/ketcher2/node_modules/varstream/tests/parser.mocha.js
generated
vendored
Executable file
993
static/js/ketcher2/node_modules/varstream/tests/parser.mocha.js
generated
vendored
Executable file
@ -0,0 +1,993 @@
|
||||
var VarStream = require('../src/VarStream')
|
||||
, fs = require('fs')
|
||||
, assert = require('assert')
|
||||
, StringDecoder = require('string_decoder').StringDecoder;
|
||||
|
||||
// Tests
|
||||
describe('Parsing VarStream', function() {
|
||||
|
||||
var scope = {};
|
||||
var myVarStream=new VarStream(scope,'vars');
|
||||
it("should work for simple datas", function(done) {
|
||||
var readStream = fs.createReadStream(__dirname+'/fixtures/1-simple.dat');
|
||||
readStream.pipe(myVarStream, { end: false });
|
||||
readStream.on('end', function () {
|
||||
// Numbers
|
||||
assert.equal(typeof scope.vars.aSimpleIntValue, 'number');
|
||||
assert.equal(scope.vars.aSimpleIntValue,1898);
|
||||
assert.equal(typeof scope.vars.aSimpleIntNegativeValue, 'number');
|
||||
assert.equal(scope.vars.aSimpleIntNegativeValue,-1669);
|
||||
assert.equal(typeof scope.vars.aSimpleFloatValue, 'number');
|
||||
assert.equal(scope.vars.aSimpleFloatValue,1.0025);
|
||||
assert.equal(typeof scope.vars.aSimpleFloatNegativeValue, 'number');
|
||||
assert.equal(scope.vars.aSimpleFloatNegativeValue,-1191.0025);
|
||||
// Booleans
|
||||
assert.equal(typeof scope.vars.aSimpleBoolValueTrue, 'boolean');
|
||||
assert.equal(scope.vars.aSimpleBoolValueTrue,true);
|
||||
assert.equal(typeof scope.vars.aSimpleBoolValueFalse, 'boolean');
|
||||
assert.equal(scope.vars.aSimpleBoolValueFalse,false);
|
||||
// Strings
|
||||
assert.equal(typeof scope.vars.aSimpleStringValue, 'string');
|
||||
assert.equal(scope.vars.aSimpleStringValue,"I'm the king of the world!");
|
||||
assert.equal(typeof scope.vars.aSimpleStringMultilineValue, 'string');
|
||||
assert.equal(scope.vars.aSimpleStringMultilineValue,
|
||||
"I'm the king of the world!\nYou know!\nIt's true.");
|
||||
done();
|
||||
});
|
||||
});
|
||||
/*
|
||||
it("should work for other text", function(done) {
|
||||
fs.createReadStream(__dirname+'/fixtures/9-othertext.dat').pipe(myVarStream)
|
||||
.once('end', function () {
|
||||
// Strings
|
||||
assert.equal(typeof scope.vars.aSimpleWellDeclaredStringValue, 'string');
|
||||
assert.equal(scope.vars.aSimpleWellDeclaredStringValue,
|
||||
"I'm the king of the world!");
|
||||
assert.equal(typeof scope.vars.aSimpleWellDeclaredStringMultilineValue,
|
||||
'string');
|
||||
assert.equal(scope.vars.aSimpleWellDeclaredStringMultilineValue,
|
||||
"I'm the king of the world!\nYou \"know\"!\nIt's true.");
|
||||
done();
|
||||
});
|
||||
});*/
|
||||
|
||||
|
||||
it("should work for data trees", function(done) {
|
||||
var readStream = fs.createReadStream(__dirname+'/fixtures/2-trees.dat');
|
||||
readStream.pipe(myVarStream, { end: false });
|
||||
readStream.on('end', function () {
|
||||
assert.equal(typeof scope.vars.treeRoot.branch1,'object');
|
||||
assert.equal(scope.vars.treeRoot.branch1.aSimpleIntValue,1898);
|
||||
assert.equal(scope.vars.treeRoot.branch1.aSimpleIntNegativeValue,-1669);
|
||||
assert.equal(typeof scope.vars.treeRoot.branch2,'object');
|
||||
assert.equal(scope.vars.treeRoot.branch2.aSimpleFloatValue,1.0025);
|
||||
assert.equal(scope.vars.treeRoot.branch2.aSimpleFloatNegativeValue,
|
||||
-1191.0025);
|
||||
assert.equal(typeof scope.vars.treeRoot.branch3,'object');
|
||||
assert.equal(scope.vars.treeRoot.branch3.aSimpleBoolValueTrue,true);
|
||||
assert.equal(scope.vars.treeRoot.branch3.aSimpleBoolValueFalse,false);
|
||||
assert.equal(typeof scope.vars.treeRoot.branch3.branch1,'object');
|
||||
assert.equal(scope.vars.treeRoot.branch3.branch1.aSimpleNullValue,null);
|
||||
assert.equal(scope.vars.treeRoot.branch3.branch1.aSimpleStringValue,
|
||||
"I'm the king of the world!");
|
||||
assert.equal(typeof scope.vars.treeRoot.branch3.branch2,'object');
|
||||
assert.equal(scope.vars.treeRoot.branch3.branch2.aSimpleStringMultilineValue,
|
||||
"I'm the king of the world!\r\nYou know!\r\nIt's true.");
|
||||
//assert.equal(scope.vars.treeRoot.branch3.branch2.aSimpleWellDeclaredStringValue,
|
||||
// "I'm the king of the world!");
|
||||
//assert.equal(typeof scope.vars.treeRoot.branch3.branch2.branch1,'object');
|
||||
//assert.equal(
|
||||
// scope.vars.treeRoot.branch3.branch2.branch1.aSimpleWellDeclaredStringMultilineValue,
|
||||
// "I'm the king of the world!\nYou \"know\"!\nIt's true.");
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
it("should deleted empty datas", function(done) {
|
||||
var readStream = fs.createReadStream(__dirname+'/fixtures/3-delete.dat');
|
||||
readStream.pipe(myVarStream, { end: false });
|
||||
readStream.on('end', function () {
|
||||
assert.equal(typeof scope.vars.treeRoot.branch1.aSimpleIntNegativeValue,'undefined');
|
||||
assert.equal(typeof scope.vars.treeRoot.branch2,'undefined');
|
||||
assert.equal(typeof scope.vars.treeRoot.branch3.aSimpleBoolValueTrue,'undefined');
|
||||
assert.equal(typeof scope.vars.treeRoot.branch3.branch1.aSimpleStringValue,'string');
|
||||
assert.equal(scope.vars.treeRoot.branch3.branch1.aSimpleStringValue,'');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
it("should take backward references in count", function(done) {
|
||||
var readStream = fs.createReadStream(__dirname+'/fixtures/4-backward.dat');
|
||||
readStream.pipe(myVarStream, { end: false });
|
||||
readStream.on('end', function () {
|
||||
assert.equal(typeof scope.vars.treeRoot.branch1,'object');
|
||||
assert.strictEqual(scope.vars.treeRoot.branch1.aSimpleIntValue,2000);
|
||||
assert.strictEqual(scope.vars.treeRoot.branch1.aSimpleIntNegativeValue,-2000);
|
||||
assert.equal(typeof scope.vars.treeRoot.branch2,'object');
|
||||
assert.strictEqual(scope.vars.treeRoot.branch2.aSimpleFloatValue,2.0001);
|
||||
assert.strictEqual(scope.vars.treeRoot.branch2.aSimpleFloatNegativeValue,-1000.0002);
|
||||
assert.equal(typeof scope.vars.treeRoot.branch3,'object');
|
||||
assert.strictEqual(scope.vars.treeRoot.branch3.aSimpleBoolValueTrue,true);
|
||||
assert.strictEqual(scope.vars.treeRoot.branch3.aSimpleBoolValueFalse,false);
|
||||
assert.equal(typeof scope.vars.treeRoot.branch3.branch1,'object');
|
||||
assert.strictEqual(scope.vars.treeRoot.branch3.branch1.aSimpleNullValue,null);
|
||||
assert.strictEqual(scope.vars.treeRoot.branch3.branch1.aSimpleStringValue,
|
||||
"I'm not the king of the world!");
|
||||
//assert.equal(typeof scope.vars.treeRoot.branch3.branch2,'object');
|
||||
//assert.equal(scope.vars.treeRoot.branch3.branch2.aSimpleStringMultilineValue,
|
||||
// "I'm not the king of the world!\nYou know!\nIt's true.");
|
||||
//assert.equal(scope.vars.treeRoot.branch3.branch2.aSimpleWellDeclaredStringValue,
|
||||
// "I'm not the king of the world!");
|
||||
//assert.equal(typeof scope.vars.treeRoot.branch3.branch2.branch1,'object');
|
||||
//assert.equal(
|
||||
// scope.vars.treeRoot.branch3.branch2.branch1.aSimpleWellDeclaredStringMultilineValue,
|
||||
// "I'm not the king of the world!\nYou \"know\"!\nIt's true.");
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it("should work with operators", function(done) {
|
||||
var readStream = fs.createReadStream(__dirname+'/fixtures/5-operators.dat');
|
||||
readStream.pipe(myVarStream, { end: false });
|
||||
readStream.on('end', function () {
|
||||
// Numbers
|
||||
assert.equal(typeof scope.vars.aSimpleIntValue, 'number');
|
||||
assert.equal(scope.vars.aSimpleIntValue,(((1898+5)*2)-15)%8);
|
||||
assert.equal(typeof scope.vars.aSimpleIntNegativeValue, 'number');
|
||||
assert.equal(scope.vars.aSimpleIntNegativeValue,(((-1669)+6)*-3)-1);
|
||||
assert.equal(typeof scope.vars.aSimpleFloatValue, 'number');
|
||||
assert.equal(scope.vars.aSimpleFloatValue,(1.0025+0.0025)/0.0025);
|
||||
assert.equal(typeof scope.vars.aSimpleFloatNegativeValue, 'number');
|
||||
assert.equal(scope.vars.aSimpleFloatNegativeValue,((-1191.0025)-(-0.0025))/-0.0025);
|
||||
// Booleans
|
||||
assert.equal(typeof scope.vars.aSimpleBoolValueTrue, 'boolean');
|
||||
assert.equal(scope.vars.aSimpleBoolValueTrue,true);
|
||||
assert.equal(typeof scope.vars.aSimpleBoolValueFalse, 'boolean');
|
||||
assert.equal(scope.vars.aSimpleBoolValueFalse,false);
|
||||
// Strings
|
||||
assert.equal(typeof scope.vars.aSimpleStringValue, 'string');
|
||||
assert.equal(scope.vars.aSimpleStringValue,"I'm the king of the world! Yep!");
|
||||
assert.equal(typeof scope.vars.aSimpleStringMultilineValue, 'string');
|
||||
assert.equal(scope.vars.aSimpleStringMultilineValue,
|
||||
"I'm the king of the world!\nYou know!\nIt's true.\r\nYep.");
|
||||
/*assert.equal(typeof scope.vars.aSimpleWellDeclaredStringValue, 'string');
|
||||
assert.equal(scope.vars.aSimpleWellDeclaredStringValue,
|
||||
"I'm the king of the world! Yep!");
|
||||
assert.equal(typeof scope.vars.aSimpleWellDeclaredStringMultilineValue,
|
||||
'string');
|
||||
assert.equal(scope.vars.aSimpleWellDeclaredStringMultilineValue,
|
||||
"I'm the king of the world!\nYou \"know\"!\nIt's true.\nYep.");
|
||||
assert.equal(scope.vars.treeRoot.branch3.branch4,
|
||||
scope.vars.treeRoot.branch3.branch2);*/
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it("should work with arrays", function(done) {
|
||||
var readStream = fs.createReadStream(__dirname+'/fixtures/6-arrays.dat');
|
||||
readStream.pipe(myVarStream, { end: false });
|
||||
readStream.on('end', function () {
|
||||
// First array
|
||||
assert.equal(typeof scope.vars.aSimpleArray,'object');
|
||||
assert.equal(scope.vars.aSimpleArray instanceof Array,true);
|
||||
assert.equal(scope.vars.aSimpleArray.length,9);
|
||||
assert.equal(scope.vars.aSimpleArray[0],0);
|
||||
assert.equal(scope.vars.aSimpleArray[1],1);
|
||||
assert.equal(scope.vars.aSimpleArray[2],2);
|
||||
assert.equal(scope.vars.aSimpleArray[3],3);
|
||||
assert.equal(scope.vars.aSimpleArray[4],4);
|
||||
assert.equal(scope.vars.aSimpleArray[5],5);
|
||||
assert.equal(scope.vars.aSimpleArray[6],6);
|
||||
assert.equal(scope.vars.aSimpleArray[7],9);
|
||||
assert.equal(scope.vars.aSimpleArray[8],8);
|
||||
// Second array
|
||||
assert.equal(typeof scope.vars.aSimpleArray2,'object');
|
||||
assert.equal(scope.vars.aSimpleArray2 instanceof Array,true);
|
||||
assert.equal(scope.vars.aSimpleArray2.length,10);
|
||||
assert.equal(scope.vars.aSimpleArray2[0].value,5);
|
||||
assert.equal(scope.vars.aSimpleArray2[1].value,4);
|
||||
assert.equal(typeof scope.vars.aSimpleArray2[2],'undefined');
|
||||
assert.equal(typeof scope.vars.aSimpleArray2[3],'undefined');
|
||||
assert.equal(typeof scope.vars.aSimpleArray2[4],'undefined');
|
||||
assert.equal(typeof scope.vars.aSimpleArray2[5],'undefined');
|
||||
assert.equal(typeof scope.vars.aSimpleArray2[6],'undefined');
|
||||
assert.equal(typeof scope.vars.aSimpleArray2[7],'undefined');
|
||||
assert.equal(typeof scope.vars.aSimpleArray2[8],'undefined');
|
||||
assert.equal(scope.vars.aSimpleArray2[9].value,5);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it("Should work with truncated content beetween chunks", function(done) {
|
||||
var readStream = fs.createReadStream(__dirname+'/fixtures/7-truncated-part1.dat');
|
||||
readStream.pipe(myVarStream, { end: false })
|
||||
readStream.on('end', function () {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it("Should work with truncated content beetween chunks", function(done) {
|
||||
var readStream = fs.createReadStream(__dirname+'/fixtures/7-truncated-part2.dat');
|
||||
readStream.pipe(myVarStream, { end: false });
|
||||
readStream.on('end', function () {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it("Should interpret rightvals first", function(done) {
|
||||
var readStream = fs.createReadStream(__dirname+'/fixtures/8-rightval.dat');
|
||||
readStream.pipe(myVarStream, { end: false });
|
||||
readStream.on('end', function () {
|
||||
assert.equal(scope.vars.aSimpleArray[0],10);
|
||||
assert.equal(scope.vars.aSimpleArray[1],10);
|
||||
assert.equal(scope.vars.aSimpleArray2[0].value,9);
|
||||
assert.equal(scope.vars.aSimpleArray2[1].value,9);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it("Should output good contents", function(done) {
|
||||
var content = ''
|
||||
, decoder = new StringDecoder('utf8');
|
||||
myVarStream.on('data', function(chunk) {
|
||||
content += decoder.write(chunk);
|
||||
});
|
||||
myVarStream.on('end', function() {
|
||||
assert.equal(content,
|
||||
fs.readFileSync(__dirname+'/fixtures/0-result.dat', 'utf8'));
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('Reading chunked varstreams', function() {
|
||||
|
||||
it("Should work at the lval level", function() {
|
||||
var scope = {};
|
||||
var myVarStream=new VarStream.Reader(scope,'vars');
|
||||
myVarStream.read('aVar1=ok\naVa');
|
||||
assert.equal(scope.vars.aVar1,'ok');
|
||||
assert.equal(typeof scope.vars.aVar2,'undefined');
|
||||
myVarStream.read('r2=1000\naVar3=2000\n');
|
||||
assert.equal(scope.vars.aVar2,1000);
|
||||
assert.equal(scope.vars.aVar3,2000);
|
||||
});
|
||||
|
||||
it("Should work at the operator level", function() {
|
||||
var scope = {};
|
||||
var myVarStream=new VarStream.Reader(scope,'vars');
|
||||
myVarStream.read('aVar1=ok\naVar2');
|
||||
assert.equal(scope.vars.aVar1,'ok');
|
||||
assert.equal(typeof scope.vars.aVar2,'undefined');
|
||||
myVarStream.read('=1000\naVar3=2000\n');
|
||||
assert.equal(scope.vars.aVar2,1000);
|
||||
assert.equal(scope.vars.aVar3,2000);
|
||||
});
|
||||
|
||||
it("Should work at the next operator level", function() {
|
||||
var scope = {};
|
||||
var myVarStream=new VarStream.Reader(scope,'vars');
|
||||
myVarStream.read('aVar1=ok\naVar2=');
|
||||
assert.equal(scope.vars.aVar1,'ok');
|
||||
assert.equal(typeof scope.vars.aVar2,'undefined');
|
||||
myVarStream.read('1000\naVar3=2000\n');
|
||||
assert.equal(scope.vars.aVar2,1000);
|
||||
assert.equal(scope.vars.aVar3,2000);
|
||||
});
|
||||
|
||||
it("Should work at the rval level", function() {
|
||||
var scope = {};
|
||||
var myVarStream=new VarStream.Reader(scope,'vars');
|
||||
myVarStream.read('aVar1=ok\naVar2=1');
|
||||
assert.equal(scope.vars.aVar1,'ok');
|
||||
assert.equal(typeof scope.vars.aVar2,'undefined');
|
||||
myVarStream.read('000\naVar3=2000\n');
|
||||
assert.equal(scope.vars.aVar2,1000);
|
||||
assert.equal(scope.vars.aVar3,2000);
|
||||
});
|
||||
|
||||
it("Should work at the multiline level", function() {
|
||||
var scope = {};
|
||||
var myVarStream=new VarStream.Reader(scope,'vars');
|
||||
myVarStream.read('aVar1=ok\naVar2=Y');
|
||||
assert.equal(scope.vars.aVar1,'ok');
|
||||
assert.equal(typeof scope.vars.aVar2,'undefined');
|
||||
myVarStream.read('ep!\\\n');
|
||||
assert.equal(scope.vars.aVar2,'Yep!\n');
|
||||
myVarStream.read(' That\'');
|
||||
assert.equal(scope.vars.aVar2,'Yep!\n That\'');
|
||||
myVarStream.read('s me!\n');
|
||||
assert.equal(scope.vars.aVar2,'Yep!\n That\'s me!');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('Reading varstreams', function() {
|
||||
|
||||
it("should work well with props containing underscores", function() {
|
||||
var scope = {};
|
||||
var myVarStream=new VarStream.Reader(scope,'vars');
|
||||
myVarStream.read('a_obj.a_text=This is a text \\\\\n');
|
||||
assert.strictEqual(scope.vars.a_obj.a_text,'This is a text \\');
|
||||
myVarStream.read('a_obj.a_text=This is \\a text.\n');
|
||||
assert.strictEqual(scope.vars.a_obj.a_text,'This is \\a text.');
|
||||
myVarStream.read('a_obj.a_text=This is \\\\a text.\n');
|
||||
assert.strictEqual(scope.vars.a_obj.a_text,'This is \\a text.');
|
||||
});
|
||||
|
||||
it("should work well when chars are escaped", function() {
|
||||
var scope = {};
|
||||
var myVarStream=new VarStream.Reader(scope,'vars');
|
||||
myVarStream.read('aObj.aText=This is a text \\\\\n');
|
||||
assert.strictEqual(scope.vars.aObj.aText,'This is a text \\');
|
||||
myVarStream.read('aObj.aText=This is \\a text.\n');
|
||||
assert.strictEqual(scope.vars.aObj.aText,'This is \\a text.');
|
||||
myVarStream.read('aObj.aText=This is \\\\a text.\n');
|
||||
assert.strictEqual(scope.vars.aObj.aText,'This is \\a text.');
|
||||
});
|
||||
|
||||
it("should work when the stream refers to its root scope with ^", function() {
|
||||
var scope = {};
|
||||
var myVarStream=new VarStream.Reader(scope,'vars');
|
||||
myVarStream.read('aObj.parent&=^\n');
|
||||
assert.equal(scope.vars,scope.vars.aObj.parent);
|
||||
});
|
||||
|
||||
it("should work when the stream refers to its root scope with ^0", function() {
|
||||
var scope = {};
|
||||
var myVarStream=new VarStream.Reader(scope,'vars');
|
||||
myVarStream.read('aObj.parent&=^\n');
|
||||
assert.equal(scope.vars,scope.vars.aObj.parent);
|
||||
});
|
||||
|
||||
it("should work well when chars are escaped in multiline strings", function() {
|
||||
var scope = {};
|
||||
var myVarStream=new VarStream.Reader(scope,'vars');
|
||||
myVarStream.read('aObj.aText=This is a \\\n');
|
||||
assert.strictEqual(scope.vars.aObj.aText,'This is a \n');
|
||||
myVarStream.read('multiline \\ text.\\\n');
|
||||
assert.strictEqual(scope.vars.aObj.aText,'This is a \nmultiline \\ text.\n');
|
||||
myVarStream.read('With two \\\\ lines.\\\\\n');
|
||||
assert.strictEqual(scope.vars.aObj.aText,'This is a \nmultiline \\ text.\nWith two \\ lines.\\');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('Reading bad varstreams', function() {
|
||||
|
||||
describe("should silently fail when", function() {
|
||||
|
||||
it("a line ends with no value after =", function() {
|
||||
var scope = {};
|
||||
var myVarStream=new VarStream.Reader(scope,'vars');
|
||||
assert.doesNotThrow(function() {
|
||||
myVarStream.read('validVar1=machin\nASimpleVar\nvalidVar2=bidule\n');
|
||||
});
|
||||
assert.deepEqual(scope.vars, {
|
||||
validVar1: 'machin',
|
||||
validVar2: 'bidule'
|
||||
});
|
||||
});
|
||||
|
||||
it("a line has an empty lvalue", function() {
|
||||
var scope = {};
|
||||
var myVarStream=new VarStream.Reader(scope,'vars');
|
||||
assert.doesNotThrow(function() {
|
||||
myVarStream.read('validVar1=machin\n=truc\nvalidVar2=bidule\n');
|
||||
});
|
||||
assert.deepEqual(scope.vars, {
|
||||
validVar1: 'machin',
|
||||
validVar2: 'bidule'
|
||||
});
|
||||
});
|
||||
|
||||
it("a line has an empty lvalue with a multiline rightvalue", function() {
|
||||
var scope = {};
|
||||
var myVarStream=new VarStream.Reader(scope,'vars');
|
||||
assert.doesNotThrow(function() {
|
||||
myVarStream.read('validVar1=machin\n=truc\\n1\\n2\\nmachin\n\nvalidVar2=bidule\n'); // Something wrong here
|
||||
});
|
||||
assert.deepEqual(scope.vars, {
|
||||
validVar1: 'machin',
|
||||
validVar2: 'bidule'
|
||||
});
|
||||
});
|
||||
|
||||
it("a line ends with no value after &=", function() {
|
||||
var scope = {};
|
||||
var myVarStream=new VarStream.Reader(scope,'vars');
|
||||
assert.doesNotThrow(function() {
|
||||
myVarStream.read('validVar1=machin\nASimpleVar&=\nvalidVar2=bidule\n');
|
||||
});
|
||||
assert.deepEqual(scope.vars, {
|
||||
validVar1: 'machin',
|
||||
validVar2: 'bidule'
|
||||
});
|
||||
});
|
||||
|
||||
it("a line ends with no value after +=", function() {
|
||||
var scope = {};
|
||||
var myVarStream=new VarStream.Reader(scope,'vars');
|
||||
assert.doesNotThrow(function() {
|
||||
myVarStream.read('validVar1=machin\nASimpleVar+=\nvalidVar2=bidule\n');
|
||||
});
|
||||
assert.deepEqual(scope.vars, {
|
||||
validVar1: 'machin',
|
||||
validVar2: 'bidule'
|
||||
});
|
||||
});
|
||||
|
||||
it("a line ends with no value after -=", function() {
|
||||
var scope = {};
|
||||
var myVarStream=new VarStream.Reader(scope,'vars');
|
||||
assert.doesNotThrow(function() {
|
||||
myVarStream.read('validVar1=machin\nASimpleVar-=\nvalidVar2=bidule\n');
|
||||
});
|
||||
assert.deepEqual(scope.vars, {
|
||||
validVar1: 'machin',
|
||||
validVar2: 'bidule'
|
||||
});
|
||||
});
|
||||
|
||||
it("a line ends with no value after /=", function() {
|
||||
var scope = {};
|
||||
var myVarStream=new VarStream.Reader(scope,'vars');
|
||||
assert.doesNotThrow(function() {
|
||||
myVarStream.read('validVar1=machin\nASimpleVar/=\nvalidVar2=bidule\n');
|
||||
});
|
||||
assert.deepEqual(scope.vars, {
|
||||
validVar1: 'machin',
|
||||
validVar2: 'bidule'
|
||||
});
|
||||
});
|
||||
|
||||
it("when there are an empty node at start", function() {
|
||||
var scope = {};
|
||||
var myVarStream=new VarStream.Reader(scope,'vars');
|
||||
assert.doesNotThrow(function() {
|
||||
myVarStream.read('validVar1=machin\n.ASimpleVar=truc\nvalidVar2=bidule\n');
|
||||
});
|
||||
assert.deepEqual(scope.vars, {
|
||||
validVar1: 'machin',
|
||||
validVar2: 'bidule'
|
||||
});
|
||||
});
|
||||
|
||||
it("when there are an empty node somewhere", function() {
|
||||
var scope = {};
|
||||
var myVarStream=new VarStream.Reader(scope,'vars');
|
||||
assert.doesNotThrow(function() {
|
||||
myVarStream.read('validVar1=machin\nASimpleVar.aNode..anotherNode.and=truc\nvalidVar2=bidule\n');
|
||||
});
|
||||
assert.deepEqual(scope.vars, {
|
||||
validVar1: 'machin',
|
||||
ASimpleVar: {},
|
||||
validVar2: 'bidule'
|
||||
});
|
||||
});
|
||||
|
||||
it("when there are an empty node at end", function() {
|
||||
var scope = {};
|
||||
var myVarStream=new VarStream.Reader(scope,'vars');
|
||||
assert.doesNotThrow(function() {
|
||||
myVarStream.read('validVar1=machin\nASimpleVar.anode.=truc\nvalidVar2=bidule\n');
|
||||
});
|
||||
assert.deepEqual(scope.vars, {
|
||||
validVar1: 'machin',
|
||||
ASimpleVar: {},
|
||||
validVar2: 'bidule'
|
||||
});
|
||||
});
|
||||
|
||||
it("when there malformed nodes at start", function() {
|
||||
var scope = {};
|
||||
var myVarStream=new VarStream.Reader(scope,'vars');
|
||||
assert.doesNotThrow(function() {
|
||||
myVarStream.read('validVar1=machin\n$%*.ASimpleVar.anode.$=truc\nvalidVar2=bidule\n');
|
||||
});
|
||||
assert.deepEqual(scope.vars, {
|
||||
validVar1: 'machin',
|
||||
validVar2: 'bidule'
|
||||
});
|
||||
});
|
||||
|
||||
it("when there malformed nodes somewhere", function() {
|
||||
var scope = {};
|
||||
var myVarStream=new VarStream.Reader(scope,'vars');
|
||||
assert.doesNotThrow(function() {
|
||||
myVarStream.read('validVar1=machin\nASimpleVar.anode.$.another=truc\nvalidVar2=bidule\n');
|
||||
});
|
||||
assert.deepEqual(scope.vars, {
|
||||
validVar1: 'machin',
|
||||
ASimpleVar: {},
|
||||
validVar2: 'bidule'
|
||||
});
|
||||
});
|
||||
|
||||
it("when there malformed nodes at end", function() {
|
||||
var scope = {};
|
||||
var myVarStream=new VarStream.Reader(scope,'vars');
|
||||
assert.doesNotThrow(function() {
|
||||
myVarStream.read('validVar1=machin\nASimpleVar.anode.$=truc\nvalidVar2=bidule\n');
|
||||
});
|
||||
assert.deepEqual(scope.vars, {
|
||||
validVar1: 'machin',
|
||||
ASimpleVar: {},
|
||||
validVar2: 'bidule'
|
||||
});
|
||||
});
|
||||
|
||||
it("there are malformed backward reference in a leftval", function() {
|
||||
var scope = {};
|
||||
var myVarStream=new VarStream.Reader(scope,'vars');
|
||||
assert.doesNotThrow(function() {
|
||||
myVarStream.read('validVar1=machin\n^3g.SimpleVar.anode=truc\nvalidVar2=bidule\n');
|
||||
});
|
||||
assert.deepEqual(scope.vars, {
|
||||
validVar1: 'machin',
|
||||
validVar2: 'bidule'
|
||||
});
|
||||
});
|
||||
|
||||
it("there are malformed backward reference in a leftval 2", function() {
|
||||
var scope = {};
|
||||
var myVarStream=new VarStream.Reader(scope,'vars');
|
||||
assert.doesNotThrow(function() {
|
||||
myVarStream.read('validVar1=machin\n^g3.SimpleVar.anode=truc\nvalidVar2=bidule\n');
|
||||
});
|
||||
assert.deepEqual(scope.vars, {
|
||||
validVar1: 'machin',
|
||||
validVar2: 'bidule'
|
||||
});
|
||||
});
|
||||
|
||||
it("there are malformed backward reference in a righval", function() {
|
||||
var scope = {};
|
||||
var myVarStream=new VarStream.Reader(scope,'vars');
|
||||
assert.doesNotThrow(function() {
|
||||
myVarStream.read('validVar1=machin\nASimpleVar.anode&=^3g.truc\nvalidVar2=bidule\n');
|
||||
});
|
||||
assert.deepEqual(scope.vars, {
|
||||
validVar1: 'machin',
|
||||
ASimpleVar: {anode: null},
|
||||
validVar2: 'bidule'
|
||||
});
|
||||
});
|
||||
|
||||
it("there are malformed backward reference in a righval 2", function() {
|
||||
var scope = {};
|
||||
var myVarStream=new VarStream.Reader(scope,'vars');
|
||||
assert.doesNotThrow(function() {
|
||||
myVarStream.read('validVar1=machin\nASimpleVar.anode&=^g3.truc\nvalidVar2=bidule\n');
|
||||
});
|
||||
assert.deepEqual(scope.vars, {
|
||||
validVar1: 'machin',
|
||||
ASimpleVar: {anode: null},
|
||||
validVar2: 'bidule'
|
||||
});
|
||||
});
|
||||
|
||||
it("there are out of range backward reference in a leftval", function() {
|
||||
var scope = {};
|
||||
var myVarStream=new VarStream.Reader(scope,'vars');
|
||||
assert.doesNotThrow(function() {
|
||||
myVarStream.read('validVar1=machin\n^12.ASimpleVar.anode=truc\nvalidVar2=bidule\n');
|
||||
});
|
||||
assert.deepEqual(scope.vars, {
|
||||
validVar1: 'machin',
|
||||
validVar2: 'bidule'
|
||||
});
|
||||
});/*
|
||||
|
||||
it("there are out of range backward reference in a rightval", function() {
|
||||
var scope = {};
|
||||
var myVarStream=new VarStream.Reader(scope,'vars');
|
||||
assert.doesNotThrow(function() {
|
||||
myVarStream.read('validVar1=machin\nASimpleVar.anode+=^12.truc.truc\nvalidVar2=bidule\n');
|
||||
});
|
||||
assert.deepEqual(scope.vars, {
|
||||
validVar1: 'machin',
|
||||
ASimpleVar: {anode: null},
|
||||
validVar2: 'bidule'
|
||||
});
|
||||
});*/
|
||||
|
||||
it("a legal char is escaped", function() {
|
||||
var scope = {};
|
||||
var myVarStream=new VarStream.Reader(scope,'vars');
|
||||
assert.doesNotThrow(function() {
|
||||
myVarStream.read('validVar1=machin\nASimpleVar.anode=truc\\truc\nvalidVar2=bidule\n');
|
||||
});
|
||||
assert.deepEqual(scope.vars, {
|
||||
validVar1: 'machin',
|
||||
ASimpleVar: {anode: 'truc\\truc'},
|
||||
validVar2: 'bidule'
|
||||
});
|
||||
});
|
||||
|
||||
it("a legal char is escaped in a multiline value", function() {
|
||||
var scope = {};
|
||||
var myVarStream=new VarStream.Reader(scope,'vars');
|
||||
assert.doesNotThrow(function() {
|
||||
myVarStream.read('validVar1=machin\nASimpleVar.anode=truc\\\ntruc\\truc\nvalidVar2=bidule\n');
|
||||
});
|
||||
assert.deepEqual(scope.vars, {
|
||||
validVar1: 'machin',
|
||||
ASimpleVar: {anode: 'truc\ntruc\\truc'},
|
||||
validVar2: 'bidule'
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe("in strict mode, should raise exceptions when", function() {
|
||||
|
||||
it("a line ends with no =", function() {
|
||||
var scope = {};
|
||||
var myVarStream=new VarStream.Reader(scope,'vars',
|
||||
VarStream.Reader.STRICT_MODE);
|
||||
assert.throws(
|
||||
function() {
|
||||
myVarStream.read('ASimpleVar\n');
|
||||
},
|
||||
function(err) {
|
||||
if(err instanceof Error
|
||||
&&err.message==='Unexpected new line found while parsing '
|
||||
+' a leftValue.') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it("a line has no lvalue", function() {
|
||||
var scope = {};
|
||||
var myVarStream=new VarStream.Reader(scope,'vars',
|
||||
VarStream.Reader.STRICT_MODE);
|
||||
assert.throws(
|
||||
function() {
|
||||
myVarStream.read('=ASimpleVar\n');
|
||||
},
|
||||
function(err) {
|
||||
if(err instanceof Error
|
||||
&&err.message==='Found an empty leftValue.') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it("a line ends with no value after &=", function() {
|
||||
var scope = {};
|
||||
var myVarStream=new VarStream.Reader(scope,'vars',
|
||||
VarStream.Reader.STRICT_MODE);
|
||||
assert.throws(
|
||||
function() {
|
||||
myVarStream.read('ASimpleVar&=\n');
|
||||
},
|
||||
function(err) {
|
||||
if(err instanceof Error
|
||||
&&err.message==='Found an empty rightValue.') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it("a line ends with no value after +=", function() {
|
||||
var scope = {};
|
||||
var myVarStream=new VarStream.Reader(scope,'vars',
|
||||
VarStream.Reader.STRICT_MODE);
|
||||
assert.throws(
|
||||
function() {
|
||||
myVarStream.read('ASimpleVar+=\n');
|
||||
},
|
||||
function(err) {
|
||||
if(err instanceof Error
|
||||
&&err.message==='Found an empty rightValue.') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it("a line ends with no value after -=", function() {
|
||||
var scope = {};
|
||||
var myVarStream=new VarStream.Reader(scope,'vars',
|
||||
VarStream.Reader.STRICT_MODE);
|
||||
assert.throws(
|
||||
function() {
|
||||
myVarStream.read('ASimpleVar-=\n');
|
||||
},
|
||||
function(err) {
|
||||
if(err instanceof Error
|
||||
&&err.message==='Found an empty rightValue.') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it("a line ends with no value after *=", function() {
|
||||
var scope = {};
|
||||
var myVarStream=new VarStream.Reader(scope,'vars',
|
||||
VarStream.Reader.STRICT_MODE);
|
||||
assert.throws(
|
||||
function() {
|
||||
myVarStream.read('ASimpleVar*=\n');
|
||||
},
|
||||
function(err) {
|
||||
if(err instanceof Error
|
||||
&&err.message==='Found an empty rightValue.') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it("a line ends with no value after /=", function() {
|
||||
var scope = {};
|
||||
var myVarStream=new VarStream.Reader(scope,'vars',
|
||||
VarStream.Reader.STRICT_MODE);
|
||||
assert.throws(
|
||||
function() {
|
||||
myVarStream.read('ASimpleVar/=\n');
|
||||
},
|
||||
function(err) {
|
||||
if(err instanceof Error
|
||||
&&err.message==='Found an empty rightValue.') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it("there are a empty node at start", function() {
|
||||
var scope = {};
|
||||
var myVarStream=new VarStream.Reader(scope,'vars',
|
||||
VarStream.Reader.STRICT_MODE);
|
||||
assert.throws(
|
||||
function() {
|
||||
myVarStream.read('.ASimpleVar=true\n');
|
||||
},
|
||||
function(err) {
|
||||
if(err instanceof Error
|
||||
&&err.message==='The leftValue can\'t have empty nodes'
|
||||
+' (.ASimpleVar).') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it("there are a empty node somewhere", function() {
|
||||
var scope = {};
|
||||
var myVarStream=new VarStream.Reader(scope,'vars',
|
||||
VarStream.Reader.STRICT_MODE);
|
||||
assert.throws(
|
||||
function() {
|
||||
myVarStream.read('ASimpleVar.prop..prop.prop=true\n');
|
||||
},
|
||||
function(err) {
|
||||
if(err instanceof Error
|
||||
&&err.message==='The leftValue can\'t have empty nodes'
|
||||
+' (ASimpleVar.prop..prop.prop).') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it("there are a empty node at end", function() {
|
||||
var scope = {};
|
||||
var myVarStream=new VarStream.Reader(scope,'vars',
|
||||
VarStream.Reader.STRICT_MODE);
|
||||
assert.throws(
|
||||
function() {
|
||||
myVarStream.read('ASimpleVar.=false\n');
|
||||
},
|
||||
function(err) {
|
||||
if(err instanceof Error
|
||||
&&err.message==='The leftValue can\'t have empty nodes (ASimpleVar.).') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it("there are malformed nodes", function() {
|
||||
var scope = {};
|
||||
var myVarStream=new VarStream.Reader(scope,'vars',
|
||||
VarStream.Reader.STRICT_MODE);
|
||||
assert.throws(
|
||||
function() {
|
||||
myVarStream.read('ASimp-+leVar.ds+d=false\n');
|
||||
},
|
||||
function(err) {
|
||||
if(err instanceof Error
|
||||
&&err.message==='Unexpected char after the "-" operator. Expected "="'
|
||||
+' found "+".') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it("there are malformed nodes", function() {
|
||||
var scope = {};
|
||||
var myVarStream=new VarStream.Reader(scope,'vars',
|
||||
VarStream.Reader.STRICT_MODE);
|
||||
assert.throws(
|
||||
function() {
|
||||
myVarStream.read('ASimpleVar.ds$d=false\n');
|
||||
},
|
||||
function(err) {
|
||||
if(err instanceof Error
|
||||
&&err.message==='Illegal chars found in a the node "ds$d".') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it("there are out of range backward reference", function() {
|
||||
var scope = {};
|
||||
var myVarStream=new VarStream.Reader(scope,'vars',
|
||||
VarStream.Reader.STRICT_MODE);
|
||||
assert.throws(
|
||||
function() {
|
||||
myVarStream.read('ASimpleVar.prop1.prop2=false\n^4.test=true\n');
|
||||
},
|
||||
function(err) {
|
||||
if(err instanceof Error
|
||||
&&err.message==='Backward reference index is greater than the'
|
||||
+' previous node max index.') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it("there are malformed backward reference in a righval", function() {
|
||||
var scope = {};
|
||||
var myVarStream=new VarStream.Reader(scope,'vars',
|
||||
VarStream.Reader.STRICT_MODE);
|
||||
assert.throws(
|
||||
function() {
|
||||
myVarStream.read('ASimpleVar.prop1.prop2=false\n^4b.test=true\n');
|
||||
},
|
||||
function(err) {
|
||||
if(err instanceof Error
|
||||
&&err.message==='Malformed backward reference.') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it("there are malformed backward reference in a righval 2", function() {
|
||||
var scope = {};
|
||||
var myVarStream=new VarStream.Reader(scope,'vars',
|
||||
VarStream.Reader.STRICT_MODE);
|
||||
assert.throws(
|
||||
function() {
|
||||
myVarStream.read('ASimpleVar.prop1.prop2=false\n^b5.test=true\n');
|
||||
},
|
||||
function(err) {
|
||||
if(err instanceof Error
|
||||
&&err.message==='Malformed backward reference.') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it("there are malformed backward reference in a leftval", function() {
|
||||
var scope = {};
|
||||
var myVarStream=new VarStream.Reader(scope,'vars',
|
||||
VarStream.Reader.STRICT_MODE);
|
||||
assert.throws(
|
||||
function() {
|
||||
myVarStream.read('^b5.test=true\n');
|
||||
},
|
||||
function(err) {
|
||||
if(err instanceof Error
|
||||
&&err.message==='Malformed backward reference.') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it("there are malformed backward reference in a leftval 2", function() {
|
||||
var scope = {};
|
||||
var myVarStream=new VarStream.Reader(scope,'vars',
|
||||
VarStream.Reader.STRICT_MODE);
|
||||
assert.throws(
|
||||
function() {
|
||||
myVarStream.read('^5b.test=true\n');
|
||||
},
|
||||
function(err) {
|
||||
if(err instanceof Error
|
||||
&&err.message==='Malformed backward reference.') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it("there are bad range backward reference in a leftval", function() {
|
||||
var scope = {};
|
||||
var myVarStream=new VarStream.Reader(scope,'vars',
|
||||
VarStream.Reader.STRICT_MODE);
|
||||
assert.throws(
|
||||
function() {
|
||||
myVarStream.read('^8.test=true\n');
|
||||
},
|
||||
function(err) {
|
||||
if(err instanceof Error
|
||||
&&err.message==='Backward reference index is greater than the previous node max index.') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it("a legal char is escaped", function() {
|
||||
var scope = {};
|
||||
var myVarStream=new VarStream.Reader(scope,'vars',
|
||||
VarStream.Reader.STRICT_MODE);
|
||||
assert.throws(
|
||||
function() {
|
||||
myVarStream.read('test=t\\rue\n');
|
||||
},
|
||||
function(err) {
|
||||
if(err instanceof Error
|
||||
&&err.message==='Found an escape char but there was nothing to escape.') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it("a legal char is escaped in a multiline value", function() {
|
||||
var scope = {};
|
||||
var myVarStream=new VarStream.Reader(scope,'vars',
|
||||
VarStream.Reader.STRICT_MODE);
|
||||
assert.throws(
|
||||
function() {
|
||||
myVarStream.read('test=truc\\\ntruc\\truc\n');
|
||||
},
|
||||
function(err) {
|
||||
if(err instanceof Error
|
||||
&&err.message==='Found an escape char but there was nothing to escape.') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it("an operator is not folled by =", function() {
|
||||
var scope = {};
|
||||
var myVarStream=new VarStream.Reader(scope,'vars',
|
||||
VarStream.Reader.STRICT_MODE);
|
||||
assert.throws(
|
||||
function() {
|
||||
myVarStream.read('test&\n');
|
||||
},
|
||||
function(err) {
|
||||
if(err instanceof Error
|
||||
&&err.message==='Unexpected char after the "&" operator. Expected "=" found "\n".') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
172
static/js/ketcher2/node_modules/varstream/tests/varstream.mocha.js
generated
vendored
Executable file
172
static/js/ketcher2/node_modules/varstream/tests/varstream.mocha.js
generated
vendored
Executable file
@ -0,0 +1,172 @@
|
||||
var VarStream = require('../src/VarStream')
|
||||
, fs = require('fs')
|
||||
, assert = require('assert')
|
||||
, StringDecoder = require('string_decoder').StringDecoder;
|
||||
|
||||
describe('VarStream constructor', function() {
|
||||
|
||||
it('should work when new is omitted', function() {
|
||||
assert.doesNotThrow(function() {
|
||||
VarStream({}, 'prop');
|
||||
});
|
||||
});
|
||||
|
||||
it('should accept options', function() {
|
||||
assert.doesNotThrow(function() {
|
||||
new VarStream({}, 'prop', VarStream.VarStreamReader.OPTIONS);
|
||||
});
|
||||
});
|
||||
|
||||
it('should fail when no root object is given', function() {
|
||||
assert.throws(function() {
|
||||
new VarStream();
|
||||
}, function(err) {
|
||||
if(err instanceof Error
|
||||
&&err.message==='No root object provided.') {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('should fail when no property is given', function() {
|
||||
assert.throws(function() {
|
||||
new VarStream({});
|
||||
}, function(err) {
|
||||
if(err instanceof Error
|
||||
&&err.message==='No root property name given.') {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('should fail when an empty property is given', function() {
|
||||
assert.throws(function() {
|
||||
new VarStream({}, '');
|
||||
}, function(err) {
|
||||
if(err instanceof Error
|
||||
&&err.message==='No root property name given.') {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('VarStream duplex stream', function() {
|
||||
|
||||
it('should work as expected', function(done) {
|
||||
var root = {};
|
||||
var stream = new VarStream(root, 'plop');
|
||||
stream.on('finish', function() {
|
||||
assert.equal(root.plop.plap, 'plip');
|
||||
assert.equal(root.plop.plop, 'plup');
|
||||
done();
|
||||
});
|
||||
stream.write('plap=plip\n');
|
||||
stream.write('plop=plup\n');
|
||||
stream.end();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('VarStream.stringify()', function() {
|
||||
|
||||
it('should fail with no input', function() {
|
||||
assert.throws(function() {
|
||||
VarStream.stringify();
|
||||
}, function(err) {
|
||||
if(err instanceof Error
|
||||
&&err.message==='The stringified object must be an instance of Object.') {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('should fail with input non-object input', function() {
|
||||
assert.throws(function() {
|
||||
VarStream.stringify('aiie caramba');
|
||||
}, function(err) {
|
||||
if(err instanceof Error
|
||||
&&err.message==='The stringified object must be an instance of Object.') {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('VarStream.parse()', function() {
|
||||
|
||||
it('should work with an empty string', function() {
|
||||
var obj = VarStream.parse('');
|
||||
assert.deepEqual(obj, {});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('Helpers decoding/rencoding', function() {
|
||||
|
||||
var dir = __dirname+'/fixtures'
|
||||
, files = fs.readdirSync(dir)
|
||||
;
|
||||
|
||||
it('should work with some null values', function() {
|
||||
var cnt = VarStream.stringify({
|
||||
test: undefined,
|
||||
test2: null
|
||||
});
|
||||
assert.deepEqual(
|
||||
VarStream.stringify(VarStream.parse(VarStream.stringify(VarStream.parse(cnt)))),
|
||||
VarStream.stringify(VarStream.parse(cnt))
|
||||
);
|
||||
});
|
||||
|
||||
it('should work with values referring to the root scope', function() {
|
||||
var obj = {
|
||||
test2: {}
|
||||
};
|
||||
obj.test = obj;
|
||||
obj.test2.test = obj;
|
||||
var cnt = VarStream.stringify(obj);
|
||||
assert.deepEqual(
|
||||
VarStream.stringify(VarStream.parse(VarStream.stringify(VarStream.parse(cnt)))),
|
||||
VarStream.stringify(VarStream.parse(cnt))
|
||||
);
|
||||
});
|
||||
|
||||
it('should work with complexer arrays', function() {
|
||||
var obj = VarStream.parse(fs.readFileSync(__dirname+'/fixtures/y-complexarray.dat', {encoding: 'utf-8'}));
|
||||
assert.deepEqual(
|
||||
VarStream.stringify(VarStream.parse(VarStream.stringify(obj))),
|
||||
VarStream.stringify(obj)
|
||||
);
|
||||
});
|
||||
|
||||
it('should work with circular references', function() {
|
||||
var obj = VarStream.parse(fs.readFileSync(__dirname+'/fixtures/z-circular.dat', {encoding: 'utf-8'}));
|
||||
assert.deepEqual(
|
||||
VarStream.stringify(VarStream.parse(VarStream.stringify(obj))),
|
||||
VarStream.stringify(obj)
|
||||
);
|
||||
});
|
||||
|
||||
it('should work with some null values in varstream format', function() {
|
||||
var obj = VarStream.parse('test2=null\ntest3=\n');
|
||||
assert.deepEqual(
|
||||
VarStream.stringify(VarStream.parse(VarStream.stringify(obj))),
|
||||
VarStream.stringify(obj)
|
||||
);
|
||||
});
|
||||
|
||||
files.forEach(function(file) {
|
||||
if('3-delete.dat' === file) return;
|
||||
it('should work with "'+file+'"', function() {
|
||||
var cnt = VarStream.stringify(VarStream.parse(fs.readFileSync(dir + '/' +file, {encoding: 'utf-8'})));
|
||||
assert.deepEqual(
|
||||
VarStream.stringify(VarStream.parse(VarStream.stringify(VarStream.parse(cnt)))),
|
||||
VarStream.stringify(VarStream.parse(cnt))
|
||||
);
|
||||
});
|
||||
})
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user