完成世界书、骰子、apiconfig页面处理
This commit is contained in:
5
frontend/node_modules/rw/.eslintrc
generated
vendored
Normal file
5
frontend/node_modules/rw/.eslintrc
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
env:
|
||||
node: true
|
||||
|
||||
extends:
|
||||
"eslint:recommended"
|
||||
26
frontend/node_modules/rw/LICENSE
generated
vendored
Normal file
26
frontend/node_modules/rw/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
Copyright (c) 2014-2016, Michael Bostock
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
* The name Michael Bostock may not be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL MICHAEL BOSTOCK BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
5
frontend/node_modules/rw/index.js
generated
vendored
Normal file
5
frontend/node_modules/rw/index.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
exports.dash = require("./lib/rw/dash");
|
||||
exports.readFile = require("./lib/rw/read-file");
|
||||
exports.readFileSync = require("./lib/rw/read-file-sync");
|
||||
exports.writeFile = require("./lib/rw/write-file");
|
||||
exports.writeFileSync = require("./lib/rw/write-file-sync");
|
||||
14
frontend/node_modules/rw/lib/rw/dash.js
generated
vendored
Normal file
14
frontend/node_modules/rw/lib/rw/dash.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
var slice = Array.prototype.slice;
|
||||
|
||||
function dashify(method, file) {
|
||||
return function(path) {
|
||||
var argv = arguments;
|
||||
if (path == "-") (argv = slice.call(argv)).splice(0, 1, file);
|
||||
return method.apply(null, argv);
|
||||
};
|
||||
}
|
||||
|
||||
exports.readFile = dashify(require("./read-file"), "/dev/stdin");
|
||||
exports.readFileSync = dashify(require("./read-file-sync"), "/dev/stdin");
|
||||
exports.writeFile = dashify(require("./write-file"), "/dev/stdout");
|
||||
exports.writeFileSync = dashify(require("./write-file-sync"), "/dev/stdout");
|
||||
32
frontend/node_modules/rw/lib/rw/write-file-sync.js
generated
vendored
Normal file
32
frontend/node_modules/rw/lib/rw/write-file-sync.js
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
var fs = require("fs"),
|
||||
encode = require("./encode");
|
||||
|
||||
module.exports = function(filename, data, options) {
|
||||
var stat;
|
||||
|
||||
try {
|
||||
stat = fs.statSync(filename);
|
||||
} catch (error) {
|
||||
if (error.code !== "ENOENT") throw error;
|
||||
}
|
||||
|
||||
if (!stat || stat.isFile()) {
|
||||
fs.writeFileSync(filename, data, options);
|
||||
} else {
|
||||
var fd = fs.openSync(filename, options && options.flag || "w"),
|
||||
bytesWritten = 0,
|
||||
bytesTotal = (data = encode(data, options)).length;
|
||||
|
||||
while (bytesWritten < bytesTotal) {
|
||||
try {
|
||||
bytesWritten += fs.writeSync(fd, data, bytesWritten, bytesTotal - bytesWritten, null);
|
||||
} catch (error) {
|
||||
if (error.code === "EPIPE") break; // ignore broken pipe, e.g., | head
|
||||
fs.closeSync(fd);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
fs.closeSync(fd);
|
||||
}
|
||||
};
|
||||
7
frontend/node_modules/rw/test/encode-string-async
generated
vendored
Normal file
7
frontend/node_modules/rw/test/encode-string-async
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
var rw = require("../").dash;
|
||||
|
||||
rw.writeFile(process.argv[2] || "-", "gréén\n", process.argv[3], function(error) {
|
||||
if (error) throw error;
|
||||
});
|
||||
53
frontend/node_modules/rw/test/run-tests
generated
vendored
Normal file
53
frontend/node_modules/rw/test/run-tests
generated
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
#!/bin/bash
|
||||
|
||||
FILE=test/input.txt
|
||||
|
||||
rm -f -- $FILE
|
||||
for i in {1..10000}; do printf '%09X\n' $RANDOM >> $FILE; done
|
||||
|
||||
function test()
|
||||
{
|
||||
if [[ $1 -eq 0 ]]
|
||||
then
|
||||
echo -e "\x1B[1;32m✓ $2\x1B[0m"
|
||||
else
|
||||
echo -e "\x1B[1;31m✗ $2\x1B[0m"
|
||||
fi
|
||||
}
|
||||
|
||||
test/encoding-sync; test $? "encoding-sync applies the specified encodings"
|
||||
test/encoding-async; test $? "encoding-async applies the specified encodings"
|
||||
[ "$(test/wc-async $FILE)" = "100000" ]; test $? "wc-async reads an entire file"
|
||||
[ "$(test/wc-sync $FILE)" = "100000" ]; test $? "wc-sync reads an entire file"
|
||||
[ "$(test/wc-async < $FILE)" = "100000" ]; test $? "wc-async reads an entire file from stdin"
|
||||
[ "$(test/wc-sync < $FILE)" = "100000" ]; test $? "wc-sync reads an entire file from stdin"
|
||||
[ "$(cat $FILE | test/wc-async)" = "100000" ]; test $? "wc-async reads an entire file from a pipe"
|
||||
[ "$(cat $FILE | test/wc-sync)" = "100000" ]; test $? "wc-sync reads an entire file from a pipe"
|
||||
[ "$(test/cat-async $FILE | wc -c | tr -d ' ')" = "100000" ]; test $? "cat-async reads an entire file and writes it to a pipe"
|
||||
[ "$(test/cat-sync $FILE | wc -c | tr -d ' ')" = "100000" ]; test $? "cat-sync reads an entire file and writes it to a pipe"
|
||||
[ "$(test/cat-async $FILE | test/wc-async)" = "100000" ]; test $? "cat-async reads an entire file and writes it to a pipe to wc-async "
|
||||
[ "$(test/cat-async $FILE | test/wc-sync)" = "100000" ]; test $? "cat-async reads an entire file and writes it to a pipe to wc-sync "
|
||||
[ "$(test/cat-sync $FILE | test/wc-async)" = "100000" ]; test $? "cat-sync reads an entire file and writes it to a pipe to wc-async "
|
||||
[ "$(test/cat-sync $FILE | test/wc-sync)" = "100000" ]; test $? "cat-sync reads an entire file and writes it to a pipe to wc-sync "
|
||||
[ "$(test/cat-async < $FILE | wc -c | tr -d ' ')" = "100000" ]; test $? "cat-async reads an entire file from stdin and writes it to a pipe"
|
||||
[ "$(test/cat-sync < $FILE | wc -c | tr -d ' ')" = "100000" ]; test $? "cat-sync reads an entire file from stdin and writes it to a pipe"
|
||||
[ "$(test/cat-async < $FILE | test/wc-async)" = "100000" ]; test $? "cat-async reads an entire file from stdin and writes it to a pipe to wc-async"
|
||||
[ "$(test/cat-async < $FILE | test/wc-sync)" = "100000" ]; test $? "cat-async reads an entire file from stdin and writes it to a pipe to wc-sync"
|
||||
[ "$(test/cat-sync < $FILE | test/wc-async)" = "100000" ]; test $? "cat-sync reads an entire file from stdin and writes it to a pipe to wc-async"
|
||||
[ "$(test/cat-sync < $FILE | test/wc-sync)" = "100000" ]; test $? "cat-sync reads an entire file from stdin and writes it to a pipe to wc-sync"
|
||||
[ "$(cat $FILE | test/cat-async | test/wc-async)" = "100000" ]; test $? "cat-async reads an entire file from a pipe and writes it to a pipe to wc-async"
|
||||
[ "$(cat $FILE | test/cat-async | test/wc-sync)" = "100000" ]; test $? "cat-async reads an entire file from a pipe and writes it to a pipe to wc-sync"
|
||||
[ "$(cat $FILE | test/cat-sync | test/wc-async)" = "100000" ]; test $? "cat-sync reads an entire file from a pipe and writes it to a pipe to wc-async"
|
||||
[ "$(cat $FILE | test/cat-sync | test/wc-sync)" = "100000" ]; test $? "cat-sync reads an entire file from a pipe and writes it to a pipe to wc-sync"
|
||||
[ "$(cat $FILE | test/cat-async | head -n 100 | test/wc-async)" = "1000" ]; test $? "cat-async reads an entire file from a pipe and writes it to a pipe to head to wc-async"
|
||||
[ "$(cat $FILE | test/cat-async | head -n 100 | test/wc-sync)" = "1000" ]; test $? "cat-async reads an entire file from a pipe and writes it to a pipe to head to wc-sync"
|
||||
[ "$(cat $FILE | test/cat-sync | head -n 100 | test/wc-async)" = "1000" ]; test $? "cat-sync reads an entire file from a pipe and writes it to a pipe to head to wc-async"
|
||||
[ "$(cat $FILE | test/cat-sync | head -n 100 | test/wc-sync)" = "1000" ]; test $? "cat-sync reads an entire file from a pipe and writes it to a pipe to head to wc-sync"
|
||||
[ "$(cat $FILE 2> /dev/null | head -n 100 | test/cat-async | test/wc-async)" = "1000" ]; test $? "cat-async reads the head of a file from a pipe and writes it to wc-async"
|
||||
[ "$(cat $FILE 2> /dev/null | head -n 100 | test/cat-async | test/wc-sync)" = "1000" ]; test $? "cat-async reads the head of a file from a pipe and writes it to wc-sync"
|
||||
[ "$(cat $FILE 2> /dev/null | head -n 100 | test/cat-sync | test/wc-async)" = "1000" ]; test $? "cat-sync reads the head of a file from a pipe and writes it to wc-async"
|
||||
[ "$(cat $FILE 2> /dev/null | head -n 100 | test/cat-sync | test/wc-sync)" = "1000" ]; test $? "cat-sync reads the head of a file from a pipe and writes it to wc-sync"
|
||||
[ "$(test/write-async test/write.out && cat test/write.out)" = "Hello, world!" ]; test $? "write-async writes an entire file"
|
||||
[ "$(test/write-sync test/write.out && cat test/write.out)" = "Hello, world!" ]; test $? "write-sync writes an entire file"
|
||||
|
||||
rm -f -- $FILE test/write.out test/encoding-sync.out test/encoding-async.out
|
||||
5
frontend/node_modules/rw/test/wc-sync
generated
vendored
Normal file
5
frontend/node_modules/rw/test/wc-sync
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
var rw = require("../").dash;
|
||||
|
||||
console.log(rw.readFileSync(process.argv[2] || "-", "utf8").length);
|
||||
Reference in New Issue
Block a user