TheDesk Mizuki (ver.2)
This commit is contained in:
parent
ac4ea9fe9f
commit
28b548d49f
|
@ -24,18 +24,25 @@ body,html{overflow-y: scroll;}
|
|||
<script type="text/javascript" src="./js/common/time.js"></script>
|
||||
<script type="text/javascript" src="./js/common/modal.js"></script>
|
||||
<a href="index.html" class="btn waves-effect orange nex" style="width:100%; max-width:200px;">戻る</a><br>
|
||||
<div id="acct-list"></div>
|
||||
<div id="acct-list" class="row"></div>
|
||||
<div class="divider"></div>
|
||||
アカウントを追加<br>
|
||||
<div id="add">
|
||||
<input type="text" id="url" style="width:70%" placeholder="mstdn.jp">
|
||||
<div id="ins-suggest"></div>
|
||||
<button class="btn waves-effect" onclick="instance()">Login</button><br>
|
||||
Windows以外でご使用の方やPleromaにログインされる方はチェックを入れて下さい。<br>
|
||||
<input type="checkbox" class="filled-in" id="linux" />
|
||||
<label for="linux">コードセットアップ</label><br>
|
||||
<span style="font-family:Open Sans;">Supports</span>
|
||||
<div id="support"></div>
|
||||
<div class="row">
|
||||
<div class="col s6">
|
||||
<input type="text" id="url" style="width:70%" placeholder="mstdn.jp">
|
||||
<div id="ins-suggest"></div>
|
||||
<button class="btn waves-effect" onclick="instance()">Login</button><br>
|
||||
Windows以外でご使用の方やPleromaにログインされる方はチェックを入れて下さい。<br>
|
||||
<input type="checkbox" class="filled-in" id="linux" />
|
||||
<label for="linux">コードセットアップ</label><br>
|
||||
</div>
|
||||
<div class="col s6">
|
||||
<span style="font-family:Open Sans;">Supports</span>
|
||||
<div id="support" class="collection transparent"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="auth" style="display:none">
|
||||
指定されたコードを貼り付けてください。ログインウィンドウは閉じていただいて構いません。<br>
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
<script type="text/javascript" src="./js/ui/jquery-ui.min.js"></script>
|
||||
<script>
|
||||
//必ずアプデ時のremove instance消して!
|
||||
var ver="Mizuki (ver.1)";
|
||||
var ver="Mizuki (ver.2)";
|
||||
//betaを入れるとバージョンチェックしない
|
||||
//var ver="beta";
|
||||
var acct_id=0;
|
||||
|
|
|
@ -10,6 +10,11 @@ var idata={
|
|||
"kirishima.cloud_letters":"6229",
|
||||
"kirishima.cloud_bbcode":"enabled",
|
||||
"kirishima.cloud_markdown":"disabled",
|
||||
"minohdon.jp":"instance",
|
||||
"minohdon.jp_name":"箕面丼",
|
||||
"minohdon.jp_letters":"5000",
|
||||
"minohdon.jp_bbcode":"disabled",
|
||||
"minohdon.jp_markdown":"disabled",
|
||||
"knzk.me":"instance",
|
||||
"knzk.me_name":"神崎丼",
|
||||
"knzk.me_letters":"5000",
|
||||
|
@ -346,20 +351,7 @@ function ckdb(acct_id) {
|
|||
|
||||
//サポートインスタンス取得
|
||||
function support() {
|
||||
var ver=enc(localStorage.getItem("ver"));
|
||||
var start = "https://dl.thedesk.top/mastodon_data.json?"+ver;
|
||||
fetch(start, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'content-type': 'application/json'
|
||||
},
|
||||
//body: JSON.stringify({})
|
||||
}).then(function(response) {
|
||||
return response.json();
|
||||
}).catch(function(error) {
|
||||
todo(error);
|
||||
console.error(error);
|
||||
}).then(function(json) {
|
||||
var json=JSON.parse(localStorage.getItem("instance"));
|
||||
console.log(json);
|
||||
Object.keys(json).forEach(function(key) {
|
||||
var instance = json[key];
|
||||
|
@ -369,7 +361,6 @@ function support() {
|
|||
$("#support").append(templete);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
//アカウントを選択…を実装
|
||||
|
|
|
@ -30,15 +30,15 @@ function load() {
|
|||
Object.keys(obj).forEach(function(key) {
|
||||
var acct = obj[key];
|
||||
var list = key * 1 + 1;
|
||||
templete = '<div class="acct" id="acct_' + key + '">' + list +
|
||||
'.<img src="' + acct.prof + '" width="40" height="40"><div class="text">' +
|
||||
templete = '<div id="acct_' + key + '"><div class="col s1">' + list +
|
||||
'.</div><div class="col s2"><img src="' + acct.prof + '" width="40" height="40"></div><div class="text col s3">' +
|
||||
acct.name + ' <span class="gray">' + escapeHTML(acct.user) + '@' + acct.domain +
|
||||
'</span></div><button class="btn waves-effect disTar" onclick="data(\'' +
|
||||
'</span></div><div class="col s2"><button class="btn waves-effect disTar" onclick="data(\'' +
|
||||
acct.domain +
|
||||
'\')">インスタンスデータ表示</button><button class="btn waves-effect" onclick="refresh(' +
|
||||
'\')">インスタンス情報</button></div><div class="col s2"><button class="btn waves-effect" onclick="refresh(' +
|
||||
key +
|
||||
')">情報更新</button><button class="btn waves-effect red disTar" onclick="multiDel(' +
|
||||
key + ')">削除</button><br></div>';
|
||||
')">情報更新</button></div><div class="col s2"><button class="btn waves-effect red disTar" onclick="multiDel(' +
|
||||
key + ')">削除</button><br></div></div>';
|
||||
$("#acct-list").append(templete);
|
||||
});
|
||||
var acctN = localStorage.getItem("acct");
|
||||
|
@ -108,14 +108,13 @@ function multiDel(target) {
|
|||
|
||||
//サポートインスタンス
|
||||
function support() {
|
||||
var start = "https://dl.thedesk.top/mastodon_data.json?eu=ai";
|
||||
var json=JSON.parse(localStorage.getItem("instance"));
|
||||
console.log(json);
|
||||
Object.keys(json).forEach(function(key) {
|
||||
var instance = json[key];
|
||||
if (instance == "instance") {
|
||||
templete = '<button class="btn waves-effect" onclick="login(\'' + key +
|
||||
'\')">' + json[key + "_name"] + '(' + key + ')</button>';
|
||||
templete = '<a onclick="login(\'' + key +
|
||||
'\')" class="collection-item pointer transparent">' + json[key + "_name"] + '(' + key + ')</a>';
|
||||
$("#support").append(templete);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -80,11 +80,13 @@ function notf(acct_id, tlid, sys) {
|
|||
var templete="";
|
||||
localStorage.setItem("lastnotf_" + acct_id,obj.id);
|
||||
if(obj.type!="follow"){
|
||||
templete = templete+parse([obj], 'notf', acct_id, tlid, popup);
|
||||
templete = parse([obj], 'notf', acct_id, tlid, popup);
|
||||
}else{
|
||||
templete = templete+userparse([obj], 'notf', acct_id, tlid, popup);
|
||||
templete = userparse([obj], 'notf', acct_id, tlid, popup);
|
||||
}
|
||||
if(!$("div[data-notfIndv=" + acct_id +"_"+obj.id+"]").length){
|
||||
$("div[data-notf=" + acct_id +"]").prepend(templete);
|
||||
}
|
||||
$("div[data-notf=" + acct_id +"]").prepend(templete);
|
||||
jQuery("time.timeago").timeago();
|
||||
} else if (type == "delete") {
|
||||
$("[toot-id=" + obj + "]").hide();
|
||||
|
@ -151,8 +153,5 @@ function notfmore(tlid) {
|
|||
function notfToggle(acct, tlid) {
|
||||
$("#notf-box_" + tlid).toggleClass("hide");
|
||||
$("#notf-box_" + tlid).toggleClass("show");
|
||||
if (!$("#notf-box_" + tlid).hasClass("fetched")) {
|
||||
notf(acct, tlid);
|
||||
}
|
||||
$(".notf-icon_" + acct).removeClass("red-text");
|
||||
}
|
||||
|
|
|
@ -134,8 +134,10 @@ function parse(obj, mix, acct_id, tlid, popup) {
|
|||
localStorage.setItem("notice-mem", noticetext);
|
||||
noticetext = "";
|
||||
}
|
||||
var if_notf='data-notfIndv="'+acct_id+"_"+toot.id+'"';
|
||||
var toot = toot.status;
|
||||
}else{
|
||||
var if_notf="";
|
||||
if (toot.reblog) {
|
||||
var rebtxt = "がブースト";
|
||||
if(localStorage.getItem("domain_" + acct_id)=="imastodon.net" && !locale){
|
||||
|
@ -405,7 +407,7 @@ function parse(obj, mix, acct_id, tlid, popup) {
|
|||
templete = templete + '<div id="pub_' + toot.id + '" class="cvo ' +
|
||||
boostback + ' ' + fav_app + ' ' + rt_app + ' ' + pin_app +
|
||||
' ' + hasmedia + '" toot-id="' + id + '" unixtime="' + date(obj[
|
||||
key].created_at, 'unix') + '">' +
|
||||
key].created_at, 'unix') + '" '+if_notf+'>' +
|
||||
'<div class="area-notice"><span class="gray sharesta">' + notice + home +
|
||||
'</span></div>' +
|
||||
'<div class="area-icon"><a onclick="udg(\'' + toot.account.id +
|
||||
|
|
20
app/main.js
20
app/main.js
|
@ -11,12 +11,15 @@ const path = require('path')
|
|||
const Menu=electron.Menu
|
||||
// アプリケーションをコントロールするモジュール
|
||||
const app = electron.app;
|
||||
const WindowsToaster = require('node-notifier').WindowsToaster;
|
||||
var notifier = new WindowsToaster({
|
||||
withFallback: false, // Fallback to Growl or Balloons?
|
||||
customPath: void 0 // Relative path if you want to use your fork of toast.exe
|
||||
});
|
||||
|
||||
var platform=process.platform;
|
||||
var bit=process.arch;
|
||||
if(platform=="win32"){
|
||||
const WindowsToaster = require('node-notifier').WindowsToaster;
|
||||
var notifier = new WindowsToaster({
|
||||
withFallback: false, // Fallback to Growl or Balloons?
|
||||
customPath: void 0 // Relative path if you want to use your fork of toast.exe
|
||||
});
|
||||
}
|
||||
// ウィンドウを作成するモジュール
|
||||
const BrowserWindow = electron.BrowserWindow;
|
||||
const {
|
||||
|
@ -108,6 +111,9 @@ var onError = function(err,response){
|
|||
|
||||
var ipc = electron.ipcMain;
|
||||
ipc.on('native-notf', function(e, args) {
|
||||
var platform=process.platform;
|
||||
var bit=process.arch;
|
||||
if(platform=="win32"){
|
||||
Jimp.read(args[2], function (err, lenna) {
|
||||
if (err) throw err;
|
||||
lenna.write(tmp_img);
|
||||
|
@ -120,7 +126,7 @@ ipc.on('native-notf', function(e, args) {
|
|||
}, function(error, response) {
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
ipc.on('update', function(e, x, y) {
|
||||
var platform=process.platform;
|
||||
|
|
7
app/node_modules/.bin/rimraf.cmd
generated
vendored
7
app/node_modules/.bin/rimraf.cmd
generated
vendored
|
@ -1,7 +0,0 @@
|
|||
@IF EXIST "%~dp0\node.exe" (
|
||||
"%~dp0\node.exe" "%~dp0\..\rimraf\bin.js" %*
|
||||
) ELSE (
|
||||
@SETLOCAL
|
||||
@SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
node "%~dp0\..\rimraf\bin.js" %*
|
||||
)
|
15
app/node_modules/.bin/semver
generated
vendored
Normal file
15
app/node_modules/.bin/semver
generated
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
#!/bin/sh
|
||||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||
|
||||
case `uname` in
|
||||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
|
||||
esac
|
||||
|
||||
if [ -x "$basedir/node" ]; then
|
||||
"$basedir/node" "$basedir/../semver/bin/semver" "$@"
|
||||
ret=$?
|
||||
else
|
||||
node "$basedir/../semver/bin/semver" "$@"
|
||||
ret=$?
|
||||
fi
|
||||
exit $ret
|
7
app/node_modules/.bin/semver.cmd
generated
vendored
Normal file
7
app/node_modules/.bin/semver.cmd
generated
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
@IF EXIST "%~dp0\node.exe" (
|
||||
"%~dp0\node.exe" "%~dp0\..\semver\bin\semver" %*
|
||||
) ELSE (
|
||||
@SETLOCAL
|
||||
@SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
node "%~dp0\..\semver\bin\semver" %*
|
||||
)
|
4
app/node_modules/.bin/rimraf → app/node_modules/.bin/which
generated
vendored
4
app/node_modules/.bin/rimraf → app/node_modules/.bin/which
generated
vendored
|
@ -6,10 +6,10 @@ case `uname` in
|
|||
esac
|
||||
|
||||
if [ -x "$basedir/node" ]; then
|
||||
"$basedir/node" "$basedir/../rimraf/bin.js" "$@"
|
||||
"$basedir/node" "$basedir/../which/bin/which" "$@"
|
||||
ret=$?
|
||||
else
|
||||
node "$basedir/../rimraf/bin.js" "$@"
|
||||
node "$basedir/../which/bin/which" "$@"
|
||||
ret=$?
|
||||
fi
|
||||
exit $ret
|
7
app/node_modules/.bin/which.cmd
generated
vendored
Normal file
7
app/node_modules/.bin/which.cmd
generated
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
@IF EXIST "%~dp0\node.exe" (
|
||||
"%~dp0\node.exe" "%~dp0\..\which\bin\which" %*
|
||||
) ELSE (
|
||||
@SETLOCAL
|
||||
@SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
node "%~dp0\..\which\bin\which" %*
|
||||
)
|
5
app/node_modules/balanced-match/.npmignore
generated
vendored
5
app/node_modules/balanced-match/.npmignore
generated
vendored
|
@ -1,5 +0,0 @@
|
|||
test
|
||||
.gitignore
|
||||
.travis.yml
|
||||
Makefile
|
||||
example.js
|
21
app/node_modules/balanced-match/LICENSE.md
generated
vendored
21
app/node_modules/balanced-match/LICENSE.md
generated
vendored
|
@ -1,21 +0,0 @@
|
|||
(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.
|
91
app/node_modules/balanced-match/README.md
generated
vendored
91
app/node_modules/balanced-match/README.md
generated
vendored
|
@ -1,91 +0,0 @@
|
|||
# balanced-match
|
||||
|
||||
Match balanced string pairs, like `{` and `}` or `<b>` and `</b>`. Supports regular expressions as well!
|
||||
|
||||
[![build status](https://secure.travis-ci.org/juliangruber/balanced-match.svg)](http://travis-ci.org/juliangruber/balanced-match)
|
||||
[![downloads](https://img.shields.io/npm/dm/balanced-match.svg)](https://www.npmjs.org/package/balanced-match)
|
||||
|
||||
[![testling badge](https://ci.testling.com/juliangruber/balanced-match.png)](https://ci.testling.com/juliangruber/balanced-match)
|
||||
|
||||
## Example
|
||||
|
||||
Get the first matching pair of braces:
|
||||
|
||||
```js
|
||||
var balanced = require('balanced-match');
|
||||
|
||||
console.log(balanced('{', '}', 'pre{in{nested}}post'));
|
||||
console.log(balanced('{', '}', 'pre{first}between{second}post'));
|
||||
console.log(balanced(/\s+\{\s+/, /\s+\}\s+/, 'pre { in{nest} } post'));
|
||||
```
|
||||
|
||||
The matches are:
|
||||
|
||||
```bash
|
||||
$ node example.js
|
||||
{ start: 3, end: 14, pre: 'pre', body: 'in{nested}', post: 'post' }
|
||||
{ start: 3,
|
||||
end: 9,
|
||||
pre: 'pre',
|
||||
body: 'first',
|
||||
post: 'between{second}post' }
|
||||
{ start: 3, end: 17, pre: 'pre', body: 'in{nest}', post: 'post' }
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### var m = balanced(a, b, str)
|
||||
|
||||
For the first non-nested matching pair of `a` and `b` in `str`, return an
|
||||
object with those keys:
|
||||
|
||||
* **start** the index of the first match of `a`
|
||||
* **end** the index of the matching `b`
|
||||
* **pre** the preamble, `a` and `b` not included
|
||||
* **body** the match, `a` and `b` not included
|
||||
* **post** the postscript, `a` and `b` not included
|
||||
|
||||
If there's no match, `undefined` will be returned.
|
||||
|
||||
If the `str` contains more `a` than `b` / there are unmatched pairs, the first match that was closed will be used. For example, `{{a}` will match `['{', 'a', '']` and `{a}}` will match `['', 'a', '}']`.
|
||||
|
||||
### var r = balanced.range(a, b, str)
|
||||
|
||||
For the first non-nested matching pair of `a` and `b` in `str`, return an
|
||||
array with indexes: `[ <a index>, <b index> ]`.
|
||||
|
||||
If there's no match, `undefined` will be returned.
|
||||
|
||||
If the `str` contains more `a` than `b` / there are unmatched pairs, the first match that was closed will be used. For example, `{{a}` will match `[ 1, 3 ]` and `{a}}` will match `[0, 2]`.
|
||||
|
||||
## Installation
|
||||
|
||||
With [npm](https://npmjs.org) do:
|
||||
|
||||
```bash
|
||||
npm install balanced-match
|
||||
```
|
||||
|
||||
## 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.
|
59
app/node_modules/balanced-match/index.js
generated
vendored
59
app/node_modules/balanced-match/index.js
generated
vendored
|
@ -1,59 +0,0 @@
|
|||
'use strict';
|
||||
module.exports = balanced;
|
||||
function balanced(a, b, str) {
|
||||
if (a instanceof RegExp) a = maybeMatch(a, str);
|
||||
if (b instanceof RegExp) b = maybeMatch(b, str);
|
||||
|
||||
var r = range(a, b, str);
|
||||
|
||||
return r && {
|
||||
start: r[0],
|
||||
end: r[1],
|
||||
pre: str.slice(0, r[0]),
|
||||
body: str.slice(r[0] + a.length, r[1]),
|
||||
post: str.slice(r[1] + b.length)
|
||||
};
|
||||
}
|
||||
|
||||
function maybeMatch(reg, str) {
|
||||
var m = str.match(reg);
|
||||
return m ? m[0] : null;
|
||||
}
|
||||
|
||||
balanced.range = range;
|
||||
function range(a, b, str) {
|
||||
var begs, beg, left, right, result;
|
||||
var ai = str.indexOf(a);
|
||||
var bi = str.indexOf(b, ai + 1);
|
||||
var i = ai;
|
||||
|
||||
if (ai >= 0 && bi > 0) {
|
||||
begs = [];
|
||||
left = str.length;
|
||||
|
||||
while (i >= 0 && !result) {
|
||||
if (i == ai) {
|
||||
begs.push(i);
|
||||
ai = str.indexOf(a, i + 1);
|
||||
} else if (begs.length == 1) {
|
||||
result = [ begs.pop(), bi ];
|
||||
} else {
|
||||
beg = begs.pop();
|
||||
if (beg < left) {
|
||||
left = beg;
|
||||
right = bi;
|
||||
}
|
||||
|
||||
bi = str.indexOf(b, i + 1);
|
||||
}
|
||||
|
||||
i = ai < bi && ai >= 0 ? ai : bi;
|
||||
}
|
||||
|
||||
if (begs.length) {
|
||||
result = [ left, right ];
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
112
app/node_modules/balanced-match/package.json
generated
vendored
112
app/node_modules/balanced-match/package.json
generated
vendored
|
@ -1,112 +0,0 @@
|
|||
{
|
||||
"_args": [
|
||||
[
|
||||
{
|
||||
"raw": "balanced-match@^1.0.0",
|
||||
"scope": null,
|
||||
"escapedName": "balanced-match",
|
||||
"name": "balanced-match",
|
||||
"rawSpec": "^1.0.0",
|
||||
"spec": ">=1.0.0 <2.0.0",
|
||||
"type": "range"
|
||||
},
|
||||
"C:\\Users\\ryuki\\TheDesk\\app\\node_modules\\brace-expansion"
|
||||
]
|
||||
],
|
||||
"_from": "balanced-match@>=1.0.0 <2.0.0",
|
||||
"_id": "balanced-match@1.0.0",
|
||||
"_inCache": true,
|
||||
"_location": "/balanced-match",
|
||||
"_nodeVersion": "7.8.0",
|
||||
"_npmOperationalInternal": {
|
||||
"host": "s3://npm-registry-packages",
|
||||
"tmp": "tmp/balanced-match-1.0.0.tgz_1497251909645_0.8755026108119637"
|
||||
},
|
||||
"_npmUser": {
|
||||
"name": "juliangruber",
|
||||
"email": "julian@juliangruber.com"
|
||||
},
|
||||
"_npmVersion": "4.2.0",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"raw": "balanced-match@^1.0.0",
|
||||
"scope": null,
|
||||
"escapedName": "balanced-match",
|
||||
"name": "balanced-match",
|
||||
"rawSpec": "^1.0.0",
|
||||
"spec": ">=1.0.0 <2.0.0",
|
||||
"type": "range"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/brace-expansion"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
|
||||
"_shasum": "89b4d199ab2bee49de164ea02b89ce462d71b767",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "balanced-match@^1.0.0",
|
||||
"_where": "C:\\Users\\ryuki\\TheDesk\\app\\node_modules\\brace-expansion",
|
||||
"author": {
|
||||
"name": "Julian Gruber",
|
||||
"email": "mail@juliangruber.com",
|
||||
"url": "http://juliangruber.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/juliangruber/balanced-match/issues"
|
||||
},
|
||||
"dependencies": {},
|
||||
"description": "Match balanced character pairs, like \"{\" and \"}\"",
|
||||
"devDependencies": {
|
||||
"matcha": "^0.7.0",
|
||||
"tape": "^4.6.0"
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "89b4d199ab2bee49de164ea02b89ce462d71b767",
|
||||
"tarball": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz"
|
||||
},
|
||||
"gitHead": "d701a549a7653a874eebce7eca25d3577dc868ac",
|
||||
"homepage": "https://github.com/juliangruber/balanced-match",
|
||||
"keywords": [
|
||||
"match",
|
||||
"regexp",
|
||||
"test",
|
||||
"balanced",
|
||||
"parse"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "juliangruber",
|
||||
"email": "julian@juliangruber.com"
|
||||
}
|
||||
],
|
||||
"name": "balanced-match",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/juliangruber/balanced-match.git"
|
||||
},
|
||||
"scripts": {
|
||||
"bench": "make bench",
|
||||
"test": "make test"
|
||||
},
|
||||
"testling": {
|
||||
"files": "test/*.js",
|
||||
"browsers": [
|
||||
"ie/8..latest",
|
||||
"firefox/20..latest",
|
||||
"firefox/nightly",
|
||||
"chrome/25..latest",
|
||||
"chrome/canary",
|
||||
"opera/12..latest",
|
||||
"opera/next",
|
||||
"safari/5.1..latest",
|
||||
"ipad/6.0..latest",
|
||||
"iphone/6.0..latest",
|
||||
"android-browser/4.2..latest"
|
||||
]
|
||||
},
|
||||
"version": "1.0.0"
|
||||
}
|
1
app/node_modules/binary/.npmignore
generated
vendored
1
app/node_modules/binary/.npmignore
generated
vendored
|
@ -1 +0,0 @@
|
|||
node_modules
|
4
app/node_modules/binary/.travis.yml
generated
vendored
4
app/node_modules/binary/.travis.yml
generated
vendored
|
@ -1,4 +0,0 @@
|
|||
language: node_js
|
||||
node_js:
|
||||
- 0.4
|
||||
- 0.6
|
177
app/node_modules/binary/README.markdown
generated
vendored
177
app/node_modules/binary/README.markdown
generated
vendored
|
@ -1,177 +0,0 @@
|
|||
binary
|
||||
======
|
||||
|
||||
Unpack multibyte binary values from buffers and streams.
|
||||
You can specify the endianness and signedness of the fields to be unpacked too.
|
||||
|
||||
This module is a cleaner and more complete version of
|
||||
[bufferlist](https://github.com/substack/node-bufferlist)'s binary module that
|
||||
runs on pre-allocated buffers instead of a linked list.
|
||||
|
||||
[![build status](https://secure.travis-ci.org/substack/node-binary.png)](http://travis-ci.org/substack/node-binary)
|
||||
|
||||
examples
|
||||
========
|
||||
|
||||
stream.js
|
||||
---------
|
||||
|
||||
``` js
|
||||
var binary = require('binary');
|
||||
|
||||
var ws = binary()
|
||||
.word32lu('x')
|
||||
.word16bs('y')
|
||||
.word16bu('z')
|
||||
.tap(function (vars) {
|
||||
console.dir(vars);
|
||||
})
|
||||
;
|
||||
process.stdin.pipe(ws);
|
||||
process.stdin.resume();
|
||||
```
|
||||
|
||||
output:
|
||||
|
||||
```
|
||||
$ node examples/stream.js
|
||||
abcdefgh
|
||||
{ x: 1684234849, y: 25958, z: 26472 }
|
||||
^D
|
||||
```
|
||||
|
||||
parse.js
|
||||
--------
|
||||
|
||||
``` js
|
||||
var buf = new Buffer([ 97, 98, 99, 100, 101, 102, 0 ]);
|
||||
|
||||
var binary = require('binary');
|
||||
var vars = binary.parse(buf)
|
||||
.word16ls('ab')
|
||||
.word32bu('cf')
|
||||
.word8('x')
|
||||
.vars
|
||||
;
|
||||
console.dir(vars);
|
||||
```
|
||||
|
||||
output:
|
||||
|
||||
```
|
||||
{ ab: 25185, cf: 1667523942, x: 0 }
|
||||
```
|
||||
|
||||
methods
|
||||
=======
|
||||
|
||||
`var binary = require('binary')`
|
||||
|
||||
var b = binary()
|
||||
----------------
|
||||
|
||||
Return a new writable stream `b` that has the chainable methods documented below
|
||||
for buffering binary input.
|
||||
|
||||
binary.parse(buf)
|
||||
-----------------
|
||||
|
||||
Parse a static buffer in one pass. Returns a chainable interface with the
|
||||
methods below plus a `vars` field to get at the variable stash as the last item
|
||||
in a chain.
|
||||
|
||||
In parse mode, methods will set their keys to `null` if the buffer isn't big
|
||||
enough except `buffer()` and `scan()` which read up up to the end of the buffer
|
||||
and stop.
|
||||
|
||||
b.word{8,16,32,64}{l,b}{e,u,s}(key)
|
||||
-----------------------------------
|
||||
|
||||
Parse bytes in the buffer or stream given:
|
||||
|
||||
* number of bits
|
||||
* endianness ( l : little, b : big ),
|
||||
* signedness ( u and e : unsigned, s : signed )
|
||||
|
||||
These functions won't start parsing until all previous parser functions have run
|
||||
and the data is available.
|
||||
|
||||
The result of the parse goes into the variable stash at `key`.
|
||||
If `key` has dots (`.`s), it refers to a nested address. If parent container
|
||||
values don't exist they will be created automatically, so for instance you can
|
||||
assign into `dst.addr` and `dst.port` and the `dst` key in the variable stash
|
||||
will be `{ addr : x, port : y }` afterwards.
|
||||
|
||||
b.buffer(key, size)
|
||||
-------------------
|
||||
|
||||
Take `size` bytes directly off the buffer stream, putting the resulting buffer
|
||||
slice in the variable stash at `key`. If `size` is a string, use the value at
|
||||
`vars[size]`. The key follows the same dotted address rules as the word
|
||||
functions.
|
||||
|
||||
b.scan(key, buffer)
|
||||
-------------------
|
||||
|
||||
Search for `buffer` in the stream and store all the intervening data in the
|
||||
stash at at `key`, excluding the search buffer. If `buffer` passed as a string,
|
||||
it will be converted into a Buffer internally.
|
||||
|
||||
For example, to read in a line you can just do:
|
||||
|
||||
``` js
|
||||
var b = binary()
|
||||
.scan('line', new Buffer('\r\n'))
|
||||
.tap(function (vars) {
|
||||
console.log(vars.line)
|
||||
})
|
||||
;
|
||||
stream.pipe(b);
|
||||
```
|
||||
|
||||
b.tap(cb)
|
||||
---------
|
||||
|
||||
The callback `cb` is provided with the variable stash from all the previous
|
||||
actions once they've all finished.
|
||||
|
||||
You can nest additional actions onto `this` inside the callback.
|
||||
|
||||
b.into(key, cb)
|
||||
---------------
|
||||
|
||||
Like `.tap()`, except all nested actions will assign into a `key` in the `vars`
|
||||
stash.
|
||||
|
||||
b.loop(cb)
|
||||
----------
|
||||
|
||||
Loop, each time calling `cb(end, vars)` for function `end` and the variable
|
||||
stash with `this` set to a new chain for nested parsing. The loop terminates
|
||||
once `end` is called.
|
||||
|
||||
b.flush()
|
||||
---------
|
||||
|
||||
Clear the variable stash entirely.
|
||||
|
||||
installation
|
||||
============
|
||||
|
||||
To install with [npm](http://github.com/isaacs/npm):
|
||||
|
||||
```
|
||||
npm install binary
|
||||
```
|
||||
|
||||
notes
|
||||
=====
|
||||
|
||||
The word64 functions will only return approximations since javascript uses ieee
|
||||
floating point for all number types. Mind the loss of precision.
|
||||
|
||||
license
|
||||
=======
|
||||
|
||||
MIT
|
||||
|
11
app/node_modules/binary/example/buf.js
generated
vendored
11
app/node_modules/binary/example/buf.js
generated
vendored
|
@ -1,11 +0,0 @@
|
|||
var buf = new Buffer([ 97, 98, 99, 100, 101, 102, 0 ]);
|
||||
|
||||
var binary = require('binary');
|
||||
binary(buf)
|
||||
.word16ls('ab')
|
||||
.word32bu('cf')
|
||||
.word8('x')
|
||||
.tap(function (vars) {
|
||||
console.dir(vars);
|
||||
})
|
||||
;
|
10
app/node_modules/binary/example/parse.js
generated
vendored
10
app/node_modules/binary/example/parse.js
generated
vendored
|
@ -1,10 +0,0 @@
|
|||
var buf = new Buffer([ 97, 98, 99, 100, 101, 102, 0 ]);
|
||||
|
||||
var binary = require('binary');
|
||||
var vars = binary.parse(buf)
|
||||
.word16ls('ab')
|
||||
.word32bu('cf')
|
||||
.word8('x')
|
||||
.vars
|
||||
;
|
||||
console.dir(vars);
|
12
app/node_modules/binary/example/stream.js
generated
vendored
12
app/node_modules/binary/example/stream.js
generated
vendored
|
@ -1,12 +0,0 @@
|
|||
var binary = require('binary');
|
||||
|
||||
var ws = binary()
|
||||
.word32lu('x')
|
||||
.word16bs('y')
|
||||
.word16bu('z')
|
||||
.tap(function (vars) {
|
||||
console.dir(vars);
|
||||
})
|
||||
;
|
||||
process.stdin.pipe(ws);
|
||||
process.stdin.resume();
|
397
app/node_modules/binary/index.js
generated
vendored
397
app/node_modules/binary/index.js
generated
vendored
|
@ -1,397 +0,0 @@
|
|||
var Chainsaw = require('chainsaw');
|
||||
var EventEmitter = require('events').EventEmitter;
|
||||
var Buffers = require('buffers');
|
||||
var Vars = require('./lib/vars.js');
|
||||
var Stream = require('stream').Stream;
|
||||
|
||||
exports = module.exports = function (bufOrEm, eventName) {
|
||||
if (Buffer.isBuffer(bufOrEm)) {
|
||||
return exports.parse(bufOrEm);
|
||||
}
|
||||
|
||||
var s = exports.stream();
|
||||
if (bufOrEm && bufOrEm.pipe) {
|
||||
bufOrEm.pipe(s);
|
||||
}
|
||||
else if (bufOrEm) {
|
||||
bufOrEm.on(eventName || 'data', function (buf) {
|
||||
s.write(buf);
|
||||
});
|
||||
|
||||
bufOrEm.on('end', function () {
|
||||
s.end();
|
||||
});
|
||||
}
|
||||
return s;
|
||||
};
|
||||
|
||||
exports.stream = function (input) {
|
||||
if (input) return exports.apply(null, arguments);
|
||||
|
||||
var pending = null;
|
||||
function getBytes (bytes, cb, skip) {
|
||||
pending = {
|
||||
bytes : bytes,
|
||||
skip : skip,
|
||||
cb : function (buf) {
|
||||
pending = null;
|
||||
cb(buf);
|
||||
},
|
||||
};
|
||||
dispatch();
|
||||
}
|
||||
|
||||
var offset = null;
|
||||
function dispatch () {
|
||||
if (!pending) {
|
||||
if (caughtEnd) done = true;
|
||||
return;
|
||||
}
|
||||
if (typeof pending === 'function') {
|
||||
pending();
|
||||
}
|
||||
else {
|
||||
var bytes = offset + pending.bytes;
|
||||
|
||||
if (buffers.length >= bytes) {
|
||||
var buf;
|
||||
if (offset == null) {
|
||||
buf = buffers.splice(0, bytes);
|
||||
if (!pending.skip) {
|
||||
buf = buf.slice();
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!pending.skip) {
|
||||
buf = buffers.slice(offset, bytes);
|
||||
}
|
||||
offset = bytes;
|
||||
}
|
||||
|
||||
if (pending.skip) {
|
||||
pending.cb();
|
||||
}
|
||||
else {
|
||||
pending.cb(buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function builder (saw) {
|
||||
function next () { if (!done) saw.next() }
|
||||
|
||||
var self = words(function (bytes, cb) {
|
||||
return function (name) {
|
||||
getBytes(bytes, function (buf) {
|
||||
vars.set(name, cb(buf));
|
||||
next();
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
self.tap = function (cb) {
|
||||
saw.nest(cb, vars.store);
|
||||
};
|
||||
|
||||
self.into = function (key, cb) {
|
||||
if (!vars.get(key)) vars.set(key, {});
|
||||
var parent = vars;
|
||||
vars = Vars(parent.get(key));
|
||||
|
||||
saw.nest(function () {
|
||||
cb.apply(this, arguments);
|
||||
this.tap(function () {
|
||||
vars = parent;
|
||||
});
|
||||
}, vars.store);
|
||||
};
|
||||
|
||||
self.flush = function () {
|
||||
vars.store = {};
|
||||
next();
|
||||
};
|
||||
|
||||
self.loop = function (cb) {
|
||||
var end = false;
|
||||
|
||||
saw.nest(false, function loop () {
|
||||
this.vars = vars.store;
|
||||
cb.call(this, function () {
|
||||
end = true;
|
||||
next();
|
||||
}, vars.store);
|
||||
this.tap(function () {
|
||||
if (end) saw.next()
|
||||
else loop.call(this)
|
||||
}.bind(this));
|
||||
}, vars.store);
|
||||
};
|
||||
|
||||
self.buffer = function (name, bytes) {
|
||||
if (typeof bytes === 'string') {
|
||||
bytes = vars.get(bytes);
|
||||
}
|
||||
|
||||
getBytes(bytes, function (buf) {
|
||||
vars.set(name, buf);
|
||||
next();
|
||||
});
|
||||
};
|
||||
|
||||
self.skip = function (bytes) {
|
||||
if (typeof bytes === 'string') {
|
||||
bytes = vars.get(bytes);
|
||||
}
|
||||
|
||||
getBytes(bytes, function () {
|
||||
next();
|
||||
});
|
||||
};
|
||||
|
||||
self.scan = function find (name, search) {
|
||||
if (typeof search === 'string') {
|
||||
search = new Buffer(search);
|
||||
}
|
||||
else if (!Buffer.isBuffer(search)) {
|
||||
throw new Error('search must be a Buffer or a string');
|
||||
}
|
||||
|
||||
var taken = 0;
|
||||
pending = function () {
|
||||
var pos = buffers.indexOf(search, offset + taken);
|
||||
var i = pos-offset-taken;
|
||||
if (pos !== -1) {
|
||||
pending = null;
|
||||
if (offset != null) {
|
||||
vars.set(
|
||||
name,
|
||||
buffers.slice(offset, offset + taken + i)
|
||||
);
|
||||
offset += taken + i + search.length;
|
||||
}
|
||||
else {
|
||||
vars.set(
|
||||
name,
|
||||
buffers.slice(0, taken + i)
|
||||
);
|
||||
buffers.splice(0, taken + i + search.length);
|
||||
}
|
||||
next();
|
||||
dispatch();
|
||||
} else {
|
||||
i = Math.max(buffers.length - search.length - offset - taken, 0);
|
||||
}
|
||||
taken += i;
|
||||
};
|
||||
dispatch();
|
||||
};
|
||||
|
||||
self.peek = function (cb) {
|
||||
offset = 0;
|
||||
saw.nest(function () {
|
||||
cb.call(this, vars.store);
|
||||
this.tap(function () {
|
||||
offset = null;
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
return self;
|
||||
};
|
||||
|
||||
var stream = Chainsaw.light(builder);
|
||||
stream.writable = true;
|
||||
|
||||
var buffers = Buffers();
|
||||
|
||||
stream.write = function (buf) {
|
||||
buffers.push(buf);
|
||||
dispatch();
|
||||
};
|
||||
|
||||
var vars = Vars();
|
||||
|
||||
var done = false, caughtEnd = false;
|
||||
stream.end = function () {
|
||||
caughtEnd = true;
|
||||
};
|
||||
|
||||
stream.pipe = Stream.prototype.pipe;
|
||||
Object.getOwnPropertyNames(EventEmitter.prototype).forEach(function (name) {
|
||||
stream[name] = EventEmitter.prototype[name];
|
||||
});
|
||||
|
||||
return stream;
|
||||
};
|
||||
|
||||
exports.parse = function parse (buffer) {
|
||||
var self = words(function (bytes, cb) {
|
||||
return function (name) {
|
||||
if (offset + bytes <= buffer.length) {
|
||||
var buf = buffer.slice(offset, offset + bytes);
|
||||
offset += bytes;
|
||||
vars.set(name, cb(buf));
|
||||
}
|
||||
else {
|
||||
vars.set(name, null);
|
||||
}
|
||||
return self;
|
||||
};
|
||||
});
|
||||
|
||||
var offset = 0;
|
||||
var vars = Vars();
|
||||
self.vars = vars.store;
|
||||
|
||||
self.tap = function (cb) {
|
||||
cb.call(self, vars.store);
|
||||
return self;
|
||||
};
|
||||
|
||||
self.into = function (key, cb) {
|
||||
if (!vars.get(key)) {
|
||||
vars.set(key, {});
|
||||
}
|
||||
var parent = vars;
|
||||
vars = Vars(parent.get(key));
|
||||
cb.call(self, vars.store);
|
||||
vars = parent;
|
||||
return self;
|
||||
};
|
||||
|
||||
self.loop = function (cb) {
|
||||
var end = false;
|
||||
var ender = function () { end = true };
|
||||
while (end === false) {
|
||||
cb.call(self, ender, vars.store);
|
||||
}
|
||||
return self;
|
||||
};
|
||||
|
||||
self.buffer = function (name, size) {
|
||||
if (typeof size === 'string') {
|
||||
size = vars.get(size);
|
||||
}
|
||||
var buf = buffer.slice(offset, Math.min(buffer.length, offset + size));
|
||||
offset += size;
|
||||
vars.set(name, buf);
|
||||
|
||||
return self;
|
||||
};
|
||||
|
||||
self.skip = function (bytes) {
|
||||
if (typeof bytes === 'string') {
|
||||
bytes = vars.get(bytes);
|
||||
}
|
||||
offset += bytes;
|
||||
|
||||
return self;
|
||||
};
|
||||
|
||||
self.scan = function (name, search) {
|
||||
if (typeof search === 'string') {
|
||||
search = new Buffer(search);
|
||||
}
|
||||
else if (!Buffer.isBuffer(search)) {
|
||||
throw new Error('search must be a Buffer or a string');
|
||||
}
|
||||
vars.set(name, null);
|
||||
|
||||
// simple but slow string search
|
||||
for (var i = 0; i + offset <= buffer.length - search.length + 1; i++) {
|
||||
for (
|
||||
var j = 0;
|
||||
j < search.length && buffer[offset+i+j] === search[j];
|
||||
j++
|
||||
);
|
||||
if (j === search.length) break;
|
||||
}
|
||||
|
||||
vars.set(name, buffer.slice(offset, offset + i));
|
||||
offset += i + search.length;
|
||||
return self;
|
||||
};
|
||||
|
||||
self.peek = function (cb) {
|
||||
var was = offset;
|
||||
cb.call(self, vars.store);
|
||||
offset = was;
|
||||
return self;
|
||||
};
|
||||
|
||||
self.flush = function () {
|
||||
vars.store = {};
|
||||
return self;
|
||||
};
|
||||
|
||||
self.eof = function () {
|
||||
return offset >= buffer.length;
|
||||
};
|
||||
|
||||
return self;
|
||||
};
|
||||
|
||||
// convert byte strings to unsigned little endian numbers
|
||||
function decodeLEu (bytes) {
|
||||
var acc = 0;
|
||||
for (var i = 0; i < bytes.length; i++) {
|
||||
acc += Math.pow(256,i) * bytes[i];
|
||||
}
|
||||
return acc;
|
||||
}
|
||||
|
||||
// convert byte strings to unsigned big endian numbers
|
||||
function decodeBEu (bytes) {
|
||||
var acc = 0;
|
||||
for (var i = 0; i < bytes.length; i++) {
|
||||
acc += Math.pow(256, bytes.length - i - 1) * bytes[i];
|
||||
}
|
||||
return acc;
|
||||
}
|
||||
|
||||
// convert byte strings to signed big endian numbers
|
||||
function decodeBEs (bytes) {
|
||||
var val = decodeBEu(bytes);
|
||||
if ((bytes[0] & 0x80) == 0x80) {
|
||||
val -= Math.pow(256, bytes.length);
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
// convert byte strings to signed little endian numbers
|
||||
function decodeLEs (bytes) {
|
||||
var val = decodeLEu(bytes);
|
||||
if ((bytes[bytes.length - 1] & 0x80) == 0x80) {
|
||||
val -= Math.pow(256, bytes.length);
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
function words (decode) {
|
||||
var self = {};
|
||||
|
||||
[ 1, 2, 4, 8 ].forEach(function (bytes) {
|
||||
var bits = bytes * 8;
|
||||
|
||||
self['word' + bits + 'le']
|
||||
= self['word' + bits + 'lu']
|
||||
= decode(bytes, decodeLEu);
|
||||
|
||||
self['word' + bits + 'ls']
|
||||
= decode(bytes, decodeLEs);
|
||||
|
||||
self['word' + bits + 'be']
|
||||
= self['word' + bits + 'bu']
|
||||
= decode(bytes, decodeBEu);
|
||||
|
||||
self['word' + bits + 'bs']
|
||||
= decode(bytes, decodeBEs);
|
||||
});
|
||||
|
||||
// word8be(n) == word8le(n) for all n
|
||||
self.word8 = self.word8u = self.word8be;
|
||||
self.word8s = self.word8bs;
|
||||
|
||||
return self;
|
||||
}
|
28
app/node_modules/binary/lib/vars.js
generated
vendored
28
app/node_modules/binary/lib/vars.js
generated
vendored
|
@ -1,28 +0,0 @@
|
|||
module.exports = function (store) {
|
||||
function getset (name, value) {
|
||||
var node = vars.store;
|
||||
var keys = name.split('.');
|
||||
keys.slice(0,-1).forEach(function (k) {
|
||||
if (node[k] === undefined) node[k] = {};
|
||||
node = node[k]
|
||||
});
|
||||
var key = keys[keys.length - 1];
|
||||
if (arguments.length == 1) {
|
||||
return node[key];
|
||||
}
|
||||
else {
|
||||
return node[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
var vars = {
|
||||
get : function (name) {
|
||||
return getset(name);
|
||||
},
|
||||
set : function (name, value) {
|
||||
return getset(name, value);
|
||||
},
|
||||
store : store || {},
|
||||
};
|
||||
return vars;
|
||||
};
|
102
app/node_modules/binary/package.json
generated
vendored
102
app/node_modules/binary/package.json
generated
vendored
|
@ -1,102 +0,0 @@
|
|||
{
|
||||
"_args": [
|
||||
[
|
||||
{
|
||||
"raw": "binary@>= 0.3.0 < 1",
|
||||
"scope": null,
|
||||
"escapedName": "binary",
|
||||
"name": "binary",
|
||||
"rawSpec": ">= 0.3.0 < 1",
|
||||
"spec": ">=0.3.0 <1.0.0",
|
||||
"type": "range"
|
||||
},
|
||||
"C:\\Users\\ryuki\\TheDesk\\app\\node_modules\\unzip"
|
||||
]
|
||||
],
|
||||
"_defaultsLoaded": true,
|
||||
"_engineSupported": true,
|
||||
"_from": "binary@>=0.3.0 <1.0.0",
|
||||
"_id": "binary@0.3.0",
|
||||
"_inCache": true,
|
||||
"_location": "/binary",
|
||||
"_nodeVersion": "v0.6.11",
|
||||
"_npmUser": {
|
||||
"name": "substack",
|
||||
"email": "mail@substack.net"
|
||||
},
|
||||
"_npmVersion": "1.1.19",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"raw": "binary@>= 0.3.0 < 1",
|
||||
"scope": null,
|
||||
"escapedName": "binary",
|
||||
"name": "binary",
|
||||
"rawSpec": ">= 0.3.0 < 1",
|
||||
"spec": ">=0.3.0 <1.0.0",
|
||||
"type": "range"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/unzip"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/binary/-/binary-0.3.0.tgz",
|
||||
"_shasum": "9f60553bc5ce8c3386f3b553cff47462adecaa79",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "binary@>= 0.3.0 < 1",
|
||||
"_where": "C:\\Users\\ryuki\\TheDesk\\app\\node_modules\\unzip",
|
||||
"author": {
|
||||
"name": "James Halliday",
|
||||
"email": "mail@substack.net",
|
||||
"url": "http://substack.net"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/substack/node-binary/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"buffers": "~0.1.1",
|
||||
"chainsaw": "~0.1.0"
|
||||
},
|
||||
"description": "Unpack multibyte binary values from buffers",
|
||||
"devDependencies": {
|
||||
"seq": "~0.2.5",
|
||||
"tap": "~0.2.4"
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "9f60553bc5ce8c3386f3b553cff47462adecaa79",
|
||||
"tarball": "https://registry.npmjs.org/binary/-/binary-0.3.0.tgz"
|
||||
},
|
||||
"engine": {
|
||||
"node": ">=0.4.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "*"
|
||||
},
|
||||
"homepage": "https://github.com/substack/node-binary#readme",
|
||||
"keywords": [
|
||||
"binary",
|
||||
"decode",
|
||||
"endian",
|
||||
"unpack",
|
||||
"signed",
|
||||
"unsigned"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "./index.js",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "substack",
|
||||
"email": "mail@substack.net"
|
||||
}
|
||||
],
|
||||
"name": "binary",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/substack/node-binary.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "tap test/*.js"
|
||||
},
|
||||
"version": "0.3.0"
|
||||
}
|
92
app/node_modules/binary/perf/loop.js
generated
vendored
92
app/node_modules/binary/perf/loop.js
generated
vendored
|
@ -1,92 +0,0 @@
|
|||
var Seq = require('seq');
|
||||
var Hash = require('hashish');
|
||||
var EventEmitter = require('events').EventEmitter;
|
||||
|
||||
var Bin = require('binary');
|
||||
var Buf = require('bufferlist/binary');
|
||||
var BufferList = require('bufferlist');
|
||||
|
||||
console.log('loop');
|
||||
function emitter () {
|
||||
var em = new EventEmitter;
|
||||
|
||||
var i = 0;
|
||||
var iv = setInterval(function () {
|
||||
var buf = new Buffer(10000);
|
||||
buf[0] = 0xff;
|
||||
|
||||
if (++ i >= 2000) {
|
||||
buf[0] = 0;
|
||||
clearInterval(iv);
|
||||
}
|
||||
em.emit('data', buf);
|
||||
}, 1);
|
||||
|
||||
return em;
|
||||
}
|
||||
|
||||
Seq()
|
||||
.seq(function () {
|
||||
var next = this.bind({}, null);
|
||||
bufferlist(next);
|
||||
})
|
||||
.seq(function () {
|
||||
var next = this.bind({}, null);
|
||||
binary(next);
|
||||
})
|
||||
;
|
||||
|
||||
function binary (next) {
|
||||
var em = emitter();
|
||||
var t0 = Date.now();
|
||||
|
||||
Bin(em)
|
||||
.loop(function (end) {
|
||||
this
|
||||
.word8('x')
|
||||
.word8('y')
|
||||
.word32be('z')
|
||||
.word32le('w')
|
||||
.buffer('buf', 10000 - 10)
|
||||
.tap(function (vars) {
|
||||
if (vars.x === 0) {
|
||||
var tf = Date.now();
|
||||
console.log(' binary: ' + (tf - t0) + ' ms');
|
||||
end();
|
||||
setTimeout(next, 20);
|
||||
}
|
||||
})
|
||||
})
|
||||
;
|
||||
}
|
||||
|
||||
function bufferlist (next) {
|
||||
var em = emitter();
|
||||
var t0 = Date.now();
|
||||
|
||||
var blist = new BufferList;
|
||||
em.on('data', function (buf) {
|
||||
blist.push(buf);
|
||||
});
|
||||
|
||||
Buf(blist)
|
||||
.forever(function () {
|
||||
var top = this;
|
||||
this
|
||||
.getWord8('x')
|
||||
.getWord8('y')
|
||||
.getWord32be('z')
|
||||
.getWord32le('w')
|
||||
.getBuffer('buf', 10000 - 10)
|
||||
.tap(function (vars) {
|
||||
if (vars.x === 0) {
|
||||
var tf = Date.now();
|
||||
console.log(' bufferlist: ' + (tf - t0) + ' ms');
|
||||
top.exit();
|
||||
setTimeout(next, 20);
|
||||
}
|
||||
})
|
||||
})
|
||||
.end()
|
||||
;
|
||||
}
|
80
app/node_modules/binary/perf/small.js
generated
vendored
80
app/node_modules/binary/perf/small.js
generated
vendored
|
@ -1,80 +0,0 @@
|
|||
var Seq = require('seq');
|
||||
var Hash = require('hashish');
|
||||
|
||||
var Bin = require('binary');
|
||||
var Buf = require('bufferlist/binary');
|
||||
var BufferList = require('bufferlist');
|
||||
var EventEmitter = require('events').EventEmitter;
|
||||
|
||||
function binary (buf, cb) {
|
||||
Bin(buf)
|
||||
.word32le('x')
|
||||
.word16be('y')
|
||||
.word16be('z')
|
||||
.word32le('w')
|
||||
.tap(cb)
|
||||
;
|
||||
};
|
||||
|
||||
function stream (buf, cb) {
|
||||
var em = new EventEmitter;
|
||||
Bin(em)
|
||||
.word32le('x')
|
||||
.word16be('y')
|
||||
.word16be('z')
|
||||
.word32le('w')
|
||||
.tap(cb)
|
||||
;
|
||||
em.emit('data', buf);
|
||||
};
|
||||
|
||||
function parse (buf, cb) {
|
||||
cb(Bin.parse(buf)
|
||||
.word32le('x')
|
||||
.word16be('y')
|
||||
.word16be('z')
|
||||
.word32le('w')
|
||||
.vars
|
||||
);
|
||||
};
|
||||
|
||||
function bufferlist (buf, cb) {
|
||||
var blist = new BufferList;
|
||||
blist.push(buf);
|
||||
Buf(blist)
|
||||
.getWord32le('x')
|
||||
.getWord16be('y')
|
||||
.getWord16be('z')
|
||||
.getWord32le('w')
|
||||
.tap(cb)
|
||||
.end()
|
||||
;
|
||||
};
|
||||
|
||||
|
||||
var buffers = [];
|
||||
for (var i = 0; i < 200; i++) {
|
||||
buffers.push(new Buffer(12));
|
||||
}
|
||||
|
||||
console.log('small');
|
||||
Seq(binary, stream, parse, bufferlist)
|
||||
.seqEach(function (f) {
|
||||
var t = this;
|
||||
var t0 = Date.now();
|
||||
Seq()
|
||||
.extend(buffers)
|
||||
.seqEach(function (buf) {
|
||||
f(buf, this.bind(this, null));
|
||||
})
|
||||
.seq(function () {
|
||||
var tf = Date.now();
|
||||
console.log(' ' + f.name + ': ' + (tf - t0));
|
||||
t(null);
|
||||
})
|
||||
;
|
||||
})
|
||||
.seq(function () {
|
||||
this(null);
|
||||
})
|
||||
;
|
46
app/node_modules/binary/test/bu.js
generated
vendored
46
app/node_modules/binary/test/bu.js
generated
vendored
|
@ -1,46 +0,0 @@
|
|||
var binary = require('../');
|
||||
var test = require('tap').test;
|
||||
|
||||
test('bu', function (t) {
|
||||
t.plan(8);
|
||||
|
||||
// note: can't store -12667700813876161 exactly in an ieee float
|
||||
|
||||
var buf = new Buffer([
|
||||
44, // a == 44
|
||||
2, 43, // b == 555
|
||||
164, 213, 37, 37, // c == 2765432101
|
||||
29, 81, 180, 20, 155, 115, 203, 193, // d == 2112667700813876161
|
||||
]);
|
||||
|
||||
binary.parse(buf)
|
||||
.word8bu('a')
|
||||
.word16bu('b')
|
||||
.word32bu('c')
|
||||
.word64bu('d')
|
||||
.tap(function (vars) {
|
||||
t.same(vars.a, 44);
|
||||
t.same(vars.b, 555);
|
||||
t.same(vars.c, 2765432101);
|
||||
t.ok(
|
||||
Math.abs(vars.d - 2112667700813876161) < 1500
|
||||
);
|
||||
})
|
||||
;
|
||||
|
||||
// also check aliases here:
|
||||
binary.parse(buf)
|
||||
.word8be('a')
|
||||
.word16be('b')
|
||||
.word32be('c')
|
||||
.word64be('d')
|
||||
.tap(function (vars) {
|
||||
t.same(vars.a, 44);
|
||||
t.same(vars.b, 555);
|
||||
t.same(vars.c, 2765432101);
|
||||
t.ok(
|
||||
Math.abs(vars.d - 2112667700813876161) < 1500
|
||||
);
|
||||
})
|
||||
;
|
||||
});
|
20
app/node_modules/binary/test/deferred.js
generated
vendored
20
app/node_modules/binary/test/deferred.js
generated
vendored
|
@ -1,20 +0,0 @@
|
|||
var binary = require('../');
|
||||
var test = require('tap').test;
|
||||
var EventEmitter = require('events').EventEmitter;
|
||||
|
||||
test('deferred', function (t) {
|
||||
t.plan(1);
|
||||
|
||||
var em = new EventEmitter;
|
||||
binary.stream(em)
|
||||
.word8('a')
|
||||
.word16be('bc')
|
||||
.tap(function (vars) {
|
||||
t.same(vars, { a : 97, bc : 25187 });
|
||||
})
|
||||
;
|
||||
|
||||
setTimeout(function () {
|
||||
em.emit('data', new Buffer([ 97, 98, 99 ]));
|
||||
}, 10);
|
||||
});
|
23
app/node_modules/binary/test/dots.js
generated
vendored
23
app/node_modules/binary/test/dots.js
generated
vendored
|
@ -1,23 +0,0 @@
|
|||
var binary = require('../');
|
||||
var test = require('tap').test;
|
||||
|
||||
test('dots', function (t) {
|
||||
t.plan(1);
|
||||
|
||||
binary.parse(new Buffer([ 97, 98, 99, 100, 101, 102 ]))
|
||||
.word8('a')
|
||||
.word16be('b.x')
|
||||
.word16be('b.y')
|
||||
.word8('b.z')
|
||||
.tap(function (vars) {
|
||||
t.same(vars, {
|
||||
a : 97,
|
||||
b : {
|
||||
x : 256 * 98 + 99,
|
||||
y : 256 * 100 + 101,
|
||||
z : 102
|
||||
},
|
||||
});
|
||||
})
|
||||
;
|
||||
});
|
41
app/node_modules/binary/test/eof.js
generated
vendored
41
app/node_modules/binary/test/eof.js
generated
vendored
|
@ -1,41 +0,0 @@
|
|||
var binary = require('../');
|
||||
var test = require('tap').test;
|
||||
var EventEmitter = require('events').EventEmitter;
|
||||
|
||||
test('eof', function (t) {
|
||||
t.plan(4);
|
||||
|
||||
var stream = new EventEmitter;
|
||||
binary.stream(stream)
|
||||
.buffer('sixone', 5)
|
||||
.peek(function () {
|
||||
this.word32le('len');
|
||||
})
|
||||
.buffer('buf', 'len')
|
||||
.word8('x')
|
||||
.tap(function (vars) {
|
||||
t.same(
|
||||
[].slice.call(vars.sixone),
|
||||
[].slice.call(new Buffer([ 6, 1, 6, 1, 6 ]))
|
||||
);
|
||||
t.same(vars.buf.length, vars.len);
|
||||
t.same(
|
||||
[].slice.call(vars.buf),
|
||||
[ 9, 0, 0, 0, 97, 98, 99, 100, 101 ]
|
||||
);
|
||||
t.same(vars.x, 102);
|
||||
})
|
||||
;
|
||||
|
||||
var bufs = [
|
||||
new Buffer([ 6, 1, 6, 1, 6, 9, 0, 0, 0, 97 ]),
|
||||
new Buffer([ 98, 99 ]),
|
||||
new Buffer([ 100, 101, 102 ]),
|
||||
];
|
||||
|
||||
bufs.forEach(function (buf) {
|
||||
stream.emit('data', buf);
|
||||
});
|
||||
|
||||
stream.emit('end');
|
||||
});
|
17
app/node_modules/binary/test/flush.js
generated
vendored
17
app/node_modules/binary/test/flush.js
generated
vendored
|
@ -1,17 +0,0 @@
|
|||
var binary = require('../');
|
||||
var test = require('tap').test;
|
||||
|
||||
test('flush', function (t) {
|
||||
t.plan(1);
|
||||
|
||||
binary.parse(new Buffer([ 97, 98, 99, 100, 101, 102 ]))
|
||||
.word8('a')
|
||||
.word16be('b')
|
||||
.word16be('c')
|
||||
.flush()
|
||||
.word8('d')
|
||||
.tap(function (vars) {
|
||||
t.same(vars, { d : 102 });
|
||||
})
|
||||
;
|
||||
});
|
14
app/node_modules/binary/test/from_buffer.js
generated
vendored
14
app/node_modules/binary/test/from_buffer.js
generated
vendored
|
@ -1,14 +0,0 @@
|
|||
var binary = require('../');
|
||||
var test = require('tap').test;
|
||||
|
||||
test('from buffer', function (t) {
|
||||
t.plan(1);
|
||||
|
||||
binary(new Buffer([ 97, 98, 99 ]))
|
||||
.word8('a')
|
||||
.word16be('bc')
|
||||
.tap(function (vars) {
|
||||
t.same(vars, { a : 97, bc : 25187 });
|
||||
})
|
||||
;
|
||||
});
|
28
app/node_modules/binary/test/get_buffer.js
generated
vendored
28
app/node_modules/binary/test/get_buffer.js
generated
vendored
|
@ -1,28 +0,0 @@
|
|||
var binary = require('../');
|
||||
var test = require('tap').test;
|
||||
|
||||
test('get buffer', function (t) {
|
||||
t.plan(4);
|
||||
|
||||
var buf = new Buffer([ 4, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 ]);
|
||||
binary.parse(buf)
|
||||
.word8('a')
|
||||
.buffer('b', 7)
|
||||
.word16lu('c')
|
||||
.tap(function (vars) {
|
||||
t.equal(vars.a, 4);
|
||||
t.equal(
|
||||
vars.b.toString(),
|
||||
new Buffer([ 2, 3, 4, 5, 6, 7, 8 ]).toString()
|
||||
);
|
||||
t.equal(vars.c, 2569);
|
||||
})
|
||||
.buffer('d', 'a')
|
||||
.tap(function (vars) {
|
||||
t.equal(
|
||||
vars.d.toString(),
|
||||
new Buffer([ 11, 12, 13, 14 ]).toString()
|
||||
);
|
||||
})
|
||||
;
|
||||
});
|
18
app/node_modules/binary/test/immediate.js
generated
vendored
18
app/node_modules/binary/test/immediate.js
generated
vendored
|
@ -1,18 +0,0 @@
|
|||
var binary = require('../');
|
||||
var test = require('tap').test;
|
||||
var EventEmitter = require('events').EventEmitter;
|
||||
|
||||
test('immediate', function (t) {
|
||||
t.plan(1);
|
||||
|
||||
var em = new EventEmitter;
|
||||
binary.stream(em, 'moo')
|
||||
.word8('a')
|
||||
.word16be('bc')
|
||||
.tap(function (vars) {
|
||||
t.same(vars, { a : 97, bc : 25187 });
|
||||
})
|
||||
;
|
||||
|
||||
em.emit('moo', new Buffer([ 97, 98, 99 ]));
|
||||
});
|
38
app/node_modules/binary/test/interval.js
generated
vendored
38
app/node_modules/binary/test/interval.js
generated
vendored
|
@ -1,38 +0,0 @@
|
|||
var binary = require('../');
|
||||
var test = require('tap').test;
|
||||
var EventEmitter = require('events').EventEmitter;
|
||||
|
||||
test('interval', function (t) {
|
||||
t.plan(1);
|
||||
|
||||
var em = new EventEmitter;
|
||||
var i = 0;
|
||||
var iv = setInterval(function () {
|
||||
var buf = new Buffer(1000);
|
||||
buf[0] = 0xff;
|
||||
if (++i >= 1000) {
|
||||
clearInterval(iv);
|
||||
buf[0] = 0;
|
||||
}
|
||||
em.emit('data', buf);
|
||||
}, 1);
|
||||
|
||||
var loops = 0;
|
||||
binary(em)
|
||||
.loop(function (end) {
|
||||
this
|
||||
.word8('x')
|
||||
.word8('y')
|
||||
.word32be('z')
|
||||
.word32le('w')
|
||||
.buffer('buf', 1000 - 10)
|
||||
.tap(function (vars) {
|
||||
loops ++;
|
||||
if (vars.x == 0) end();
|
||||
})
|
||||
})
|
||||
.tap(function () {
|
||||
t.same(loops, 1000);
|
||||
})
|
||||
;
|
||||
});
|
35
app/node_modules/binary/test/into_buffer.js
generated
vendored
35
app/node_modules/binary/test/into_buffer.js
generated
vendored
|
@ -1,35 +0,0 @@
|
|||
var binary = require('../');
|
||||
var test = require('tap').test;
|
||||
|
||||
test('intoBuffer', function (t) {
|
||||
t.plan(3);
|
||||
var buf = new Buffer([ 1, 2, 3, 4, 5, 6 ])
|
||||
|
||||
binary.parse(buf)
|
||||
.into('moo', function () {
|
||||
this
|
||||
.word8('x')
|
||||
.word8('y')
|
||||
.word8('z')
|
||||
;
|
||||
})
|
||||
.tap(function (vars) {
|
||||
t.same(vars, { moo : { x : 1, y : 2, z : 3 } });
|
||||
})
|
||||
.word8('w')
|
||||
.tap(function (vars) {
|
||||
t.same(vars, {
|
||||
moo : { x : 1, y : 2, z : 3 },
|
||||
w : 4,
|
||||
});
|
||||
})
|
||||
.word8('x')
|
||||
.tap(function (vars) {
|
||||
t.same(vars, {
|
||||
moo : { x : 1, y : 2, z : 3 },
|
||||
w : 4,
|
||||
x : 5,
|
||||
});
|
||||
})
|
||||
;
|
||||
});
|
43
app/node_modules/binary/test/into_stream.js
generated
vendored
43
app/node_modules/binary/test/into_stream.js
generated
vendored
|
@ -1,43 +0,0 @@
|
|||
var binary = require('../');
|
||||
var test = require('tap').test;
|
||||
var EventEmitter = require('events').EventEmitter;
|
||||
|
||||
test('into stream', function (t) {
|
||||
t.plan(3);
|
||||
|
||||
var digits = [ 1, 2, 3, 4, 5, 6 ];
|
||||
var stream = new EventEmitter;
|
||||
var iv = setInterval(function () {
|
||||
var d = digits.shift();
|
||||
if (d) stream.emit('data', new Buffer([ d ]))
|
||||
else clearInterval(iv)
|
||||
}, 20);
|
||||
|
||||
binary.stream(stream)
|
||||
.into('moo', function () {
|
||||
this
|
||||
.word8('x')
|
||||
.word8('y')
|
||||
.word8('z')
|
||||
;
|
||||
})
|
||||
.tap(function (vars) {
|
||||
t.same(vars, { moo : { x : 1, y : 2, z : 3 } });
|
||||
})
|
||||
.word8('w')
|
||||
.tap(function (vars) {
|
||||
t.same(vars, {
|
||||
moo : { x : 1, y : 2, z : 3 },
|
||||
w : 4,
|
||||
});
|
||||
})
|
||||
.word8('x')
|
||||
.tap(function (vars) {
|
||||
t.same(vars, {
|
||||
moo : { x : 1, y : 2, z : 3 },
|
||||
w : 4,
|
||||
x : 5,
|
||||
});
|
||||
})
|
||||
;
|
||||
});
|
44
app/node_modules/binary/test/loop.js
generated
vendored
44
app/node_modules/binary/test/loop.js
generated
vendored
|
@ -1,44 +0,0 @@
|
|||
var binary = require('../');
|
||||
var test = require('tap').test;
|
||||
var EventEmitter = require('events').EventEmitter;
|
||||
|
||||
test('loop', function (t) {
|
||||
t.plan(3 * 2 + 1);
|
||||
|
||||
var em = new EventEmitter;
|
||||
|
||||
binary.stream(em)
|
||||
.loop(function (end, vars) {
|
||||
t.strictEqual(vars, this.vars);
|
||||
this
|
||||
.word16lu('a')
|
||||
.word8u('b')
|
||||
.word8s('c')
|
||||
.tap(function (vars_) {
|
||||
t.strictEqual(vars, vars_);
|
||||
if (vars.c < 0) end();
|
||||
})
|
||||
;
|
||||
})
|
||||
.tap(function (vars) {
|
||||
t.same(vars, { a : 1337, b : 55, c : -5 });
|
||||
})
|
||||
;
|
||||
|
||||
setTimeout(function () {
|
||||
em.emit('data', new Buffer([ 2, 10, 88 ]));
|
||||
}, 10);
|
||||
setTimeout(function () {
|
||||
em.emit('data', new Buffer([ 100, 3, 6, 242, 30 ]));
|
||||
}, 20);
|
||||
setTimeout(function () {
|
||||
em.emit('data', new Buffer([ 60, 60, 199, 44 ]));
|
||||
}, 30);
|
||||
|
||||
setTimeout(function () {
|
||||
em.emit('data', new Buffer([ 57, 5 ]));
|
||||
}, 80);
|
||||
setTimeout(function () {
|
||||
em.emit('data', new Buffer([ 55, 251 ]));
|
||||
}, 90);
|
||||
});
|
54
app/node_modules/binary/test/loop_scan.js
generated
vendored
54
app/node_modules/binary/test/loop_scan.js
generated
vendored
|
@ -1,54 +0,0 @@
|
|||
var binary = require('../');
|
||||
var test = require('tap').test;
|
||||
var EventEmitter = require('events').EventEmitter;
|
||||
|
||||
test('loop scan', function (t) {
|
||||
t.plan(8 + 6 + 2);
|
||||
|
||||
var em = new EventEmitter;
|
||||
|
||||
binary.stream(em)
|
||||
.loop(function (end) {
|
||||
var vars_ = this.vars;
|
||||
this
|
||||
.scan('filler', 'BEGINMSG')
|
||||
.buffer('cmd', 3)
|
||||
.word8('num')
|
||||
.tap(function (vars) {
|
||||
t.strictEqual(vars, vars_);
|
||||
if (vars.num != 0x02 && vars.num != 0x06) {
|
||||
t.same(vars.filler.length, 0);
|
||||
}
|
||||
if (vars.cmd.toString() == 'end') end();
|
||||
})
|
||||
;
|
||||
})
|
||||
.tap(function (vars) {
|
||||
t.same(vars.cmd.toString(), 'end');
|
||||
t.same(vars.num, 0x08);
|
||||
})
|
||||
;
|
||||
|
||||
setTimeout(function () {
|
||||
em.emit('data', new Buffer(
|
||||
'BEGINMSGcmd\x01'
|
||||
+ 'GARBAGEDATAXXXX'
|
||||
+ 'BEGINMSGcmd\x02'
|
||||
+ 'BEGINMSGcmd\x03'
|
||||
));
|
||||
}, 10);
|
||||
|
||||
setTimeout(function () {
|
||||
em.emit('data', new Buffer(
|
||||
'BEGINMSGcmd\x04'
|
||||
+ 'BEGINMSGcmd\x05'
|
||||
+ 'GARBAGEDATAXXXX'
|
||||
+ 'BEGINMSGcmd\x06'
|
||||
));
|
||||
em.emit('data', new Buffer('BEGINMSGcmd\x07'));
|
||||
}, 20);
|
||||
|
||||
setTimeout(function () {
|
||||
em.emit('data', new Buffer('BEGINMSGend\x08'));
|
||||
}, 30);
|
||||
});
|
46
app/node_modules/binary/test/lu.js
generated
vendored
46
app/node_modules/binary/test/lu.js
generated
vendored
|
@ -1,46 +0,0 @@
|
|||
var binary = require('../');
|
||||
var test = require('tap').test;
|
||||
|
||||
test('lu', function (t) {
|
||||
t.plan(8);
|
||||
|
||||
// note: can't store -12667700813876161 exactly in an ieee float
|
||||
|
||||
var buf = new Buffer([
|
||||
44, // a == 44
|
||||
43, 2, // b == 555
|
||||
37, 37, 213, 164, // c == 2765432101
|
||||
193, 203, 115, 155, 20, 180, 81, 29, // d == 2112667700813876161
|
||||
]);
|
||||
|
||||
binary.parse(buf)
|
||||
.word8lu('a')
|
||||
.word16lu('b')
|
||||
.word32lu('c')
|
||||
.word64lu('d')
|
||||
.tap(function (vars) {
|
||||
t.same(vars.a, 44);
|
||||
t.same(vars.b, 555);
|
||||
t.same(vars.c, 2765432101);
|
||||
t.ok(
|
||||
Math.abs(vars.d - 2112667700813876161) < 1500
|
||||
);
|
||||
})
|
||||
;
|
||||
|
||||
// also check aliases here:
|
||||
binary.parse(buf)
|
||||
.word8le('a')
|
||||
.word16le('b')
|
||||
.word32le('c')
|
||||
.word64le('d')
|
||||
.tap(function (vars) {
|
||||
t.same(vars.a, 44);
|
||||
t.same(vars.b, 555);
|
||||
t.same(vars.c, 2765432101);
|
||||
t.ok(
|
||||
Math.abs(vars.d - 2112667700813876161) < 1500
|
||||
);
|
||||
})
|
||||
;
|
||||
});
|
29
app/node_modules/binary/test/negbs.js
generated
vendored
29
app/node_modules/binary/test/negbs.js
generated
vendored
|
@ -1,29 +0,0 @@
|
|||
var binary = require('../');
|
||||
var test = require('tap').test;
|
||||
|
||||
test('negbs', function (t) {
|
||||
t.plan(4);
|
||||
// note: can't store -12667700813876161 exactly in an ieee float
|
||||
|
||||
var buf = new Buffer([
|
||||
226, // a == -30
|
||||
246, 219, // b == -2341
|
||||
255, 243, 245, 236, // c == -789012
|
||||
255, 210, 254, 203, 16, 222, 52, 63, // d == -12667700813876161
|
||||
]);
|
||||
|
||||
binary.parse(buf)
|
||||
.word8bs('a')
|
||||
.word16bs('b')
|
||||
.word32bs('c')
|
||||
.word64bs('d')
|
||||
.tap(function (vars) {
|
||||
t.same(vars.a, -30);
|
||||
t.same(vars.b, -2341);
|
||||
t.same(vars.c, -789012);
|
||||
t.ok(
|
||||
Math.abs(vars.d - -12667700813876161) < 1500
|
||||
);
|
||||
})
|
||||
;
|
||||
});
|
29
app/node_modules/binary/test/negls.js
generated
vendored
29
app/node_modules/binary/test/negls.js
generated
vendored
|
@ -1,29 +0,0 @@
|
|||
var binary = require('../');
|
||||
var test = require('tap').test;
|
||||
|
||||
test('negls', function (t) {
|
||||
t.plan(4);
|
||||
// note: can't store -12667700813876161 exactly in an ieee float
|
||||
|
||||
var buf = new Buffer([
|
||||
226, // a == -30
|
||||
219, 246, // b == -2341
|
||||
236, 245, 243, 255, // c == -789012
|
||||
63, 52, 222, 16, 203, 254, 210, 255, // d == -12667700813876161
|
||||
]);
|
||||
|
||||
binary.parse(buf)
|
||||
.word8ls('a')
|
||||
.word16ls('b')
|
||||
.word32ls('c')
|
||||
.word64ls('d')
|
||||
.tap(function (vars) {
|
||||
t.same(vars.a, -30);
|
||||
t.same(vars.b, -2341);
|
||||
t.same(vars.c, -789012);
|
||||
t.ok(
|
||||
Math.abs(vars.d - -12667700813876161) < 1000
|
||||
);
|
||||
})
|
||||
;
|
||||
});
|
35
app/node_modules/binary/test/nested.js
generated
vendored
35
app/node_modules/binary/test/nested.js
generated
vendored
|
@ -1,35 +0,0 @@
|
|||
var binary = require('../');
|
||||
var test = require('tap').test;
|
||||
var EventEmitter = require('events').EventEmitter;
|
||||
|
||||
test('nested', function (t) {
|
||||
t.plan(3);
|
||||
var insideDone = false;
|
||||
|
||||
var em = new EventEmitter;
|
||||
binary.stream(em)
|
||||
.word16be('ab')
|
||||
.tap(function () {
|
||||
this
|
||||
.word8('c')
|
||||
.word8('d')
|
||||
.tap(function () {
|
||||
insideDone = true;
|
||||
})
|
||||
;
|
||||
})
|
||||
.tap(function (vars) {
|
||||
t.ok(insideDone);
|
||||
t.same(vars.c, 'c'.charCodeAt(0));
|
||||
t.same(vars.d, 'd'.charCodeAt(0));
|
||||
|
||||
})
|
||||
;
|
||||
|
||||
var strs = [ 'abc', 'def', 'hi', 'jkl' ];
|
||||
var iv = setInterval(function () {
|
||||
var s = strs.shift();
|
||||
if (s) em.emit('data', new Buffer(s));
|
||||
else clearInterval(iv);
|
||||
}, 50);
|
||||
});
|
17
app/node_modules/binary/test/not_enough_buf.js
generated
vendored
17
app/node_modules/binary/test/not_enough_buf.js
generated
vendored
|
@ -1,17 +0,0 @@
|
|||
var binary = require('../');
|
||||
var test = require('tap').test;
|
||||
|
||||
test('not enough buf', function (t) {
|
||||
t.plan(3);
|
||||
|
||||
var vars = binary(new Buffer([1,2,3,4]))
|
||||
.word8('a')
|
||||
.buffer('b', 10)
|
||||
.word8('c')
|
||||
.vars
|
||||
;
|
||||
|
||||
t.same(vars.a, 1);
|
||||
t.equal(vars.b.toString(), new Buffer([2,3,4]).toString());
|
||||
t.strictEqual(vars.c, null);
|
||||
});
|
19
app/node_modules/binary/test/not_enough_parse.js
generated
vendored
19
app/node_modules/binary/test/not_enough_parse.js
generated
vendored
|
@ -1,19 +0,0 @@
|
|||
var binary = require('../');
|
||||
var test = require('tap').test;
|
||||
|
||||
test('not enough parse', function (t) {
|
||||
t.plan(4);
|
||||
|
||||
var vars = binary(new Buffer([1,2]))
|
||||
.word8('a')
|
||||
.word8('b')
|
||||
.word8('c')
|
||||
.word8('d')
|
||||
.vars
|
||||
;
|
||||
|
||||
t.same(vars.a, 1);
|
||||
t.same(vars.b, 2);
|
||||
t.strictEqual(vars.c, null);
|
||||
t.strictEqual(vars.d, null);
|
||||
});
|
54
app/node_modules/binary/test/parse.js
generated
vendored
54
app/node_modules/binary/test/parse.js
generated
vendored
|
@ -1,54 +0,0 @@
|
|||
var binary = require('../');
|
||||
var test = require('tap').test;
|
||||
|
||||
test('parse', function (t) {
|
||||
t.plan(6);
|
||||
var res = binary.parse(new Buffer([ 97, 98, 99, 99, 99, 99, 1, 2, 3 ]))
|
||||
.word8('a')
|
||||
.word16be('bc')
|
||||
.skip(3)
|
||||
.buffer('def', 3)
|
||||
.tap(function (vars) {
|
||||
t.equal(vars.a, 97);
|
||||
t.equal(vars.bc, 25187);
|
||||
t.same(
|
||||
[].slice.call(vars.def),
|
||||
[].slice.call(new Buffer([ 1, 2, 3]))
|
||||
);
|
||||
})
|
||||
.vars
|
||||
;
|
||||
t.equal(res.a, 97);
|
||||
t.equal(res.bc, 25187);
|
||||
t.same(
|
||||
[].slice.call(res.def),
|
||||
[].slice.call(new Buffer([ 1, 2, 3 ]))
|
||||
);
|
||||
});
|
||||
|
||||
test('loop', function (t) {
|
||||
t.plan(2);
|
||||
var res = binary.parse(new Buffer([ 97, 98, 99, 4, 5, 2, -3, 9 ]))
|
||||
.word8('a')
|
||||
.word16be('bc')
|
||||
.loop(function (end) {
|
||||
var x = this.word8s('x').vars.x;
|
||||
if (x < 0) end();
|
||||
})
|
||||
.tap(function (vars) {
|
||||
t.same(vars, {
|
||||
a : 97,
|
||||
bc : 25187,
|
||||
x : -3,
|
||||
});
|
||||
})
|
||||
.word8('y')
|
||||
.vars
|
||||
;
|
||||
t.same(res, {
|
||||
a : 97,
|
||||
bc : 25187,
|
||||
x : -3,
|
||||
y : 9,
|
||||
});
|
||||
});
|
40
app/node_modules/binary/test/peek.js
generated
vendored
40
app/node_modules/binary/test/peek.js
generated
vendored
|
@ -1,40 +0,0 @@
|
|||
var binary = require('../');
|
||||
var test = require('tap').test;
|
||||
var EventEmitter = require('events').EventEmitter;
|
||||
|
||||
test('peek', function (t) {
|
||||
t.plan(4);
|
||||
var bufs = [
|
||||
new Buffer([ 6, 1, 6, 1, 6, 9, 0, 0, 0, 97 ]),
|
||||
new Buffer([ 98, 99 ]),
|
||||
new Buffer([ 100, 101, 102 ]),
|
||||
];
|
||||
|
||||
var stream = new EventEmitter;
|
||||
var iv = setInterval(function () {
|
||||
var buf = bufs.shift();
|
||||
if (buf) stream.emit('data', buf)
|
||||
else clearInterval(iv)
|
||||
}, 20);
|
||||
|
||||
binary.stream(stream)
|
||||
.buffer('sixone', 5)
|
||||
.peek(function () {
|
||||
this.word32le('len');
|
||||
})
|
||||
.buffer('buf', 'len')
|
||||
.word8('x')
|
||||
.tap(function (vars) {
|
||||
t.same(
|
||||
[].slice.call(vars.sixone),
|
||||
[].slice.call(new Buffer([ 6, 1, 6, 1, 6 ]))
|
||||
);
|
||||
t.same(vars.buf.length, vars.len);
|
||||
t.same(
|
||||
[].slice.call(vars.buf),
|
||||
[ 9, 0, 0, 0, 97, 98, 99, 100, 101 ]
|
||||
);
|
||||
t.same(vars.x, 102);
|
||||
})
|
||||
;
|
||||
});
|
49
app/node_modules/binary/test/pipe.js
generated
vendored
49
app/node_modules/binary/test/pipe.js
generated
vendored
|
@ -1,49 +0,0 @@
|
|||
var binary = require('../');
|
||||
var test = require('tap').test;
|
||||
var Stream = require('stream').Stream;
|
||||
|
||||
test('loop', function (t) {
|
||||
t.plan(3 * 2 + 1);
|
||||
|
||||
var rs = new Stream;
|
||||
rs.readable = true;
|
||||
|
||||
var ws = binary()
|
||||
.loop(function (end, vars) {
|
||||
t.strictEqual(vars, this.vars);
|
||||
this
|
||||
.word16lu('a')
|
||||
.word8u('b')
|
||||
.word8s('c')
|
||||
.tap(function (vars_) {
|
||||
t.strictEqual(vars, vars_);
|
||||
if (vars.c < 0) end();
|
||||
})
|
||||
;
|
||||
})
|
||||
.tap(function (vars) {
|
||||
t.same(vars, { a : 1337, b : 55, c : -5 });
|
||||
})
|
||||
;
|
||||
rs.pipe(ws);
|
||||
|
||||
setTimeout(function () {
|
||||
rs.emit('data', new Buffer([ 2, 10, 88 ]));
|
||||
}, 10);
|
||||
setTimeout(function () {
|
||||
rs.emit('data', new Buffer([ 100, 3, 6, 242, 30 ]));
|
||||
}, 20);
|
||||
setTimeout(function () {
|
||||
rs.emit('data', new Buffer([ 60, 60, 199, 44 ]));
|
||||
}, 30);
|
||||
|
||||
setTimeout(function () {
|
||||
rs.emit('data', new Buffer([ 57, 5 ]));
|
||||
}, 80);
|
||||
setTimeout(function () {
|
||||
rs.emit('data', new Buffer([ 55, 251 ]));
|
||||
}, 90);
|
||||
setTimeout(function () {
|
||||
rs.emit('end');
|
||||
}, 100);
|
||||
});
|
29
app/node_modules/binary/test/posbs.js
generated
vendored
29
app/node_modules/binary/test/posbs.js
generated
vendored
|
@ -1,29 +0,0 @@
|
|||
var binary = require('../');
|
||||
var test = require('tap').test;
|
||||
|
||||
test('posbs', function (t) {
|
||||
t.plan(4);
|
||||
// note: can't store 12667700813876161 exactly in an ieee float
|
||||
|
||||
var buf = new Buffer([
|
||||
30, // a == -30
|
||||
9, 37, // b == -2341
|
||||
0, 12, 10, 20, // c == -789012
|
||||
0, 45, 1, 52, 239, 33, 203, 193, // d == 12667700813876161
|
||||
]);
|
||||
|
||||
binary.parse(buf)
|
||||
.word8bs('a')
|
||||
.word16bs('b')
|
||||
.word32bs('c')
|
||||
.word64bs('d')
|
||||
.tap(function (vars) {
|
||||
t.same(vars.a, 30);
|
||||
t.same(vars.b, 2341);
|
||||
t.same(vars.c, 789012);
|
||||
t.ok(
|
||||
Math.abs(vars.d - 12667700813876161) < 1000
|
||||
);
|
||||
})
|
||||
;
|
||||
});
|
29
app/node_modules/binary/test/posls.js
generated
vendored
29
app/node_modules/binary/test/posls.js
generated
vendored
|
@ -1,29 +0,0 @@
|
|||
var binary = require('../');
|
||||
var test = require('tap').test;
|
||||
|
||||
test('posls', function (t) {
|
||||
t.plan(4);
|
||||
|
||||
// note: can't store 12667700813876161 exactly in an ieee float
|
||||
var buf = new Buffer([
|
||||
30, // a == -30
|
||||
37, 9, // b == -2341
|
||||
20, 10, 12, 0, // c == -789012
|
||||
193, 203, 33, 239, 52, 1, 45, 0, // d == 12667700813876161
|
||||
]);
|
||||
|
||||
binary.parse(buf)
|
||||
.word8ls('a')
|
||||
.word16ls('b')
|
||||
.word32ls('c')
|
||||
.word64ls('d')
|
||||
.tap(function (vars) {
|
||||
t.same(vars.a, 30);
|
||||
t.same(vars.b, 2341);
|
||||
t.same(vars.c, 789012);
|
||||
t.ok(
|
||||
Math.abs(vars.d - 12667700813876161) < 1000
|
||||
);
|
||||
})
|
||||
;
|
||||
});
|
33
app/node_modules/binary/test/scan.js
generated
vendored
33
app/node_modules/binary/test/scan.js
generated
vendored
|
@ -1,33 +0,0 @@
|
|||
var binary = require('../');
|
||||
var test = require('tap').test;
|
||||
var EventEmitter = require('events').EventEmitter;
|
||||
|
||||
test('scan', function (t) {
|
||||
t.plan(4);
|
||||
|
||||
var em = new EventEmitter;
|
||||
binary(em)
|
||||
.word8('a')
|
||||
.scan('l1', new Buffer('\r\n'))
|
||||
.scan('l2', '\r\n')
|
||||
.word8('z')
|
||||
.tap(function (vars) {
|
||||
t.same(vars.a, 99);
|
||||
t.same(vars.l1.toString(), 'foo bar');
|
||||
t.same(vars.l2.toString(), 'baz');
|
||||
t.same(vars.z, 42);
|
||||
})
|
||||
;
|
||||
|
||||
setTimeout(function () {
|
||||
em.emit('data', new Buffer([99,0x66,0x6f,0x6f,0x20]));
|
||||
}, 20);
|
||||
|
||||
setTimeout(function () {
|
||||
em.emit('data', new Buffer('bar\r'));
|
||||
}, 40);
|
||||
|
||||
setTimeout(function () {
|
||||
em.emit('data', new Buffer('\nbaz\r\n*'));
|
||||
}, 60);
|
||||
});
|
18
app/node_modules/binary/test/scan_buf.js
generated
vendored
18
app/node_modules/binary/test/scan_buf.js
generated
vendored
|
@ -1,18 +0,0 @@
|
|||
var binary = require('../');
|
||||
var test = require('tap').test;
|
||||
|
||||
test('scan buf', function (t) {
|
||||
t.plan(4);
|
||||
|
||||
var vars = binary(new Buffer('\x63foo bar\r\nbaz\r\n*'))
|
||||
.word8('a')
|
||||
.scan('l1', new Buffer('\r\n'))
|
||||
.scan('l2', '\r\n')
|
||||
.word8('z')
|
||||
.vars
|
||||
;
|
||||
t.same(vars.a, 99);
|
||||
t.same(vars.z, 42);
|
||||
t.same(vars.l1.toString(), 'foo bar');
|
||||
t.same(vars.l2.toString(), 'baz');
|
||||
});
|
16
app/node_modules/binary/test/scan_buf_null.js
generated
vendored
16
app/node_modules/binary/test/scan_buf_null.js
generated
vendored
|
@ -1,16 +0,0 @@
|
|||
var binary = require('../');
|
||||
var test = require('tap').test;
|
||||
|
||||
test('scan buf null', function (t) {
|
||||
t.plan(3);
|
||||
var vars = binary(new Buffer('\x63foo bar baz'))
|
||||
.word8('a')
|
||||
.scan('b', '\r\n')
|
||||
.word8('c')
|
||||
.vars
|
||||
;
|
||||
|
||||
t.same(vars.a, 99);
|
||||
t.same(vars.b.toString(), 'foo bar baz');
|
||||
t.strictEqual(vars.c, null);
|
||||
});
|
58
app/node_modules/binary/test/skip.js
generated
vendored
58
app/node_modules/binary/test/skip.js
generated
vendored
|
@ -1,58 +0,0 @@
|
|||
var binary = require('../');
|
||||
var test = require('tap').test;
|
||||
var EventEmitter = require('events').EventEmitter;
|
||||
var seq = require('seq');
|
||||
|
||||
test('skip', function (t) {
|
||||
t.plan(7);
|
||||
var em = new EventEmitter;
|
||||
var state = 0;
|
||||
|
||||
binary(em)
|
||||
.word16lu('a')
|
||||
.tap(function () { state = 1 })
|
||||
.skip(7)
|
||||
.tap(function () { state = 2 })
|
||||
.word8('b')
|
||||
.tap(function () { state = 3 })
|
||||
.tap(function (vars) {
|
||||
t.same(state, 3);
|
||||
t.same(vars, {
|
||||
a : 2569,
|
||||
b : 8,
|
||||
});
|
||||
})
|
||||
;
|
||||
|
||||
seq()
|
||||
.seq(setTimeout, seq, 20)
|
||||
.seq(function () {
|
||||
t.same(state, 0);
|
||||
em.emit('data', new Buffer([ 9 ]));
|
||||
this(null);
|
||||
})
|
||||
.seq(setTimeout, seq, 5)
|
||||
.seq(function () {
|
||||
t.same(state, 0);
|
||||
em.emit('data', new Buffer([ 10, 1, 2 ]));
|
||||
this(null);
|
||||
})
|
||||
.seq(setTimeout, seq, 30)
|
||||
.seq(function () {
|
||||
t.same(state, 1);
|
||||
em.emit('data', new Buffer([ 3, 4, 5 ]));
|
||||
this(null);
|
||||
})
|
||||
.seq(setTimeout, seq, 15)
|
||||
.seq(function () {
|
||||
t.same(state, 1);
|
||||
em.emit('data', new Buffer([ 6, 7 ]));
|
||||
this(null);
|
||||
})
|
||||
.seq(function () {
|
||||
t.same(state, 2);
|
||||
em.emit('data', new Buffer([ 8 ]));
|
||||
this(null);
|
||||
})
|
||||
;
|
||||
});
|
34
app/node_modules/binary/test/split.js
generated
vendored
34
app/node_modules/binary/test/split.js
generated
vendored
|
@ -1,34 +0,0 @@
|
|||
var binary = require('../');
|
||||
var test = require('tap').test;
|
||||
var EventEmitter = require('events').EventEmitter;
|
||||
|
||||
test('split', function (t) {
|
||||
t.plan(1);
|
||||
|
||||
var em = new EventEmitter;
|
||||
binary.stream(em)
|
||||
.word8('a')
|
||||
.word16be('bc')
|
||||
.word32ls('x')
|
||||
.word32bs('y')
|
||||
.tap(function (vars) {
|
||||
t.same(vars, {
|
||||
a : 97,
|
||||
bc : 25187,
|
||||
x : 621609828,
|
||||
y : 621609828,
|
||||
});
|
||||
})
|
||||
;
|
||||
|
||||
em.emit('data', new Buffer([ 97, 98 ]));
|
||||
setTimeout(function () {
|
||||
em.emit('data', new Buffer([ 99, 100 ]));
|
||||
}, 25);
|
||||
setTimeout(function () {
|
||||
em.emit('data', new Buffer([ 3, 13, 37, 37 ]));
|
||||
}, 30);
|
||||
setTimeout(function () {
|
||||
em.emit('data', new Buffer([ 13, 3, 100 ]));
|
||||
}, 40);
|
||||
});
|
129
app/node_modules/brace-expansion/README.md
generated
vendored
129
app/node_modules/brace-expansion/README.md
generated
vendored
|
@ -1,129 +0,0 @@
|
|||
# brace-expansion
|
||||
|
||||
[Brace expansion](https://www.gnu.org/software/bash/manual/html_node/Brace-Expansion.html),
|
||||
as known from sh/bash, in JavaScript.
|
||||
|
||||
[![build status](https://secure.travis-ci.org/juliangruber/brace-expansion.svg)](http://travis-ci.org/juliangruber/brace-expansion)
|
||||
[![downloads](https://img.shields.io/npm/dm/brace-expansion.svg)](https://www.npmjs.org/package/brace-expansion)
|
||||
[![Greenkeeper badge](https://badges.greenkeeper.io/juliangruber/brace-expansion.svg)](https://greenkeeper.io/)
|
||||
|
||||
[![testling badge](https://ci.testling.com/juliangruber/brace-expansion.png)](https://ci.testling.com/juliangruber/brace-expansion)
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
var expand = require('brace-expansion');
|
||||
|
||||
expand('file-{a,b,c}.jpg')
|
||||
// => ['file-a.jpg', 'file-b.jpg', 'file-c.jpg']
|
||||
|
||||
expand('-v{,,}')
|
||||
// => ['-v', '-v', '-v']
|
||||
|
||||
expand('file{0..2}.jpg')
|
||||
// => ['file0.jpg', 'file1.jpg', 'file2.jpg']
|
||||
|
||||
expand('file-{a..c}.jpg')
|
||||
// => ['file-a.jpg', 'file-b.jpg', 'file-c.jpg']
|
||||
|
||||
expand('file{2..0}.jpg')
|
||||
// => ['file2.jpg', 'file1.jpg', 'file0.jpg']
|
||||
|
||||
expand('file{0..4..2}.jpg')
|
||||
// => ['file0.jpg', 'file2.jpg', 'file4.jpg']
|
||||
|
||||
expand('file-{a..e..2}.jpg')
|
||||
// => ['file-a.jpg', 'file-c.jpg', 'file-e.jpg']
|
||||
|
||||
expand('file{00..10..5}.jpg')
|
||||
// => ['file00.jpg', 'file05.jpg', 'file10.jpg']
|
||||
|
||||
expand('{{A..C},{a..c}}')
|
||||
// => ['A', 'B', 'C', 'a', 'b', 'c']
|
||||
|
||||
expand('ppp{,config,oe{,conf}}')
|
||||
// => ['ppp', 'pppconfig', 'pppoe', 'pppoeconf']
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
```js
|
||||
var expand = require('brace-expansion');
|
||||
```
|
||||
|
||||
### var expanded = expand(str)
|
||||
|
||||
Return an array of all possible and valid expansions of `str`. If none are
|
||||
found, `[str]` is returned.
|
||||
|
||||
Valid expansions are:
|
||||
|
||||
```js
|
||||
/^(.*,)+(.+)?$/
|
||||
// {a,b,...}
|
||||
```
|
||||
|
||||
A comma separated list of options, like `{a,b}` or `{a,{b,c}}` or `{,a,}`.
|
||||
|
||||
```js
|
||||
/^-?\d+\.\.-?\d+(\.\.-?\d+)?$/
|
||||
// {x..y[..incr]}
|
||||
```
|
||||
|
||||
A numeric sequence from `x` to `y` inclusive, with optional increment.
|
||||
If `x` or `y` start with a leading `0`, all the numbers will be padded
|
||||
to have equal length. Negative numbers and backwards iteration work too.
|
||||
|
||||
```js
|
||||
/^-?\d+\.\.-?\d+(\.\.-?\d+)?$/
|
||||
// {x..y[..incr]}
|
||||
```
|
||||
|
||||
An alphabetic sequence from `x` to `y` inclusive, with optional increment.
|
||||
`x` and `y` must be exactly one character, and if given, `incr` must be a
|
||||
number.
|
||||
|
||||
For compatibility reasons, the string `${` is not eligible for brace expansion.
|
||||
|
||||
## Installation
|
||||
|
||||
With [npm](https://npmjs.org) do:
|
||||
|
||||
```bash
|
||||
npm install brace-expansion
|
||||
```
|
||||
|
||||
## Contributors
|
||||
|
||||
- [Julian Gruber](https://github.com/juliangruber)
|
||||
- [Isaac Z. Schlueter](https://github.com/isaacs)
|
||||
|
||||
## Sponsors
|
||||
|
||||
This module is proudly supported by my [Sponsors](https://github.com/juliangruber/sponsors)!
|
||||
|
||||
Do you want to support modules like this to improve their quality, stability and weigh in on new features? Then please consider donating to my [Patreon](https://www.patreon.com/juliangruber). Not sure how much of my modules you're using? Try [feross/thanks](https://github.com/feross/thanks)!
|
||||
|
||||
## 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.
|
201
app/node_modules/brace-expansion/index.js
generated
vendored
201
app/node_modules/brace-expansion/index.js
generated
vendored
|
@ -1,201 +0,0 @@
|
|||
var concatMap = require('concat-map');
|
||||
var balanced = require('balanced-match');
|
||||
|
||||
module.exports = expandTop;
|
||||
|
||||
var escSlash = '\0SLASH'+Math.random()+'\0';
|
||||
var escOpen = '\0OPEN'+Math.random()+'\0';
|
||||
var escClose = '\0CLOSE'+Math.random()+'\0';
|
||||
var escComma = '\0COMMA'+Math.random()+'\0';
|
||||
var escPeriod = '\0PERIOD'+Math.random()+'\0';
|
||||
|
||||
function numeric(str) {
|
||||
return parseInt(str, 10) == str
|
||||
? parseInt(str, 10)
|
||||
: str.charCodeAt(0);
|
||||
}
|
||||
|
||||
function escapeBraces(str) {
|
||||
return str.split('\\\\').join(escSlash)
|
||||
.split('\\{').join(escOpen)
|
||||
.split('\\}').join(escClose)
|
||||
.split('\\,').join(escComma)
|
||||
.split('\\.').join(escPeriod);
|
||||
}
|
||||
|
||||
function unescapeBraces(str) {
|
||||
return str.split(escSlash).join('\\')
|
||||
.split(escOpen).join('{')
|
||||
.split(escClose).join('}')
|
||||
.split(escComma).join(',')
|
||||
.split(escPeriod).join('.');
|
||||
}
|
||||
|
||||
|
||||
// Basically just str.split(","), but handling cases
|
||||
// where we have nested braced sections, which should be
|
||||
// treated as individual members, like {a,{b,c},d}
|
||||
function parseCommaParts(str) {
|
||||
if (!str)
|
||||
return [''];
|
||||
|
||||
var parts = [];
|
||||
var m = balanced('{', '}', str);
|
||||
|
||||
if (!m)
|
||||
return str.split(',');
|
||||
|
||||
var pre = m.pre;
|
||||
var body = m.body;
|
||||
var post = m.post;
|
||||
var p = pre.split(',');
|
||||
|
||||
p[p.length-1] += '{' + body + '}';
|
||||
var postParts = parseCommaParts(post);
|
||||
if (post.length) {
|
||||
p[p.length-1] += postParts.shift();
|
||||
p.push.apply(p, postParts);
|
||||
}
|
||||
|
||||
parts.push.apply(parts, p);
|
||||
|
||||
return parts;
|
||||
}
|
||||
|
||||
function expandTop(str) {
|
||||
if (!str)
|
||||
return [];
|
||||
|
||||
// I don't know why Bash 4.3 does this, but it does.
|
||||
// Anything starting with {} will have the first two bytes preserved
|
||||
// but *only* at the top level, so {},a}b will not expand to anything,
|
||||
// but a{},b}c will be expanded to [a}c,abc].
|
||||
// One could argue that this is a bug in Bash, but since the goal of
|
||||
// this module is to match Bash's rules, we escape a leading {}
|
||||
if (str.substr(0, 2) === '{}') {
|
||||
str = '\\{\\}' + str.substr(2);
|
||||
}
|
||||
|
||||
return expand(escapeBraces(str), true).map(unescapeBraces);
|
||||
}
|
||||
|
||||
function identity(e) {
|
||||
return e;
|
||||
}
|
||||
|
||||
function embrace(str) {
|
||||
return '{' + str + '}';
|
||||
}
|
||||
function isPadded(el) {
|
||||
return /^-?0\d/.test(el);
|
||||
}
|
||||
|
||||
function lte(i, y) {
|
||||
return i <= y;
|
||||
}
|
||||
function gte(i, y) {
|
||||
return i >= y;
|
||||
}
|
||||
|
||||
function expand(str, isTop) {
|
||||
var expansions = [];
|
||||
|
||||
var m = balanced('{', '}', str);
|
||||
if (!m || /\$$/.test(m.pre)) return [str];
|
||||
|
||||
var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
|
||||
var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
|
||||
var isSequence = isNumericSequence || isAlphaSequence;
|
||||
var isOptions = m.body.indexOf(',') >= 0;
|
||||
if (!isSequence && !isOptions) {
|
||||
// {a},b}
|
||||
if (m.post.match(/,.*\}/)) {
|
||||
str = m.pre + '{' + m.body + escClose + m.post;
|
||||
return expand(str);
|
||||
}
|
||||
return [str];
|
||||
}
|
||||
|
||||
var n;
|
||||
if (isSequence) {
|
||||
n = m.body.split(/\.\./);
|
||||
} else {
|
||||
n = parseCommaParts(m.body);
|
||||
if (n.length === 1) {
|
||||
// x{{a,b}}y ==> x{a}y x{b}y
|
||||
n = expand(n[0], false).map(embrace);
|
||||
if (n.length === 1) {
|
||||
var post = m.post.length
|
||||
? expand(m.post, false)
|
||||
: [''];
|
||||
return post.map(function(p) {
|
||||
return m.pre + n[0] + p;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// at this point, n is the parts, and we know it's not a comma set
|
||||
// with a single entry.
|
||||
|
||||
// no need to expand pre, since it is guaranteed to be free of brace-sets
|
||||
var pre = m.pre;
|
||||
var post = m.post.length
|
||||
? expand(m.post, false)
|
||||
: [''];
|
||||
|
||||
var N;
|
||||
|
||||
if (isSequence) {
|
||||
var x = numeric(n[0]);
|
||||
var y = numeric(n[1]);
|
||||
var width = Math.max(n[0].length, n[1].length)
|
||||
var incr = n.length == 3
|
||||
? Math.abs(numeric(n[2]))
|
||||
: 1;
|
||||
var test = lte;
|
||||
var reverse = y < x;
|
||||
if (reverse) {
|
||||
incr *= -1;
|
||||
test = gte;
|
||||
}
|
||||
var pad = n.some(isPadded);
|
||||
|
||||
N = [];
|
||||
|
||||
for (var i = x; test(i, y); i += incr) {
|
||||
var c;
|
||||
if (isAlphaSequence) {
|
||||
c = String.fromCharCode(i);
|
||||
if (c === '\\')
|
||||
c = '';
|
||||
} else {
|
||||
c = String(i);
|
||||
if (pad) {
|
||||
var need = width - c.length;
|
||||
if (need > 0) {
|
||||
var z = new Array(need + 1).join('0');
|
||||
if (i < 0)
|
||||
c = '-' + z + c.slice(1);
|
||||
else
|
||||
c = z + c;
|
||||
}
|
||||
}
|
||||
}
|
||||
N.push(c);
|
||||
}
|
||||
} else {
|
||||
N = concatMap(n, function(el) { return expand(el, false) });
|
||||
}
|
||||
|
||||
for (var j = 0; j < N.length; j++) {
|
||||
for (var k = 0; k < post.length; k++) {
|
||||
var expansion = pre + N[j] + post[k];
|
||||
if (!isTop || isSequence || expansion)
|
||||
expansions.push(expansion);
|
||||
}
|
||||
}
|
||||
|
||||
return expansions;
|
||||
}
|
||||
|
117
app/node_modules/brace-expansion/package.json
generated
vendored
117
app/node_modules/brace-expansion/package.json
generated
vendored
|
@ -1,117 +0,0 @@
|
|||
{
|
||||
"_args": [
|
||||
[
|
||||
{
|
||||
"raw": "brace-expansion@^1.1.7",
|
||||
"scope": null,
|
||||
"escapedName": "brace-expansion",
|
||||
"name": "brace-expansion",
|
||||
"rawSpec": "^1.1.7",
|
||||
"spec": ">=1.1.7 <2.0.0",
|
||||
"type": "range"
|
||||
},
|
||||
"C:\\Users\\ryuki\\TheDesk\\app\\node_modules\\minimatch"
|
||||
]
|
||||
],
|
||||
"_from": "brace-expansion@>=1.1.7 <2.0.0",
|
||||
"_id": "brace-expansion@1.1.11",
|
||||
"_inCache": true,
|
||||
"_location": "/brace-expansion",
|
||||
"_nodeVersion": "9.0.0",
|
||||
"_npmOperationalInternal": {
|
||||
"host": "s3://npm-registry-packages",
|
||||
"tmp": "tmp/brace-expansion_1.1.11_1518248541320_0.33962849281003904"
|
||||
},
|
||||
"_npmUser": {
|
||||
"name": "juliangruber",
|
||||
"email": "julian@juliangruber.com"
|
||||
},
|
||||
"_npmVersion": "5.5.1",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"raw": "brace-expansion@^1.1.7",
|
||||
"scope": null,
|
||||
"escapedName": "brace-expansion",
|
||||
"name": "brace-expansion",
|
||||
"rawSpec": "^1.1.7",
|
||||
"spec": ">=1.1.7 <2.0.0",
|
||||
"type": "range"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/minimatch"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
|
||||
"_shasum": "3c7fcbf529d87226f3d2f52b966ff5271eb441dd",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "brace-expansion@^1.1.7",
|
||||
"_where": "C:\\Users\\ryuki\\TheDesk\\app\\node_modules\\minimatch",
|
||||
"author": {
|
||||
"name": "Julian Gruber",
|
||||
"email": "mail@juliangruber.com",
|
||||
"url": "http://juliangruber.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/juliangruber/brace-expansion/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"balanced-match": "^1.0.0",
|
||||
"concat-map": "0.0.1"
|
||||
},
|
||||
"description": "Brace expansion as known from sh/bash",
|
||||
"devDependencies": {
|
||||
"matcha": "^0.7.0",
|
||||
"tape": "^4.6.0"
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
|
||||
"shasum": "3c7fcbf529d87226f3d2f52b966ff5271eb441dd",
|
||||
"tarball": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
|
||||
"fileCount": 4,
|
||||
"unpackedSize": 11059
|
||||
},
|
||||
"gitHead": "01a21de7441549d26ac0c0a9ff91385d16e5c21c",
|
||||
"homepage": "https://github.com/juliangruber/brace-expansion",
|
||||
"keywords": [],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "isaacs",
|
||||
"email": "isaacs@npmjs.com"
|
||||
},
|
||||
{
|
||||
"name": "juliangruber",
|
||||
"email": "julian@juliangruber.com"
|
||||
}
|
||||
],
|
||||
"name": "brace-expansion",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/juliangruber/brace-expansion.git"
|
||||
},
|
||||
"scripts": {
|
||||
"bench": "matcha test/perf/bench.js",
|
||||
"gentest": "bash test/generate.sh",
|
||||
"test": "tape test/*.js"
|
||||
},
|
||||
"testling": {
|
||||
"files": "test/*.js",
|
||||
"browsers": [
|
||||
"ie/8..latest",
|
||||
"firefox/20..latest",
|
||||
"firefox/nightly",
|
||||
"chrome/25..latest",
|
||||
"chrome/canary",
|
||||
"opera/12..latest",
|
||||
"opera/next",
|
||||
"safari/5.1..latest",
|
||||
"ipad/6.0..latest",
|
||||
"iphone/6.0..latest",
|
||||
"android-browser/4.2..latest"
|
||||
]
|
||||
},
|
||||
"version": "1.1.11"
|
||||
}
|
122
app/node_modules/buffers/README.markdown
generated
vendored
122
app/node_modules/buffers/README.markdown
generated
vendored
|
@ -1,122 +0,0 @@
|
|||
buffers
|
||||
=======
|
||||
|
||||
Treat a collection of Buffers as a single contiguous partially mutable Buffer.
|
||||
|
||||
Where possible, operations execute without creating a new Buffer and copying
|
||||
everything over.
|
||||
|
||||
This is a cleaner more Buffery rehash of
|
||||
[bufferlist](http://github.com/substack/node-bufferlist).
|
||||
|
||||
example
|
||||
=======
|
||||
|
||||
slice
|
||||
-----
|
||||
|
||||
var Buffers = require('buffers');
|
||||
var bufs = Buffers();
|
||||
bufs.push(new Buffer([1,2,3]));
|
||||
bufs.push(new Buffer([4,5,6,7]));
|
||||
bufs.push(new Buffer([8,9,10]));
|
||||
|
||||
console.dir(bufs.slice(2,8))
|
||||
|
||||
output:
|
||||
|
||||
$ node examples/slice.js
|
||||
<Buffer 03 04 05 06 07 08>
|
||||
|
||||
splice
|
||||
------
|
||||
|
||||
var Buffers = require('buffers');
|
||||
var bufs = Buffers([
|
||||
new Buffer([1,2,3]),
|
||||
new Buffer([4,5,6,7]),
|
||||
new Buffer([8,9,10]),
|
||||
]);
|
||||
|
||||
var removed = bufs.splice(2, 4);
|
||||
console.dir({
|
||||
removed : removed.slice(),
|
||||
bufs : bufs.slice(),
|
||||
});
|
||||
|
||||
output:
|
||||
|
||||
$ node examples/splice.js
|
||||
{ removed: <Buffer 03 04 05 06>,
|
||||
bufs: <Buffer 01 02 07 08 09 0a> }
|
||||
|
||||
methods
|
||||
=======
|
||||
|
||||
Buffers(buffers)
|
||||
----------------
|
||||
|
||||
Create a Buffers with an array of `Buffer`s if specified, else `[]`.
|
||||
|
||||
.push(buf1, buf2...)
|
||||
--------------------
|
||||
|
||||
Push buffers onto the end. Just like `Array.prototype.push`.
|
||||
|
||||
.unshift(buf1, buf2...)
|
||||
-----------------------
|
||||
|
||||
Unshift buffers onto the head. Just like `Array.prototype.unshift`.
|
||||
|
||||
.slice(i, j)
|
||||
------------
|
||||
|
||||
Slice a range out of the buffer collection as if it were contiguous.
|
||||
Works just like the `Array.prototype.slice` version.
|
||||
|
||||
.splice(i, howMany, replacements)
|
||||
---------------------------------
|
||||
|
||||
Splice the buffer collection as if it were contiguous.
|
||||
Works just like `Array.prototype.splice`, even the replacement part!
|
||||
|
||||
.copy(dst, dstStart, start, end)
|
||||
--------------------------------
|
||||
|
||||
Copy the buffer collection as if it were contiguous to the `dst` Buffer with the
|
||||
specified bounds.
|
||||
Works just like `Buffer.prototype.copy`.
|
||||
|
||||
.get(i)
|
||||
-------
|
||||
|
||||
Get a single element at index `i`.
|
||||
|
||||
.set(i, x)
|
||||
----------
|
||||
|
||||
Set a single element's value at index `i`.
|
||||
|
||||
.indexOf(needle, offset)
|
||||
----------
|
||||
|
||||
Find a string or buffer `needle` inside the buffer collection. Returns
|
||||
the position of the search string or -1 if the search string was not
|
||||
found.
|
||||
|
||||
Provide an `offset` to skip that number of characters at the beginning
|
||||
of the search. This can be used to find additional matches.
|
||||
|
||||
This function will return the correct result even if the search string
|
||||
is spread out over multiple internal buffers.
|
||||
|
||||
.toBuffer()
|
||||
-----------
|
||||
|
||||
Convert the buffer collection to a single buffer, equivalent with `.slice(0, buffers.length)`;
|
||||
|
||||
.toString(encoding, start, end)
|
||||
-----------
|
||||
|
||||
Decodes and returns a string from the buffer collection.
|
||||
Works just like `Buffer.prototype.toString`
|
9
app/node_modules/buffers/examples/slice.js
generated
vendored
9
app/node_modules/buffers/examples/slice.js
generated
vendored
|
@ -1,9 +0,0 @@
|
|||
var Buffers = require('buffers');
|
||||
var bufs = Buffers();
|
||||
bufs.push(new Buffer([1,2,3]));
|
||||
bufs.push(new Buffer([4,5,6,7]));
|
||||
bufs.push(new Buffer([8,9,10]));
|
||||
|
||||
console.dir(bufs.slice(2,8))
|
||||
|
||||
// Output: <Buffer 03 04 05 06 07 08>
|
17
app/node_modules/buffers/examples/splice.js
generated
vendored
17
app/node_modules/buffers/examples/splice.js
generated
vendored
|
@ -1,17 +0,0 @@
|
|||
var Buffers = require('buffers');
|
||||
var bufs = Buffers([
|
||||
new Buffer([1,2,3]),
|
||||
new Buffer([4,5,6,7]),
|
||||
new Buffer([8,9,10]),
|
||||
]);
|
||||
|
||||
var removed = bufs.splice(2, 4, new Buffer('ab'), new Buffer('cd'));
|
||||
console.dir({
|
||||
removed : removed.slice(),
|
||||
bufs : bufs.slice(),
|
||||
});
|
||||
|
||||
/* Output:
|
||||
{ removed: <Buffer 03 04 05 06>,
|
||||
bufs: <Buffer 01 02 07 08 09 0a> }
|
||||
*/
|
269
app/node_modules/buffers/index.js
generated
vendored
269
app/node_modules/buffers/index.js
generated
vendored
|
@ -1,269 +0,0 @@
|
|||
module.exports = Buffers;
|
||||
|
||||
function Buffers (bufs) {
|
||||
if (!(this instanceof Buffers)) return new Buffers(bufs);
|
||||
this.buffers = bufs || [];
|
||||
this.length = this.buffers.reduce(function (size, buf) {
|
||||
return size + buf.length
|
||||
}, 0);
|
||||
}
|
||||
|
||||
Buffers.prototype.push = function () {
|
||||
for (var i = 0; i < arguments.length; i++) {
|
||||
if (!Buffer.isBuffer(arguments[i])) {
|
||||
throw new TypeError('Tried to push a non-buffer');
|
||||
}
|
||||
}
|
||||
|
||||
for (var i = 0; i < arguments.length; i++) {
|
||||
var buf = arguments[i];
|
||||
this.buffers.push(buf);
|
||||
this.length += buf.length;
|
||||
}
|
||||
return this.length;
|
||||
};
|
||||
|
||||
Buffers.prototype.unshift = function () {
|
||||
for (var i = 0; i < arguments.length; i++) {
|
||||
if (!Buffer.isBuffer(arguments[i])) {
|
||||
throw new TypeError('Tried to unshift a non-buffer');
|
||||
}
|
||||
}
|
||||
|
||||
for (var i = 0; i < arguments.length; i++) {
|
||||
var buf = arguments[i];
|
||||
this.buffers.unshift(buf);
|
||||
this.length += buf.length;
|
||||
}
|
||||
return this.length;
|
||||
};
|
||||
|
||||
Buffers.prototype.copy = function (dst, dStart, start, end) {
|
||||
return this.slice(start, end).copy(dst, dStart, 0, end - start);
|
||||
};
|
||||
|
||||
Buffers.prototype.splice = function (i, howMany) {
|
||||
var buffers = this.buffers;
|
||||
var index = i >= 0 ? i : this.length - i;
|
||||
var reps = [].slice.call(arguments, 2);
|
||||
|
||||
if (howMany === undefined) {
|
||||
howMany = this.length - index;
|
||||
}
|
||||
else if (howMany > this.length - index) {
|
||||
howMany = this.length - index;
|
||||
}
|
||||
|
||||
for (var i = 0; i < reps.length; i++) {
|
||||
this.length += reps[i].length;
|
||||
}
|
||||
|
||||
var removed = new Buffers();
|
||||
var bytes = 0;
|
||||
|
||||
var startBytes = 0;
|
||||
for (
|
||||
var ii = 0;
|
||||
ii < buffers.length && startBytes + buffers[ii].length < index;
|
||||
ii ++
|
||||
) { startBytes += buffers[ii].length }
|
||||
|
||||
if (index - startBytes > 0) {
|
||||
var start = index - startBytes;
|
||||
|
||||
if (start + howMany < buffers[ii].length) {
|
||||
removed.push(buffers[ii].slice(start, start + howMany));
|
||||
|
||||
var orig = buffers[ii];
|
||||
//var buf = new Buffer(orig.length - howMany);
|
||||
var buf0 = new Buffer(start);
|
||||
for (var i = 0; i < start; i++) {
|
||||
buf0[i] = orig[i];
|
||||
}
|
||||
|
||||
var buf1 = new Buffer(orig.length - start - howMany);
|
||||
for (var i = start + howMany; i < orig.length; i++) {
|
||||
buf1[ i - howMany - start ] = orig[i]
|
||||
}
|
||||
|
||||
if (reps.length > 0) {
|
||||
var reps_ = reps.slice();
|
||||
reps_.unshift(buf0);
|
||||
reps_.push(buf1);
|
||||
buffers.splice.apply(buffers, [ ii, 1 ].concat(reps_));
|
||||
ii += reps_.length;
|
||||
reps = [];
|
||||
}
|
||||
else {
|
||||
buffers.splice(ii, 1, buf0, buf1);
|
||||
//buffers[ii] = buf;
|
||||
ii += 2;
|
||||
}
|
||||
}
|
||||
else {
|
||||
removed.push(buffers[ii].slice(start));
|
||||
buffers[ii] = buffers[ii].slice(0, start);
|
||||
ii ++;
|
||||
}
|
||||
}
|
||||
|
||||
if (reps.length > 0) {
|
||||
buffers.splice.apply(buffers, [ ii, 0 ].concat(reps));
|
||||
ii += reps.length;
|
||||
}
|
||||
|
||||
while (removed.length < howMany) {
|
||||
var buf = buffers[ii];
|
||||
var len = buf.length;
|
||||
var take = Math.min(len, howMany - removed.length);
|
||||
|
||||
if (take === len) {
|
||||
removed.push(buf);
|
||||
buffers.splice(ii, 1);
|
||||
}
|
||||
else {
|
||||
removed.push(buf.slice(0, take));
|
||||
buffers[ii] = buffers[ii].slice(take);
|
||||
}
|
||||
}
|
||||
|
||||
this.length -= removed.length;
|
||||
|
||||
return removed;
|
||||
};
|
||||
|
||||
Buffers.prototype.slice = function (i, j) {
|
||||
var buffers = this.buffers;
|
||||
if (j === undefined) j = this.length;
|
||||
if (i === undefined) i = 0;
|
||||
|
||||
if (j > this.length) j = this.length;
|
||||
|
||||
var startBytes = 0;
|
||||
for (
|
||||
var si = 0;
|
||||
si < buffers.length && startBytes + buffers[si].length <= i;
|
||||
si ++
|
||||
) { startBytes += buffers[si].length }
|
||||
|
||||
var target = new Buffer(j - i);
|
||||
|
||||
var ti = 0;
|
||||
for (var ii = si; ti < j - i && ii < buffers.length; ii++) {
|
||||
var len = buffers[ii].length;
|
||||
|
||||
var start = ti === 0 ? i - startBytes : 0;
|
||||
var end = ti + len >= j - i
|
||||
? Math.min(start + (j - i) - ti, len)
|
||||
: len
|
||||
;
|
||||
|
||||
buffers[ii].copy(target, ti, start, end);
|
||||
ti += end - start;
|
||||
}
|
||||
|
||||
return target;
|
||||
};
|
||||
|
||||
Buffers.prototype.pos = function (i) {
|
||||
if (i < 0 || i >= this.length) throw new Error('oob');
|
||||
var l = i, bi = 0, bu = null;
|
||||
for (;;) {
|
||||
bu = this.buffers[bi];
|
||||
if (l < bu.length) {
|
||||
return {buf: bi, offset: l};
|
||||
} else {
|
||||
l -= bu.length;
|
||||
}
|
||||
bi++;
|
||||
}
|
||||
};
|
||||
|
||||
Buffers.prototype.get = function get (i) {
|
||||
var pos = this.pos(i);
|
||||
|
||||
return this.buffers[pos.buf].get(pos.offset);
|
||||
};
|
||||
|
||||
Buffers.prototype.set = function set (i, b) {
|
||||
var pos = this.pos(i);
|
||||
|
||||
return this.buffers[pos.buf].set(pos.offset, b);
|
||||
};
|
||||
|
||||
Buffers.prototype.indexOf = function (needle, offset) {
|
||||
if ("string" === typeof needle) {
|
||||
needle = new Buffer(needle);
|
||||
} else if (needle instanceof Buffer) {
|
||||
// already a buffer
|
||||
} else {
|
||||
throw new Error('Invalid type for a search string');
|
||||
}
|
||||
|
||||
if (!needle.length) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!this.length) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
var i = 0, j = 0, match = 0, mstart, pos = 0;
|
||||
|
||||
// start search from a particular point in the virtual buffer
|
||||
if (offset) {
|
||||
var p = this.pos(offset);
|
||||
i = p.buf;
|
||||
j = p.offset;
|
||||
pos = offset;
|
||||
}
|
||||
|
||||
// for each character in virtual buffer
|
||||
for (;;) {
|
||||
while (j >= this.buffers[i].length) {
|
||||
j = 0;
|
||||
i++;
|
||||
|
||||
if (i >= this.buffers.length) {
|
||||
// search string not found
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
var char = this.buffers[i][j];
|
||||
|
||||
if (char == needle[match]) {
|
||||
// keep track where match started
|
||||
if (match == 0) {
|
||||
mstart = {
|
||||
i: i,
|
||||
j: j,
|
||||
pos: pos
|
||||
};
|
||||
}
|
||||
match++;
|
||||
if (match == needle.length) {
|
||||
// full match
|
||||
return mstart.pos;
|
||||
}
|
||||
} else if (match != 0) {
|
||||
// a partial match ended, go back to match starting position
|
||||
// this will continue the search at the next character
|
||||
i = mstart.i;
|
||||
j = mstart.j;
|
||||
pos = mstart.pos;
|
||||
match = 0;
|
||||
}
|
||||
|
||||
j++;
|
||||
pos++;
|
||||
}
|
||||
};
|
||||
|
||||
Buffers.prototype.toBuffer = function() {
|
||||
return this.slice();
|
||||
}
|
||||
|
||||
Buffers.prototype.toString = function(encoding, start, end) {
|
||||
return this.slice(start, end).toString(encoding);
|
||||
}
|
87
app/node_modules/buffers/package.json
generated
vendored
87
app/node_modules/buffers/package.json
generated
vendored
|
@ -1,87 +0,0 @@
|
|||
{
|
||||
"_args": [
|
||||
[
|
||||
{
|
||||
"raw": "buffers@~0.1.1",
|
||||
"scope": null,
|
||||
"escapedName": "buffers",
|
||||
"name": "buffers",
|
||||
"rawSpec": "~0.1.1",
|
||||
"spec": ">=0.1.1 <0.2.0",
|
||||
"type": "range"
|
||||
},
|
||||
"C:\\Users\\ryuki\\TheDesk\\app\\node_modules\\binary"
|
||||
]
|
||||
],
|
||||
"_defaultsLoaded": true,
|
||||
"_engineSupported": true,
|
||||
"_from": "buffers@>=0.1.1 <0.2.0",
|
||||
"_id": "buffers@0.1.1",
|
||||
"_inCache": true,
|
||||
"_location": "/buffers",
|
||||
"_nodeVersion": "v0.4.12",
|
||||
"_npmJsonOpts": {
|
||||
"file": "/home/substack/.npm/buffers/0.1.1/package/package.json",
|
||||
"wscript": false,
|
||||
"contributors": false,
|
||||
"serverjs": false
|
||||
},
|
||||
"_npmVersion": "1.0.30",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"raw": "buffers@~0.1.1",
|
||||
"scope": null,
|
||||
"escapedName": "buffers",
|
||||
"name": "buffers",
|
||||
"rawSpec": "~0.1.1",
|
||||
"spec": ">=0.1.1 <0.2.0",
|
||||
"type": "range"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/binary",
|
||||
"/match-stream"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/buffers/-/buffers-0.1.1.tgz",
|
||||
"_shasum": "b24579c3bed4d6d396aeee6d9a8ae7f5482ab7bb",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "buffers@~0.1.1",
|
||||
"_where": "C:\\Users\\ryuki\\TheDesk\\app\\node_modules\\binary",
|
||||
"author": {
|
||||
"name": "James Halliday",
|
||||
"email": "mail@substack.net",
|
||||
"url": "http://substack.net"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/substack/node-buffers/issues"
|
||||
},
|
||||
"dependencies": {},
|
||||
"description": "Treat a collection of Buffers as a single contiguous partially mutable Buffer.",
|
||||
"devDependencies": {},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "b24579c3bed4d6d396aeee6d9a8ae7f5482ab7bb",
|
||||
"tarball": "https://registry.npmjs.org/buffers/-/buffers-0.1.1.tgz"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.2.0"
|
||||
},
|
||||
"homepage": "https://github.com/substack/node-buffers#readme",
|
||||
"main": "./index",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "substack",
|
||||
"email": "mail@substack.net"
|
||||
}
|
||||
],
|
||||
"name": "buffers",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/substack/node-buffers.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "expresso"
|
||||
},
|
||||
"version": "0.1.1"
|
||||
}
|
209
app/node_modules/buffers/test/buffers.js
generated
vendored
209
app/node_modules/buffers/test/buffers.js
generated
vendored
|
@ -1,209 +0,0 @@
|
|||
var assert = require('assert');
|
||||
var Buffers = require('../');
|
||||
|
||||
function create (xs, split) {
|
||||
var bufs = Buffers();
|
||||
var offset = 0;
|
||||
split.forEach(function (i) {
|
||||
bufs.push(new Buffer(xs.slice(offset, offset + i)));
|
||||
offset += i;
|
||||
});
|
||||
return bufs;
|
||||
}
|
||||
|
||||
exports.slice = function () {
|
||||
var xs = [0,1,2,3,4,5,6,7,8,9];
|
||||
var splits = [ [4,2,3,1], [2,2,2,2,2], [1,6,3,1], [9,2], [10], [5,5] ];
|
||||
|
||||
splits.forEach(function (split) {
|
||||
var bufs = create(xs, split);
|
||||
assert.eql(new Buffer(xs), bufs.slice(),
|
||||
'[' + xs.join(',') + ']'
|
||||
+ ' != ' +
|
||||
'[' + [].join.call(bufs.slice(), ',') + ']'
|
||||
);
|
||||
|
||||
for (var i = 0; i < xs.length; i++) {
|
||||
for (var j = i; j < xs.length; j++) {
|
||||
var a = bufs.slice(i,j);
|
||||
var b = new Buffer(xs.slice(i,j));
|
||||
|
||||
assert.eql(a, b,
|
||||
'[' + [].join.call(a, ',') + ']'
|
||||
+ ' != ' +
|
||||
'[' + [].join.call(b, ',') + ']'
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
exports.splice = function () {
|
||||
var xs = [0,1,2,3,4,5,6,7,8,9];
|
||||
var splits = [ [4,2,3,1], [2,2,2,2,2], [1,6,3,1], [9,2], [10], [5,5] ];
|
||||
|
||||
splits.forEach(function (split) {
|
||||
for (var i = 0; i < xs.length; i++) {
|
||||
for (var j = i; j < xs.length; j++) {
|
||||
var bufs = create(xs, split);
|
||||
var xs_ = xs.slice();
|
||||
|
||||
var a_ = bufs.splice(i,j);
|
||||
var a = [].slice.call(a_.slice());
|
||||
var b = xs_.splice(i,j);
|
||||
assert.eql(a, b,
|
||||
'[' + a.join(',') + ']'
|
||||
+ ' != ' +
|
||||
'[' + b.join(',') + ']'
|
||||
);
|
||||
|
||||
assert.eql(bufs.slice(), new Buffer(xs_),
|
||||
'[' + [].join.call(bufs.slice(), ',') + ']'
|
||||
+ ' != ' +
|
||||
'[' + [].join.call(xs_, ',') + ']'
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
exports.spliceRep = function () {
|
||||
var xs = [0,1,2,3,4,5,6,7,8,9];
|
||||
var splits = [ [4,2,3,1], [2,2,2,2,2], [1,6,3,1], [9,2], [10], [5,5] ];
|
||||
var reps = [ [], [1], [5,6], [3,1,3,3,7], [9,8,7,6,5,4,3,2,1,2,3,4,5] ];
|
||||
|
||||
splits.forEach(function (split) {
|
||||
reps.forEach(function (rep) {
|
||||
for (var i = 0; i < xs.length; i++) {
|
||||
for (var j = i; j < xs.length; j++) {
|
||||
var bufs = create(xs, split);
|
||||
var xs_ = xs.slice();
|
||||
|
||||
var a_ = bufs.splice.apply(
|
||||
bufs, [ i, j ].concat(new Buffer(rep))
|
||||
);
|
||||
var a = [].slice.call(a_.slice());
|
||||
var b = xs_.splice.apply(xs_, [ i, j ].concat(rep));
|
||||
|
||||
assert.eql(a, b,
|
||||
'[' + a.join(',') + ']'
|
||||
+ ' != ' +
|
||||
'[' + b.join(',') + ']'
|
||||
);
|
||||
|
||||
assert.eql(bufs.slice(), new Buffer(xs_),
|
||||
'[' + [].join.call(bufs.slice(), ',') + ']'
|
||||
+ ' != ' +
|
||||
'[' + [].join.call(xs_, ',') + ']'
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
exports.copy = function () {
|
||||
var xs = [0,1,2,3,4,5,6,7,8,9];
|
||||
var splits = [ [4,2,3,1], [2,2,2,2,2], [1,6,3,1], [9,2], [10], [5,5] ];
|
||||
|
||||
splits.forEach(function (split) {
|
||||
var bufs = create(xs, split);
|
||||
var buf = new Buffer(xs);
|
||||
|
||||
for (var i = 0; i < xs.length; i++) {
|
||||
for (var j = i; j < xs.length; j++) {
|
||||
var t0 = new Buffer(j - i);
|
||||
var t1 = new Buffer(j - i);
|
||||
|
||||
assert.eql(
|
||||
bufs.copy(t0, 0, i, j),
|
||||
buf.copy(t1, 0, i, j)
|
||||
);
|
||||
|
||||
assert.eql(
|
||||
[].slice.call(t0),
|
||||
[].slice.call(t1)
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
exports.push = function () {
|
||||
var bufs = Buffers();
|
||||
bufs.push(new Buffer([0]));
|
||||
bufs.push(new Buffer([1,2,3]));
|
||||
bufs.push(new Buffer([4,5]));
|
||||
bufs.push(new Buffer([6,7,8,9]));
|
||||
assert.eql(
|
||||
[].slice.call(bufs.slice()),
|
||||
[0,1,2,3,4,5,6,7,8,9]
|
||||
);
|
||||
|
||||
assert.throws(function () {
|
||||
bufs.push(new Buffer([11,12]), 'moo');
|
||||
});
|
||||
assert.eql(bufs.buffers.length, 4);
|
||||
};
|
||||
|
||||
exports.unshift = function () {
|
||||
var bufs = Buffers();
|
||||
bufs.unshift(new Buffer([6,7,8,9]));
|
||||
bufs.unshift(new Buffer([4,5]));
|
||||
bufs.unshift(new Buffer([1,2,3]));
|
||||
bufs.unshift(new Buffer([0]));
|
||||
assert.eql(
|
||||
[].slice.call(bufs.slice()),
|
||||
[0,1,2,3,4,5,6,7,8,9]
|
||||
);
|
||||
assert.throws(function () {
|
||||
bufs.unshift(new Buffer([-2,-1]), 'moo');
|
||||
});
|
||||
assert.eql(bufs.buffers.length, 4);
|
||||
};
|
||||
|
||||
exports.get = function () {
|
||||
var bufs = Buffers();
|
||||
bufs.unshift(new Buffer([6,7,8,9]));
|
||||
bufs.unshift(new Buffer([4,5]));
|
||||
bufs.unshift(new Buffer([1,2,3]));
|
||||
bufs.unshift(new Buffer([0]));
|
||||
assert.eql( bufs.get(0), 0 );
|
||||
assert.eql( bufs.get(1), 1 );
|
||||
assert.eql( bufs.get(2), 2 );
|
||||
assert.eql( bufs.get(3), 3 );
|
||||
assert.eql( bufs.get(4), 4 );
|
||||
assert.eql( bufs.get(5), 5 );
|
||||
assert.eql( bufs.get(6), 6 );
|
||||
assert.eql( bufs.get(7), 7 );
|
||||
assert.eql( bufs.get(8), 8 );
|
||||
assert.eql( bufs.get(9), 9 );
|
||||
};
|
||||
|
||||
exports.set = function () {
|
||||
var bufs = Buffers();
|
||||
bufs.push(new Buffer("Hel"));
|
||||
bufs.push(new Buffer("lo"));
|
||||
bufs.push(new Buffer("!"));
|
||||
bufs.set(0, 'h'.charCodeAt(0) );
|
||||
bufs.set(3, 'L'.charCodeAt(0) );
|
||||
bufs.set(5, '.'.charCodeAt(0) );
|
||||
assert.eql( bufs.slice(0).toString(), 'helLo.' );
|
||||
};
|
||||
|
||||
exports.indexOf = function () {
|
||||
var bufs = Buffers();
|
||||
bufs.push(new Buffer("Hel"));
|
||||
bufs.push(new Buffer("lo,"));
|
||||
bufs.push(new Buffer(" how are "));
|
||||
bufs.push(new Buffer("you"));
|
||||
bufs.push(new Buffer("?"));
|
||||
assert.eql( bufs.indexOf("Hello"), 0 );
|
||||
assert.eql( bufs.indexOf("Hello", 1), -1 );
|
||||
assert.eql( bufs.indexOf("ello"), 1 );
|
||||
assert.eql( bufs.indexOf("ello", 1), 1 );
|
||||
assert.eql( bufs.indexOf("ello", 2), -1 );
|
||||
assert.eql( bufs.indexOf("e"), 1 );
|
||||
assert.eql( bufs.indexOf("e", 2), 13 );
|
||||
assert.eql( bufs.indexOf(new Buffer([0x65]), 2), 13 );
|
||||
};
|
1
app/node_modules/chainsaw/.npmignore
generated
vendored
1
app/node_modules/chainsaw/.npmignore
generated
vendored
|
@ -1 +0,0 @@
|
|||
node_modules
|
157
app/node_modules/chainsaw/README.markdown
generated
vendored
157
app/node_modules/chainsaw/README.markdown
generated
vendored
|
@ -1,157 +0,0 @@
|
|||
Chainsaw
|
||||
========
|
||||
|
||||
Build chainable fluent interfaces the easy way in node.js.
|
||||
|
||||
With this meta-module you can write modules with chainable interfaces.
|
||||
Chainsaw takes care of all of the boring details and makes nested flow control
|
||||
super simple too.
|
||||
|
||||
Just call `Chainsaw` with a constructor function like in the examples below.
|
||||
In your methods, just do `saw.next()` to move along to the next event and
|
||||
`saw.nest()` to create a nested chain.
|
||||
|
||||
Examples
|
||||
========
|
||||
|
||||
add_do.js
|
||||
---------
|
||||
|
||||
This silly example adds values with a chainsaw.
|
||||
|
||||
var Chainsaw = require('chainsaw');
|
||||
|
||||
function AddDo (sum) {
|
||||
return Chainsaw(function (saw) {
|
||||
this.add = function (n) {
|
||||
sum += n;
|
||||
saw.next();
|
||||
};
|
||||
|
||||
this.do = function (cb) {
|
||||
saw.nest(cb, sum);
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
AddDo(0)
|
||||
.add(5)
|
||||
.add(10)
|
||||
.do(function (sum) {
|
||||
if (sum > 12) this.add(-10);
|
||||
})
|
||||
.do(function (sum) {
|
||||
console.log('Sum: ' + sum);
|
||||
})
|
||||
;
|
||||
|
||||
Output:
|
||||
Sum: 5
|
||||
|
||||
prompt.js
|
||||
---------
|
||||
|
||||
This example provides a wrapper on top of stdin with the help of
|
||||
[node-lazy](https://github.com/pkrumins/node-lazy) for line-processing.
|
||||
|
||||
var Chainsaw = require('chainsaw');
|
||||
var Lazy = require('lazy');
|
||||
|
||||
module.exports = Prompt;
|
||||
function Prompt (stream) {
|
||||
var waiting = [];
|
||||
var lines = [];
|
||||
var lazy = Lazy(stream).lines.map(String)
|
||||
.forEach(function (line) {
|
||||
if (waiting.length) {
|
||||
var w = waiting.shift();
|
||||
w(line);
|
||||
}
|
||||
else lines.push(line);
|
||||
})
|
||||
;
|
||||
|
||||
var vars = {};
|
||||
return Chainsaw(function (saw) {
|
||||
this.getline = function (f) {
|
||||
var g = function (line) {
|
||||
saw.nest(f, line, vars);
|
||||
};
|
||||
|
||||
if (lines.length) g(lines.shift());
|
||||
else waiting.push(g);
|
||||
};
|
||||
|
||||
this.do = function (cb) {
|
||||
saw.nest(cb, vars);
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
And now for the new Prompt() module in action:
|
||||
|
||||
var util = require('util');
|
||||
var stdin = process.openStdin();
|
||||
|
||||
Prompt(stdin)
|
||||
.do(function () {
|
||||
util.print('x = ');
|
||||
})
|
||||
.getline(function (line, vars) {
|
||||
vars.x = parseInt(line, 10);
|
||||
})
|
||||
.do(function () {
|
||||
util.print('y = ');
|
||||
})
|
||||
.getline(function (line, vars) {
|
||||
vars.y = parseInt(line, 10);
|
||||
})
|
||||
.do(function (vars) {
|
||||
if (vars.x + vars.y < 10) {
|
||||
util.print('z = ');
|
||||
this.getline(function (line) {
|
||||
vars.z = parseInt(line, 10);
|
||||
})
|
||||
}
|
||||
else {
|
||||
vars.z = 0;
|
||||
}
|
||||
})
|
||||
.do(function (vars) {
|
||||
console.log('x + y + z = ' + (vars.x + vars.y + vars.z));
|
||||
process.exit();
|
||||
})
|
||||
;
|
||||
|
||||
Installation
|
||||
============
|
||||
|
||||
With [npm](http://github.com/isaacs/npm), just do:
|
||||
npm install chainsaw
|
||||
|
||||
or clone this project on github:
|
||||
|
||||
git clone http://github.com/substack/node-chainsaw.git
|
||||
|
||||
To run the tests with [expresso](http://github.com/visionmedia/expresso),
|
||||
just do:
|
||||
|
||||
expresso
|
||||
|
||||
|
||||
Light Mode vs Full Mode
|
||||
=======================
|
||||
|
||||
`node-chainsaw` supports two different modes. In full mode, every
|
||||
action is recorded, which allows you to replay actions using the
|
||||
`jump()`, `trap()` and `down()` methods.
|
||||
|
||||
However, if your chainsaws are long-lived, recording every action can
|
||||
consume a tremendous amount of memory, so we also offer a "light" mode
|
||||
where actions are not recorded and the aforementioned methods are
|
||||
disabled.
|
||||
|
||||
To enable light mode simply use `Chainsaw.light()` to construct your
|
||||
saw, instead of `Chainsaw()`.
|
||||
|
||||
|
25
app/node_modules/chainsaw/examples/add_do.js
generated
vendored
25
app/node_modules/chainsaw/examples/add_do.js
generated
vendored
|
@ -1,25 +0,0 @@
|
|||
var Chainsaw = require('chainsaw');
|
||||
|
||||
function AddDo (sum) {
|
||||
return Chainsaw(function (saw) {
|
||||
this.add = function (n) {
|
||||
sum += n;
|
||||
saw.next();
|
||||
};
|
||||
|
||||
this.do = function (cb) {
|
||||
saw.nest(cb, sum);
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
AddDo(0)
|
||||
.add(5)
|
||||
.add(10)
|
||||
.do(function (sum) {
|
||||
if (sum > 12) this.add(-10);
|
||||
})
|
||||
.do(function (sum) {
|
||||
console.log('Sum: ' + sum);
|
||||
})
|
||||
;
|
67
app/node_modules/chainsaw/examples/prompt.js
generated
vendored
67
app/node_modules/chainsaw/examples/prompt.js
generated
vendored
|
@ -1,67 +0,0 @@
|
|||
var Chainsaw = require('chainsaw');
|
||||
var Lazy = require('lazy');
|
||||
|
||||
module.exports = Prompt;
|
||||
function Prompt (stream) {
|
||||
var waiting = [];
|
||||
var lines = [];
|
||||
var lazy = Lazy(stream).lines.map(String)
|
||||
.forEach(function (line) {
|
||||
if (waiting.length) {
|
||||
var w = waiting.shift();
|
||||
w(line);
|
||||
}
|
||||
else lines.push(line);
|
||||
})
|
||||
;
|
||||
|
||||
var vars = {};
|
||||
return Chainsaw(function (saw) {
|
||||
this.getline = function (f) {
|
||||
var g = function (line) {
|
||||
saw.nest(f, line, vars);
|
||||
};
|
||||
|
||||
if (lines.length) g(lines.shift());
|
||||
else waiting.push(g);
|
||||
};
|
||||
|
||||
this.do = function (cb) {
|
||||
saw.nest(cb, vars);
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
var util = require('util');
|
||||
if (__filename === process.argv[1]) {
|
||||
var stdin = process.openStdin();
|
||||
Prompt(stdin)
|
||||
.do(function () {
|
||||
util.print('x = ');
|
||||
})
|
||||
.getline(function (line, vars) {
|
||||
vars.x = parseInt(line, 10);
|
||||
})
|
||||
.do(function () {
|
||||
util.print('y = ');
|
||||
})
|
||||
.getline(function (line, vars) {
|
||||
vars.y = parseInt(line, 10);
|
||||
})
|
||||
.do(function (vars) {
|
||||
if (vars.x + vars.y < 10) {
|
||||
util.print('z = ');
|
||||
this.getline(function (line) {
|
||||
vars.z = parseInt(line, 10);
|
||||
})
|
||||
}
|
||||
else {
|
||||
vars.z = 0;
|
||||
}
|
||||
})
|
||||
.do(function (vars) {
|
||||
console.log('x + y + z = ' + (vars.x + vars.y + vars.z));
|
||||
process.exit();
|
||||
})
|
||||
;
|
||||
}
|
145
app/node_modules/chainsaw/index.js
generated
vendored
145
app/node_modules/chainsaw/index.js
generated
vendored
|
@ -1,145 +0,0 @@
|
|||
var Traverse = require('traverse');
|
||||
var EventEmitter = require('events').EventEmitter;
|
||||
|
||||
module.exports = Chainsaw;
|
||||
function Chainsaw (builder) {
|
||||
var saw = Chainsaw.saw(builder, {});
|
||||
var r = builder.call(saw.handlers, saw);
|
||||
if (r !== undefined) saw.handlers = r;
|
||||
saw.record();
|
||||
return saw.chain();
|
||||
};
|
||||
|
||||
Chainsaw.light = function ChainsawLight (builder) {
|
||||
var saw = Chainsaw.saw(builder, {});
|
||||
var r = builder.call(saw.handlers, saw);
|
||||
if (r !== undefined) saw.handlers = r;
|
||||
return saw.chain();
|
||||
};
|
||||
|
||||
Chainsaw.saw = function (builder, handlers) {
|
||||
var saw = new EventEmitter;
|
||||
saw.handlers = handlers;
|
||||
saw.actions = [];
|
||||
|
||||
saw.chain = function () {
|
||||
var ch = Traverse(saw.handlers).map(function (node) {
|
||||
if (this.isRoot) return node;
|
||||
var ps = this.path;
|
||||
|
||||
if (typeof node === 'function') {
|
||||
this.update(function () {
|
||||
saw.actions.push({
|
||||
path : ps,
|
||||
args : [].slice.call(arguments)
|
||||
});
|
||||
return ch;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
process.nextTick(function () {
|
||||
saw.emit('begin');
|
||||
saw.next();
|
||||
});
|
||||
|
||||
return ch;
|
||||
};
|
||||
|
||||
saw.pop = function () {
|
||||
return saw.actions.shift();
|
||||
};
|
||||
|
||||
saw.next = function () {
|
||||
var action = saw.pop();
|
||||
|
||||
if (!action) {
|
||||
saw.emit('end');
|
||||
}
|
||||
else if (!action.trap) {
|
||||
var node = saw.handlers;
|
||||
action.path.forEach(function (key) { node = node[key] });
|
||||
node.apply(saw.handlers, action.args);
|
||||
}
|
||||
};
|
||||
|
||||
saw.nest = function (cb) {
|
||||
var args = [].slice.call(arguments, 1);
|
||||
var autonext = true;
|
||||
|
||||
if (typeof cb === 'boolean') {
|
||||
var autonext = cb;
|
||||
cb = args.shift();
|
||||
}
|
||||
|
||||
var s = Chainsaw.saw(builder, {});
|
||||
var r = builder.call(s.handlers, s);
|
||||
|
||||
if (r !== undefined) s.handlers = r;
|
||||
|
||||
// If we are recording...
|
||||
if ("undefined" !== typeof saw.step) {
|
||||
// ... our children should, too
|
||||
s.record();
|
||||
}
|
||||
|
||||
cb.apply(s.chain(), args);
|
||||
if (autonext !== false) s.on('end', saw.next);
|
||||
};
|
||||
|
||||
saw.record = function () {
|
||||
upgradeChainsaw(saw);
|
||||
};
|
||||
|
||||
['trap', 'down', 'jump'].forEach(function (method) {
|
||||
saw[method] = function () {
|
||||
throw new Error("To use the trap, down and jump features, please "+
|
||||
"call record() first to start recording actions.");
|
||||
};
|
||||
});
|
||||
|
||||
return saw;
|
||||
};
|
||||
|
||||
function upgradeChainsaw(saw) {
|
||||
saw.step = 0;
|
||||
|
||||
// override pop
|
||||
saw.pop = function () {
|
||||
return saw.actions[saw.step++];
|
||||
};
|
||||
|
||||
saw.trap = function (name, cb) {
|
||||
var ps = Array.isArray(name) ? name : [name];
|
||||
saw.actions.push({
|
||||
path : ps,
|
||||
step : saw.step,
|
||||
cb : cb,
|
||||
trap : true
|
||||
});
|
||||
};
|
||||
|
||||
saw.down = function (name) {
|
||||
var ps = (Array.isArray(name) ? name : [name]).join('/');
|
||||
var i = saw.actions.slice(saw.step).map(function (x) {
|
||||
if (x.trap && x.step <= saw.step) return false;
|
||||
return x.path.join('/') == ps;
|
||||
}).indexOf(true);
|
||||
|
||||
if (i >= 0) saw.step += i;
|
||||
else saw.step = saw.actions.length;
|
||||
|
||||
var act = saw.actions[saw.step - 1];
|
||||
if (act && act.trap) {
|
||||
// It's a trap!
|
||||
saw.step = act.step;
|
||||
act.cb();
|
||||
}
|
||||
else saw.next();
|
||||
};
|
||||
|
||||
saw.jump = function (step) {
|
||||
saw.step = step;
|
||||
saw.next();
|
||||
};
|
||||
};
|
85
app/node_modules/chainsaw/package.json
generated
vendored
85
app/node_modules/chainsaw/package.json
generated
vendored
|
@ -1,85 +0,0 @@
|
|||
{
|
||||
"_args": [
|
||||
[
|
||||
{
|
||||
"raw": "chainsaw@~0.1.0",
|
||||
"scope": null,
|
||||
"escapedName": "chainsaw",
|
||||
"name": "chainsaw",
|
||||
"rawSpec": "~0.1.0",
|
||||
"spec": ">=0.1.0 <0.2.0",
|
||||
"type": "range"
|
||||
},
|
||||
"C:\\Users\\ryuki\\TheDesk\\app\\node_modules\\binary"
|
||||
]
|
||||
],
|
||||
"_defaultsLoaded": true,
|
||||
"_engineSupported": true,
|
||||
"_from": "chainsaw@>=0.1.0 <0.2.0",
|
||||
"_id": "chainsaw@0.1.0",
|
||||
"_inCache": true,
|
||||
"_location": "/chainsaw",
|
||||
"_nodeVersion": "v0.5.0-pre",
|
||||
"_npmVersion": "1.0.10",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"raw": "chainsaw@~0.1.0",
|
||||
"scope": null,
|
||||
"escapedName": "chainsaw",
|
||||
"name": "chainsaw",
|
||||
"rawSpec": "~0.1.0",
|
||||
"spec": ">=0.1.0 <0.2.0",
|
||||
"type": "range"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/binary"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/chainsaw/-/chainsaw-0.1.0.tgz",
|
||||
"_shasum": "5eab50b28afe58074d0d58291388828b5e5fbc98",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "chainsaw@~0.1.0",
|
||||
"_where": "C:\\Users\\ryuki\\TheDesk\\app\\node_modules\\binary",
|
||||
"author": {
|
||||
"name": "James Halliday",
|
||||
"email": "mail@substack.net",
|
||||
"url": "http://substack.net"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/substack/node-chainsaw/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"traverse": ">=0.3.0 <0.4"
|
||||
},
|
||||
"description": "Build chainable fluent interfaces the easy way... with a freakin' chainsaw!",
|
||||
"devDependencies": {},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "5eab50b28afe58074d0d58291388828b5e5fbc98",
|
||||
"tarball": "https://registry.npmjs.org/chainsaw/-/chainsaw-0.1.0.tgz"
|
||||
},
|
||||
"engine": {
|
||||
"node": ">=0.4.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "*"
|
||||
},
|
||||
"homepage": "https://github.com/substack/node-chainsaw#readme",
|
||||
"keywords": [
|
||||
"chain",
|
||||
"fluent",
|
||||
"interface",
|
||||
"monad",
|
||||
"monadic"
|
||||
],
|
||||
"license": "MIT/X11",
|
||||
"main": "./index.js",
|
||||
"name": "chainsaw",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/substack/node-chainsaw.git"
|
||||
},
|
||||
"scripts": {},
|
||||
"version": "0.1.0"
|
||||
}
|
418
app/node_modules/chainsaw/test/chainsaw.js
generated
vendored
418
app/node_modules/chainsaw/test/chainsaw.js
generated
vendored
|
@ -1,418 +0,0 @@
|
|||
var assert = require('assert');
|
||||
var Chainsaw = require('../index');
|
||||
|
||||
exports.getset = function () {
|
||||
var to = setTimeout(function () {
|
||||
assert.fail('builder never fired');
|
||||
}, 1000);
|
||||
|
||||
var ch = Chainsaw(function (saw) {
|
||||
clearTimeout(to);
|
||||
var num = 0;
|
||||
|
||||
this.get = function (cb) {
|
||||
cb(num);
|
||||
saw.next();
|
||||
};
|
||||
|
||||
this.set = function (n) {
|
||||
num = n;
|
||||
saw.next();
|
||||
};
|
||||
|
||||
var ti = setTimeout(function () {
|
||||
assert.fail('end event not emitted');
|
||||
}, 50);
|
||||
|
||||
saw.on('end', function () {
|
||||
clearTimeout(ti);
|
||||
assert.equal(times, 3);
|
||||
});
|
||||
});
|
||||
|
||||
var times = 0;
|
||||
ch
|
||||
.get(function (x) {
|
||||
assert.equal(x, 0);
|
||||
times ++;
|
||||
})
|
||||
.set(10)
|
||||
.get(function (x) {
|
||||
assert.equal(x, 10);
|
||||
times ++;
|
||||
})
|
||||
.set(20)
|
||||
.get(function (x) {
|
||||
assert.equal(x, 20);
|
||||
times ++;
|
||||
})
|
||||
;
|
||||
};
|
||||
|
||||
exports.nest = function () {
|
||||
var ch = (function () {
|
||||
var vars = {};
|
||||
return Chainsaw(function (saw) {
|
||||
this.do = function (cb) {
|
||||
saw.nest(cb, vars);
|
||||
};
|
||||
});
|
||||
})();
|
||||
|
||||
var order = [];
|
||||
var to = setTimeout(function () {
|
||||
assert.fail("Didn't get to the end");
|
||||
}, 50);
|
||||
|
||||
ch
|
||||
.do(function (vars) {
|
||||
vars.x = 'y';
|
||||
order.push(1);
|
||||
|
||||
this
|
||||
.do(function (vs) {
|
||||
order.push(2);
|
||||
vs.x = 'x';
|
||||
})
|
||||
.do(function (vs) {
|
||||
order.push(3);
|
||||
vs.z = 'z';
|
||||
})
|
||||
;
|
||||
})
|
||||
.do(function (vars) {
|
||||
vars.y = 'y';
|
||||
order.push(4);
|
||||
})
|
||||
.do(function (vars) {
|
||||
assert.eql(order, [1,2,3,4]);
|
||||
assert.eql(vars, { x : 'x', y : 'y', z : 'z' });
|
||||
clearTimeout(to);
|
||||
})
|
||||
;
|
||||
};
|
||||
|
||||
exports.nestWait = function () {
|
||||
var ch = (function () {
|
||||
var vars = {};
|
||||
return Chainsaw(function (saw) {
|
||||
this.do = function (cb) {
|
||||
saw.nest(cb, vars);
|
||||
};
|
||||
|
||||
this.wait = function (n) {
|
||||
setTimeout(function () {
|
||||
saw.next();
|
||||
}, n);
|
||||
};
|
||||
});
|
||||
})();
|
||||
|
||||
var order = [];
|
||||
var to = setTimeout(function () {
|
||||
assert.fail("Didn't get to the end");
|
||||
}, 1000);
|
||||
|
||||
var times = {};
|
||||
|
||||
ch
|
||||
.do(function (vars) {
|
||||
vars.x = 'y';
|
||||
order.push(1);
|
||||
|
||||
this
|
||||
.do(function (vs) {
|
||||
order.push(2);
|
||||
vs.x = 'x';
|
||||
times.x = Date.now();
|
||||
})
|
||||
.wait(50)
|
||||
.do(function (vs) {
|
||||
order.push(3);
|
||||
vs.z = 'z';
|
||||
|
||||
times.z = Date.now();
|
||||
var dt = times.z - times.x;
|
||||
assert.ok(dt >= 50 && dt < 75);
|
||||
})
|
||||
;
|
||||
})
|
||||
.do(function (vars) {
|
||||
vars.y = 'y';
|
||||
order.push(4);
|
||||
|
||||
times.y = Date.now();
|
||||
})
|
||||
.wait(100)
|
||||
.do(function (vars) {
|
||||
assert.eql(order, [1,2,3,4]);
|
||||
assert.eql(vars, { x : 'x', y : 'y', z : 'z' });
|
||||
clearTimeout(to);
|
||||
|
||||
times.end = Date.now();
|
||||
var dt = times.end - times.y;
|
||||
assert.ok(dt >= 100 && dt < 125)
|
||||
})
|
||||
;
|
||||
};
|
||||
|
||||
exports.nestNext = function () {
|
||||
var ch = (function () {
|
||||
var vars = {};
|
||||
return Chainsaw(function (saw) {
|
||||
this.do = function (cb) {
|
||||
saw.nest(false, function () {
|
||||
var args = [].slice.call(arguments);
|
||||
args.push(saw.next);
|
||||
cb.apply(this, args);
|
||||
}, vars);
|
||||
};
|
||||
});
|
||||
})();
|
||||
|
||||
var order = [];
|
||||
var to = setTimeout(function () {
|
||||
assert.fail("Didn't get to the end");
|
||||
}, 500);
|
||||
|
||||
var times = [];
|
||||
|
||||
ch
|
||||
.do(function (vars, next_) {
|
||||
vars.x = 'y';
|
||||
order.push(1);
|
||||
|
||||
this
|
||||
.do(function (vs, next) {
|
||||
order.push(2);
|
||||
vs.x = 'x';
|
||||
setTimeout(next, 30);
|
||||
})
|
||||
.do(function (vs, next) {
|
||||
order.push(3);
|
||||
vs.z = 'z';
|
||||
setTimeout(next, 10);
|
||||
})
|
||||
.do(function () {
|
||||
setTimeout(next_, 20);
|
||||
})
|
||||
;
|
||||
})
|
||||
.do(function (vars, next) {
|
||||
vars.y = 'y';
|
||||
order.push(4);
|
||||
setTimeout(next, 5);
|
||||
})
|
||||
.do(function (vars) {
|
||||
assert.eql(order, [1,2,3,4]);
|
||||
assert.eql(vars, { x : 'x', y : 'y', z : 'z' });
|
||||
|
||||
clearTimeout(to);
|
||||
})
|
||||
;
|
||||
};
|
||||
|
||||
exports.builder = function () {
|
||||
var cx = Chainsaw(function (saw) {
|
||||
this.x = function () {};
|
||||
});
|
||||
assert.ok(cx.x);
|
||||
|
||||
var cy = Chainsaw(function (saw) {
|
||||
return { y : function () {} };
|
||||
});
|
||||
assert.ok(cy.y);
|
||||
|
||||
var cz = Chainsaw(function (saw) {
|
||||
return { z : function (cb) { saw.nest(cb) } };
|
||||
});
|
||||
assert.ok(cz.z);
|
||||
|
||||
var to = setTimeout(function () {
|
||||
assert.fail("Nested z didn't run");
|
||||
}, 50);
|
||||
|
||||
cz.z(function () {
|
||||
clearTimeout(to);
|
||||
assert.ok(this.z);
|
||||
});
|
||||
};
|
||||
|
||||
this.attr = function () {
|
||||
var to = setTimeout(function () {
|
||||
assert.fail("attr chain didn't finish");
|
||||
}, 50);
|
||||
|
||||
var xy = [];
|
||||
var ch = Chainsaw(function (saw) {
|
||||
this.h = {
|
||||
x : function () {
|
||||
xy.push('x');
|
||||
saw.next();
|
||||
},
|
||||
y : function () {
|
||||
xy.push('y');
|
||||
saw.next();
|
||||
assert.eql(xy, ['x','y']);
|
||||
clearTimeout(to);
|
||||
}
|
||||
};
|
||||
});
|
||||
assert.ok(ch.h);
|
||||
assert.ok(ch.h.x);
|
||||
assert.ok(ch.h.y);
|
||||
|
||||
ch.h.x().h.y();
|
||||
};
|
||||
|
||||
exports.down = function () {
|
||||
var error = null;
|
||||
var s;
|
||||
var ch = Chainsaw(function (saw) {
|
||||
s = saw;
|
||||
this.raise = function (err) {
|
||||
error = err;
|
||||
saw.down('catch');
|
||||
};
|
||||
|
||||
this.do = function (cb) {
|
||||
cb.call(this);
|
||||
};
|
||||
|
||||
this.catch = function (cb) {
|
||||
if (error) {
|
||||
saw.nest(cb, error);
|
||||
error = null;
|
||||
}
|
||||
else saw.next();
|
||||
};
|
||||
});
|
||||
|
||||
var to = setTimeout(function () {
|
||||
assert.fail(".do() after .catch() didn't fire");
|
||||
}, 50);
|
||||
|
||||
ch
|
||||
.do(function () {
|
||||
this.raise('pow');
|
||||
})
|
||||
.do(function () {
|
||||
assert.fail("raise didn't skip over this do block");
|
||||
})
|
||||
.catch(function (err) {
|
||||
assert.equal(err, 'pow');
|
||||
})
|
||||
.do(function () {
|
||||
clearTimeout(to);
|
||||
})
|
||||
;
|
||||
};
|
||||
|
||||
exports.trap = function () {
|
||||
var error = null;
|
||||
var ch = Chainsaw(function (saw) {
|
||||
var pars = 0;
|
||||
var stack = [];
|
||||
var i = 0;
|
||||
|
||||
this.par = function (cb) {
|
||||
pars ++;
|
||||
var j = i ++;
|
||||
cb.call(function () {
|
||||
pars --;
|
||||
stack[j] = [].slice.call(arguments);
|
||||
saw.down('result');
|
||||
});
|
||||
saw.next();
|
||||
};
|
||||
|
||||
this.join = function (cb) {
|
||||
saw.trap('result', function () {
|
||||
if (pars == 0) {
|
||||
cb.apply(this, stack);
|
||||
saw.next();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
this.raise = function (err) {
|
||||
error = err;
|
||||
saw.down('catch');
|
||||
};
|
||||
|
||||
this.do = function (cb) {
|
||||
cb.call(this);
|
||||
};
|
||||
|
||||
this.catch = function (cb) {
|
||||
if (error) {
|
||||
saw.nest(cb, error);
|
||||
error = null;
|
||||
}
|
||||
else saw.next();
|
||||
};
|
||||
});
|
||||
|
||||
var to = setTimeout(function () {
|
||||
assert.fail(".do() after .join() didn't fire");
|
||||
}, 100);
|
||||
var tj = setTimeout(function () {
|
||||
assert.fail('.join() never fired');
|
||||
}, 100);
|
||||
|
||||
var joined = false;
|
||||
ch
|
||||
.par(function () {
|
||||
setTimeout(this.bind(null, 1), 50);
|
||||
})
|
||||
.par(function () {
|
||||
setTimeout(this.bind(null, 2), 25);
|
||||
})
|
||||
.join(function (x, y) {
|
||||
assert.equal(x[0], 1);
|
||||
assert.equal(y[0], 2);
|
||||
clearTimeout(tj);
|
||||
joined = true;
|
||||
})
|
||||
.do(function () {
|
||||
clearTimeout(to);
|
||||
assert.ok(joined);
|
||||
})
|
||||
;
|
||||
};
|
||||
|
||||
exports.jump = function () {
|
||||
var to = setTimeout(function () {
|
||||
assert.fail('builder never fired');
|
||||
}, 50);
|
||||
|
||||
var xs = [ 4, 5, 6, -4, 8, 9, -1, 8 ];
|
||||
var xs_ = [];
|
||||
|
||||
var ch = Chainsaw(function (saw) {
|
||||
this.x = function (i) {
|
||||
xs_.push(i);
|
||||
saw.next();
|
||||
};
|
||||
|
||||
this.y = function (step) {
|
||||
var x = xs.shift();
|
||||
if (x > 0) saw.jump(step);
|
||||
else saw.next();
|
||||
};
|
||||
|
||||
saw.on('end', function () {
|
||||
clearTimeout(to);
|
||||
assert.eql(xs, [ 8 ]);
|
||||
assert.eql(xs_, [ 1, 1, 1, 1, 2, 3, 2, 3, 2, 3 ]);
|
||||
});
|
||||
});
|
||||
|
||||
ch
|
||||
.x(1)
|
||||
.y(0)
|
||||
.x(2)
|
||||
.x(3)
|
||||
.y(2)
|
||||
;
|
||||
};
|
4
app/node_modules/concat-map/.travis.yml
generated
vendored
4
app/node_modules/concat-map/.travis.yml
generated
vendored
|
@ -1,4 +0,0 @@
|
|||
language: node_js
|
||||
node_js:
|
||||
- 0.4
|
||||
- 0.6
|
18
app/node_modules/concat-map/LICENSE
generated
vendored
18
app/node_modules/concat-map/LICENSE
generated
vendored
|
@ -1,18 +0,0 @@
|
|||
This software is released under the MIT license:
|
||||
|
||||
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.
|
62
app/node_modules/concat-map/README.markdown
generated
vendored
62
app/node_modules/concat-map/README.markdown
generated
vendored
|
@ -1,62 +0,0 @@
|
|||
concat-map
|
||||
==========
|
||||
|
||||
Concatenative mapdashery.
|
||||
|
||||
[![browser support](http://ci.testling.com/substack/node-concat-map.png)](http://ci.testling.com/substack/node-concat-map)
|
||||
|
||||
[![build status](https://secure.travis-ci.org/substack/node-concat-map.png)](http://travis-ci.org/substack/node-concat-map)
|
||||
|
||||
example
|
||||
=======
|
||||
|
||||
``` js
|
||||
var concatMap = require('concat-map');
|
||||
var xs = [ 1, 2, 3, 4, 5, 6 ];
|
||||
var ys = concatMap(xs, function (x) {
|
||||
return x % 2 ? [ x - 0.1, x, x + 0.1 ] : [];
|
||||
});
|
||||
console.dir(ys);
|
||||
```
|
||||
|
||||
***
|
||||
|
||||
```
|
||||
[ 0.9, 1, 1.1, 2.9, 3, 3.1, 4.9, 5, 5.1 ]
|
||||
```
|
||||
|
||||
methods
|
||||
=======
|
||||
|
||||
``` js
|
||||
var concatMap = require('concat-map')
|
||||
```
|
||||
|
||||
concatMap(xs, fn)
|
||||
-----------------
|
||||
|
||||
Return an array of concatenated elements by calling `fn(x, i)` for each element
|
||||
`x` and each index `i` in the array `xs`.
|
||||
|
||||
When `fn(x, i)` returns an array, its result will be concatenated with the
|
||||
result array. If `fn(x, i)` returns anything else, that value will be pushed
|
||||
onto the end of the result array.
|
||||
|
||||
install
|
||||
=======
|
||||
|
||||
With [npm](http://npmjs.org) do:
|
||||
|
||||
```
|
||||
npm install concat-map
|
||||
```
|
||||
|
||||
license
|
||||
=======
|
||||
|
||||
MIT
|
||||
|
||||
notes
|
||||
=====
|
||||
|
||||
This module was written while sitting high above the ground in a tree.
|
6
app/node_modules/concat-map/example/map.js
generated
vendored
6
app/node_modules/concat-map/example/map.js
generated
vendored
|
@ -1,6 +0,0 @@
|
|||
var concatMap = require('../');
|
||||
var xs = [ 1, 2, 3, 4, 5, 6 ];
|
||||
var ys = concatMap(xs, function (x) {
|
||||
return x % 2 ? [ x - 0.1, x, x + 0.1 ] : [];
|
||||
});
|
||||
console.dir(ys);
|
13
app/node_modules/concat-map/index.js
generated
vendored
13
app/node_modules/concat-map/index.js
generated
vendored
|
@ -1,13 +0,0 @@
|
|||
module.exports = function (xs, fn) {
|
||||
var res = [];
|
||||
for (var i = 0; i < xs.length; i++) {
|
||||
var x = fn(xs[i], i);
|
||||
if (isArray(x)) res.push.apply(res, x);
|
||||
else res.push(x);
|
||||
}
|
||||
return res;
|
||||
};
|
||||
|
||||
var isArray = Array.isArray || function (xs) {
|
||||
return Object.prototype.toString.call(xs) === '[object Array]';
|
||||
};
|
117
app/node_modules/concat-map/package.json
generated
vendored
117
app/node_modules/concat-map/package.json
generated
vendored
|
@ -1,117 +0,0 @@
|
|||
{
|
||||
"_args": [
|
||||
[
|
||||
{
|
||||
"raw": "concat-map@0.0.1",
|
||||
"scope": null,
|
||||
"escapedName": "concat-map",
|
||||
"name": "concat-map",
|
||||
"rawSpec": "0.0.1",
|
||||
"spec": "0.0.1",
|
||||
"type": "version"
|
||||
},
|
||||
"C:\\Users\\ryuki\\TheDesk\\app\\node_modules\\brace-expansion"
|
||||
]
|
||||
],
|
||||
"_from": "concat-map@0.0.1",
|
||||
"_id": "concat-map@0.0.1",
|
||||
"_inCache": true,
|
||||
"_location": "/concat-map",
|
||||
"_npmUser": {
|
||||
"name": "substack",
|
||||
"email": "mail@substack.net"
|
||||
},
|
||||
"_npmVersion": "1.3.21",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"raw": "concat-map@0.0.1",
|
||||
"scope": null,
|
||||
"escapedName": "concat-map",
|
||||
"name": "concat-map",
|
||||
"rawSpec": "0.0.1",
|
||||
"spec": "0.0.1",
|
||||
"type": "version"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/brace-expansion"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
||||
"_shasum": "d8a96bd77fd68df7793a73036a3ba0d5405d477b",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "concat-map@0.0.1",
|
||||
"_where": "C:\\Users\\ryuki\\TheDesk\\app\\node_modules\\brace-expansion",
|
||||
"author": {
|
||||
"name": "James Halliday",
|
||||
"email": "mail@substack.net",
|
||||
"url": "http://substack.net"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/substack/node-concat-map/issues"
|
||||
},
|
||||
"dependencies": {},
|
||||
"description": "concatenative mapdashery",
|
||||
"devDependencies": {
|
||||
"tape": "~2.4.0"
|
||||
},
|
||||
"directories": {
|
||||
"example": "example",
|
||||
"test": "test"
|
||||
},
|
||||
"dist": {
|
||||
"shasum": "d8a96bd77fd68df7793a73036a3ba0d5405d477b",
|
||||
"tarball": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz"
|
||||
},
|
||||
"homepage": "https://github.com/substack/node-concat-map",
|
||||
"keywords": [
|
||||
"concat",
|
||||
"concatMap",
|
||||
"map",
|
||||
"functional",
|
||||
"higher-order"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "substack",
|
||||
"email": "mail@substack.net"
|
||||
}
|
||||
],
|
||||
"name": "concat-map",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/substack/node-concat-map.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "tape test/*.js"
|
||||
},
|
||||
"testling": {
|
||||
"files": "test/*.js",
|
||||
"browsers": {
|
||||
"ie": [
|
||||
6,
|
||||
7,
|
||||
8,
|
||||
9
|
||||
],
|
||||
"ff": [
|
||||
3.5,
|
||||
10,
|
||||
15
|
||||
],
|
||||
"chrome": [
|
||||
10,
|
||||
22
|
||||
],
|
||||
"safari": [
|
||||
5.1
|
||||
],
|
||||
"opera": [
|
||||
12
|
||||
]
|
||||
}
|
||||
},
|
||||
"version": "0.0.1"
|
||||
}
|
39
app/node_modules/concat-map/test/map.js
generated
vendored
39
app/node_modules/concat-map/test/map.js
generated
vendored
|
@ -1,39 +0,0 @@
|
|||
var concatMap = require('../');
|
||||
var test = require('tape');
|
||||
|
||||
test('empty or not', function (t) {
|
||||
var xs = [ 1, 2, 3, 4, 5, 6 ];
|
||||
var ixes = [];
|
||||
var ys = concatMap(xs, function (x, ix) {
|
||||
ixes.push(ix);
|
||||
return x % 2 ? [ x - 0.1, x, x + 0.1 ] : [];
|
||||
});
|
||||
t.same(ys, [ 0.9, 1, 1.1, 2.9, 3, 3.1, 4.9, 5, 5.1 ]);
|
||||
t.same(ixes, [ 0, 1, 2, 3, 4, 5 ]);
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('always something', function (t) {
|
||||
var xs = [ 'a', 'b', 'c', 'd' ];
|
||||
var ys = concatMap(xs, function (x) {
|
||||
return x === 'b' ? [ 'B', 'B', 'B' ] : [ x ];
|
||||
});
|
||||
t.same(ys, [ 'a', 'B', 'B', 'B', 'c', 'd' ]);
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('scalars', function (t) {
|
||||
var xs = [ 'a', 'b', 'c', 'd' ];
|
||||
var ys = concatMap(xs, function (x) {
|
||||
return x === 'b' ? [ 'B', 'B', 'B' ] : x;
|
||||
});
|
||||
t.same(ys, [ 'a', 'B', 'B', 'B', 'c', 'd' ]);
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('undefs', function (t) {
|
||||
var xs = [ 'a', 'b', 'c', 'd' ];
|
||||
var ys = concatMap(xs, function () {});
|
||||
t.same(ys, [ undefined, undefined, undefined, undefined ]);
|
||||
t.end();
|
||||
});
|
43
app/node_modules/fs.realpath/LICENSE
generated
vendored
43
app/node_modules/fs.realpath/LICENSE
generated
vendored
|
@ -1,43 +0,0 @@
|
|||
The ISC License
|
||||
|
||||
Copyright (c) Isaac Z. Schlueter and Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
----
|
||||
|
||||
This library bundles a version of the `fs.realpath` and `fs.realpathSync`
|
||||
methods from Node.js v0.10 under the terms of the Node.js MIT license.
|
||||
|
||||
Node's license follows, also included at the header of `old.js` which contains
|
||||
the licensed code:
|
||||
|
||||
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.
|
33
app/node_modules/fs.realpath/README.md
generated
vendored
33
app/node_modules/fs.realpath/README.md
generated
vendored
|
@ -1,33 +0,0 @@
|
|||
# fs.realpath
|
||||
|
||||
A backwards-compatible fs.realpath for Node v6 and above
|
||||
|
||||
In Node v6, the JavaScript implementation of fs.realpath was replaced
|
||||
with a faster (but less resilient) native implementation. That raises
|
||||
new and platform-specific errors and cannot handle long or excessively
|
||||
symlink-looping paths.
|
||||
|
||||
This module handles those cases by detecting the new errors and
|
||||
falling back to the JavaScript implementation. On versions of Node
|
||||
prior to v6, it has no effect.
|
||||
|
||||
## USAGE
|
||||
|
||||
```js
|
||||
var rp = require('fs.realpath')
|
||||
|
||||
// async version
|
||||
rp.realpath(someLongAndLoopingPath, function (er, real) {
|
||||
// the ELOOP was handled, but it was a bit slower
|
||||
})
|
||||
|
||||
// sync version
|
||||
var real = rp.realpathSync(someLongAndLoopingPath)
|
||||
|
||||
// monkeypatch at your own risk!
|
||||
// This replaces the fs.realpath/fs.realpathSync builtins
|
||||
rp.monkeypatch()
|
||||
|
||||
// un-do the monkeypatching
|
||||
rp.unmonkeypatch()
|
||||
```
|
66
app/node_modules/fs.realpath/index.js
generated
vendored
66
app/node_modules/fs.realpath/index.js
generated
vendored
|
@ -1,66 +0,0 @@
|
|||
module.exports = realpath
|
||||
realpath.realpath = realpath
|
||||
realpath.sync = realpathSync
|
||||
realpath.realpathSync = realpathSync
|
||||
realpath.monkeypatch = monkeypatch
|
||||
realpath.unmonkeypatch = unmonkeypatch
|
||||
|
||||
var fs = require('fs')
|
||||
var origRealpath = fs.realpath
|
||||
var origRealpathSync = fs.realpathSync
|
||||
|
||||
var version = process.version
|
||||
var ok = /^v[0-5]\./.test(version)
|
||||
var old = require('./old.js')
|
||||
|
||||
function newError (er) {
|
||||
return er && er.syscall === 'realpath' && (
|
||||
er.code === 'ELOOP' ||
|
||||
er.code === 'ENOMEM' ||
|
||||
er.code === 'ENAMETOOLONG'
|
||||
)
|
||||
}
|
||||
|
||||
function realpath (p, cache, cb) {
|
||||
if (ok) {
|
||||
return origRealpath(p, cache, cb)
|
||||
}
|
||||
|
||||
if (typeof cache === 'function') {
|
||||
cb = cache
|
||||
cache = null
|
||||
}
|
||||
origRealpath(p, cache, function (er, result) {
|
||||
if (newError(er)) {
|
||||
old.realpath(p, cache, cb)
|
||||
} else {
|
||||
cb(er, result)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function realpathSync (p, cache) {
|
||||
if (ok) {
|
||||
return origRealpathSync(p, cache)
|
||||
}
|
||||
|
||||
try {
|
||||
return origRealpathSync(p, cache)
|
||||
} catch (er) {
|
||||
if (newError(er)) {
|
||||
return old.realpathSync(p, cache)
|
||||
} else {
|
||||
throw er
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function monkeypatch () {
|
||||
fs.realpath = realpath
|
||||
fs.realpathSync = realpathSync
|
||||
}
|
||||
|
||||
function unmonkeypatch () {
|
||||
fs.realpath = origRealpath
|
||||
fs.realpathSync = origRealpathSync
|
||||
}
|
303
app/node_modules/fs.realpath/old.js
generated
vendored
303
app/node_modules/fs.realpath/old.js
generated
vendored
|
@ -1,303 +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 pathModule = require('path');
|
||||
var isWindows = process.platform === 'win32';
|
||||
var fs = require('fs');
|
||||
|
||||
// JavaScript implementation of realpath, ported from node pre-v6
|
||||
|
||||
var DEBUG = process.env.NODE_DEBUG && /fs/.test(process.env.NODE_DEBUG);
|
||||
|
||||
function rethrow() {
|
||||
// Only enable in debug mode. A backtrace uses ~1000 bytes of heap space and
|
||||
// is fairly slow to generate.
|
||||
var callback;
|
||||
if (DEBUG) {
|
||||
var backtrace = new Error;
|
||||
callback = debugCallback;
|
||||
} else
|
||||
callback = missingCallback;
|
||||
|
||||
return callback;
|
||||
|
||||
function debugCallback(err) {
|
||||
if (err) {
|
||||
backtrace.message = err.message;
|
||||
err = backtrace;
|
||||
missingCallback(err);
|
||||
}
|
||||
}
|
||||
|
||||
function missingCallback(err) {
|
||||
if (err) {
|
||||
if (process.throwDeprecation)
|
||||
throw err; // Forgot a callback but don't know where? Use NODE_DEBUG=fs
|
||||
else if (!process.noDeprecation) {
|
||||
var msg = 'fs: missing callback ' + (err.stack || err.message);
|
||||
if (process.traceDeprecation)
|
||||
console.trace(msg);
|
||||
else
|
||||
console.error(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function maybeCallback(cb) {
|
||||
return typeof cb === 'function' ? cb : rethrow();
|
||||
}
|
||||
|
||||
var normalize = pathModule.normalize;
|
||||
|
||||
// Regexp that finds the next partion of a (partial) path
|
||||
// result is [base_with_slash, base], e.g. ['somedir/', 'somedir']
|
||||
if (isWindows) {
|
||||
var nextPartRe = /(.*?)(?:[\/\\]+|$)/g;
|
||||
} else {
|
||||
var nextPartRe = /(.*?)(?:[\/]+|$)/g;
|
||||
}
|
||||
|
||||
// Regex to find the device root, including trailing slash. E.g. 'c:\\'.
|
||||
if (isWindows) {
|
||||
var splitRootRe = /^(?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?[\\\/]*/;
|
||||
} else {
|
||||
var splitRootRe = /^[\/]*/;
|
||||
}
|
||||
|
||||
exports.realpathSync = function realpathSync(p, cache) {
|
||||
// make p is absolute
|
||||
p = pathModule.resolve(p);
|
||||
|
||||
if (cache && Object.prototype.hasOwnProperty.call(cache, p)) {
|
||||
return cache[p];
|
||||
}
|
||||
|
||||
var original = p,
|
||||
seenLinks = {},
|
||||
knownHard = {};
|
||||
|
||||
// current character position in p
|
||||
var pos;
|
||||
// the partial path so far, including a trailing slash if any
|
||||
var current;
|
||||
// the partial path without a trailing slash (except when pointing at a root)
|
||||
var base;
|
||||
// the partial path scanned in the previous round, with slash
|
||||
var previous;
|
||||
|
||||
start();
|
||||
|
||||
function start() {
|
||||
// Skip over roots
|
||||
var m = splitRootRe.exec(p);
|
||||
pos = m[0].length;
|
||||
current = m[0];
|
||||
base = m[0];
|
||||
previous = '';
|
||||
|
||||
// On windows, check that the root exists. On unix there is no need.
|
||||
if (isWindows && !knownHard[base]) {
|
||||
fs.lstatSync(base);
|
||||
knownHard[base] = true;
|
||||
}
|
||||
}
|
||||
|
||||
// walk down the path, swapping out linked pathparts for their real
|
||||
// values
|
||||
// NB: p.length changes.
|
||||
while (pos < p.length) {
|
||||
// find the next part
|
||||
nextPartRe.lastIndex = pos;
|
||||
var result = nextPartRe.exec(p);
|
||||
previous = current;
|
||||
current += result[0];
|
||||
base = previous + result[1];
|
||||
pos = nextPartRe.lastIndex;
|
||||
|
||||
// continue if not a symlink
|
||||
if (knownHard[base] || (cache && cache[base] === base)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var resolvedLink;
|
||||
if (cache && Object.prototype.hasOwnProperty.call(cache, base)) {
|
||||
// some known symbolic link. no need to stat again.
|
||||
resolvedLink = cache[base];
|
||||
} else {
|
||||
var stat = fs.lstatSync(base);
|
||||
if (!stat.isSymbolicLink()) {
|
||||
knownHard[base] = true;
|
||||
if (cache) cache[base] = base;
|
||||
continue;
|
||||
}
|
||||
|
||||
// read the link if it wasn't read before
|
||||
// dev/ino always return 0 on windows, so skip the check.
|
||||
var linkTarget = null;
|
||||
if (!isWindows) {
|
||||
var id = stat.dev.toString(32) + ':' + stat.ino.toString(32);
|
||||
if (seenLinks.hasOwnProperty(id)) {
|
||||
linkTarget = seenLinks[id];
|
||||
}
|
||||
}
|
||||
if (linkTarget === null) {
|
||||
fs.statSync(base);
|
||||
linkTarget = fs.readlinkSync(base);
|
||||
}
|
||||
resolvedLink = pathModule.resolve(previous, linkTarget);
|
||||
// track this, if given a cache.
|
||||
if (cache) cache[base] = resolvedLink;
|
||||
if (!isWindows) seenLinks[id] = linkTarget;
|
||||
}
|
||||
|
||||
// resolve the link, then start over
|
||||
p = pathModule.resolve(resolvedLink, p.slice(pos));
|
||||
start();
|
||||
}
|
||||
|
||||
if (cache) cache[original] = p;
|
||||
|
||||
return p;
|
||||
};
|
||||
|
||||
|
||||
exports.realpath = function realpath(p, cache, cb) {
|
||||
if (typeof cb !== 'function') {
|
||||
cb = maybeCallback(cache);
|
||||
cache = null;
|
||||
}
|
||||
|
||||
// make p is absolute
|
||||
p = pathModule.resolve(p);
|
||||
|
||||
if (cache && Object.prototype.hasOwnProperty.call(cache, p)) {
|
||||
return process.nextTick(cb.bind(null, null, cache[p]));
|
||||
}
|
||||
|
||||
var original = p,
|
||||
seenLinks = {},
|
||||
knownHard = {};
|
||||
|
||||
// current character position in p
|
||||
var pos;
|
||||
// the partial path so far, including a trailing slash if any
|
||||
var current;
|
||||
// the partial path without a trailing slash (except when pointing at a root)
|
||||
var base;
|
||||
// the partial path scanned in the previous round, with slash
|
||||
var previous;
|
||||
|
||||
start();
|
||||
|
||||
function start() {
|
||||
// Skip over roots
|
||||
var m = splitRootRe.exec(p);
|
||||
pos = m[0].length;
|
||||
current = m[0];
|
||||
base = m[0];
|
||||
previous = '';
|
||||
|
||||
// On windows, check that the root exists. On unix there is no need.
|
||||
if (isWindows && !knownHard[base]) {
|
||||
fs.lstat(base, function(err) {
|
||||
if (err) return cb(err);
|
||||
knownHard[base] = true;
|
||||
LOOP();
|
||||
});
|
||||
} else {
|
||||
process.nextTick(LOOP);
|
||||
}
|
||||
}
|
||||
|
||||
// walk down the path, swapping out linked pathparts for their real
|
||||
// values
|
||||
function LOOP() {
|
||||
// stop if scanned past end of path
|
||||
if (pos >= p.length) {
|
||||
if (cache) cache[original] = p;
|
||||
return cb(null, p);
|
||||
}
|
||||
|
||||
// find the next part
|
||||
nextPartRe.lastIndex = pos;
|
||||
var result = nextPartRe.exec(p);
|
||||
previous = current;
|
||||
current += result[0];
|
||||
base = previous + result[1];
|
||||
pos = nextPartRe.lastIndex;
|
||||
|
||||
// continue if not a symlink
|
||||
if (knownHard[base] || (cache && cache[base] === base)) {
|
||||
return process.nextTick(LOOP);
|
||||
}
|
||||
|
||||
if (cache && Object.prototype.hasOwnProperty.call(cache, base)) {
|
||||
// known symbolic link. no need to stat again.
|
||||
return gotResolvedLink(cache[base]);
|
||||
}
|
||||
|
||||
return fs.lstat(base, gotStat);
|
||||
}
|
||||
|
||||
function gotStat(err, stat) {
|
||||
if (err) return cb(err);
|
||||
|
||||
// if not a symlink, skip to the next path part
|
||||
if (!stat.isSymbolicLink()) {
|
||||
knownHard[base] = true;
|
||||
if (cache) cache[base] = base;
|
||||
return process.nextTick(LOOP);
|
||||
}
|
||||
|
||||
// stat & read the link if not read before
|
||||
// call gotTarget as soon as the link target is known
|
||||
// dev/ino always return 0 on windows, so skip the check.
|
||||
if (!isWindows) {
|
||||
var id = stat.dev.toString(32) + ':' + stat.ino.toString(32);
|
||||
if (seenLinks.hasOwnProperty(id)) {
|
||||
return gotTarget(null, seenLinks[id], base);
|
||||
}
|
||||
}
|
||||
fs.stat(base, function(err) {
|
||||
if (err) return cb(err);
|
||||
|
||||
fs.readlink(base, function(err, target) {
|
||||
if (!isWindows) seenLinks[id] = target;
|
||||
gotTarget(err, target);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function gotTarget(err, target, base) {
|
||||
if (err) return cb(err);
|
||||
|
||||
var resolvedLink = pathModule.resolve(previous, target);
|
||||
if (cache) cache[base] = resolvedLink;
|
||||
gotResolvedLink(resolvedLink);
|
||||
}
|
||||
|
||||
function gotResolvedLink(resolvedLink) {
|
||||
// resolve the link, then start over
|
||||
p = pathModule.resolve(resolvedLink, p.slice(pos));
|
||||
start();
|
||||
}
|
||||
};
|
94
app/node_modules/fs.realpath/package.json
generated
vendored
94
app/node_modules/fs.realpath/package.json
generated
vendored
|
@ -1,94 +0,0 @@
|
|||
{
|
||||
"_args": [
|
||||
[
|
||||
{
|
||||
"raw": "fs.realpath@^1.0.0",
|
||||
"scope": null,
|
||||
"escapedName": "fs.realpath",
|
||||
"name": "fs.realpath",
|
||||
"rawSpec": "^1.0.0",
|
||||
"spec": ">=1.0.0 <2.0.0",
|
||||
"type": "range"
|
||||
},
|
||||
"C:\\Users\\ryuki\\TheDesk\\app\\node_modules\\glob"
|
||||
]
|
||||
],
|
||||
"_from": "fs.realpath@>=1.0.0 <2.0.0",
|
||||
"_id": "fs.realpath@1.0.0",
|
||||
"_inCache": true,
|
||||
"_location": "/fs.realpath",
|
||||
"_nodeVersion": "4.4.4",
|
||||
"_npmOperationalInternal": {
|
||||
"host": "packages-16-east.internal.npmjs.com",
|
||||
"tmp": "tmp/fs.realpath-1.0.0.tgz_1466015941059_0.3332864767871797"
|
||||
},
|
||||
"_npmUser": {
|
||||
"name": "isaacs",
|
||||
"email": "i@izs.me"
|
||||
},
|
||||
"_npmVersion": "3.9.1",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"raw": "fs.realpath@^1.0.0",
|
||||
"scope": null,
|
||||
"escapedName": "fs.realpath",
|
||||
"name": "fs.realpath",
|
||||
"rawSpec": "^1.0.0",
|
||||
"spec": ">=1.0.0 <2.0.0",
|
||||
"type": "range"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/glob"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
|
||||
"_shasum": "1504ad2523158caa40db4a2787cb01411994ea4f",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "fs.realpath@^1.0.0",
|
||||
"_where": "C:\\Users\\ryuki\\TheDesk\\app\\node_modules\\glob",
|
||||
"author": {
|
||||
"name": "Isaac Z. Schlueter",
|
||||
"email": "i@izs.me",
|
||||
"url": "http://blog.izs.me/"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/isaacs/fs.realpath/issues"
|
||||
},
|
||||
"dependencies": {},
|
||||
"description": "Use node's fs.realpath, but fall back to the JS implementation if the native one fails",
|
||||
"devDependencies": {},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "1504ad2523158caa40db4a2787cb01411994ea4f",
|
||||
"tarball": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz"
|
||||
},
|
||||
"files": [
|
||||
"old.js",
|
||||
"index.js"
|
||||
],
|
||||
"gitHead": "03e7c884431fe185dfebbc9b771aeca339c1807a",
|
||||
"homepage": "https://github.com/isaacs/fs.realpath#readme",
|
||||
"keywords": [
|
||||
"realpath",
|
||||
"fs",
|
||||
"polyfill"
|
||||
],
|
||||
"license": "ISC",
|
||||
"main": "index.js",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "isaacs",
|
||||
"email": "i@izs.me"
|
||||
}
|
||||
],
|
||||
"name": "fs.realpath",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/isaacs/fs.realpath.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "tap test/*.js --cov"
|
||||
},
|
||||
"version": "1.0.0"
|
||||
}
|
5
app/node_modules/fstream/.npmignore
generated
vendored
5
app/node_modules/fstream/.npmignore
generated
vendored
|
@ -1,5 +0,0 @@
|
|||
.*.swp
|
||||
node_modules/
|
||||
examples/deep-copy/
|
||||
examples/path/
|
||||
examples/filter-copy/
|
3
app/node_modules/fstream/.travis.yml
generated
vendored
3
app/node_modules/fstream/.travis.yml
generated
vendored
|
@ -1,3 +0,0 @@
|
|||
language: node_js
|
||||
node_js:
|
||||
- 0.6
|
27
app/node_modules/fstream/LICENSE
generated
vendored
27
app/node_modules/fstream/LICENSE
generated
vendored
|
@ -1,27 +0,0 @@
|
|||
Copyright (c) Isaac Z. Schlueter ("Author")
|
||||
All rights reserved.
|
||||
|
||||
The BSD License
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. 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.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 THE AUTHOR OR CONTRIBUTORS
|
||||
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.
|
76
app/node_modules/fstream/README.md
generated
vendored
76
app/node_modules/fstream/README.md
generated
vendored
|
@ -1,76 +0,0 @@
|
|||
Like FS streams, but with stat on them, and supporting directories and
|
||||
symbolic links, as well as normal files. Also, you can use this to set
|
||||
the stats on a file, even if you don't change its contents, or to create
|
||||
a symlink, etc.
|
||||
|
||||
So, for example, you can "write" a directory, and it'll call `mkdir`. You
|
||||
can specify a uid and gid, and it'll call `chown`. You can specify a
|
||||
`mtime` and `atime`, and it'll call `utimes`. You can call it a symlink
|
||||
and provide a `linkpath` and it'll call `symlink`.
|
||||
|
||||
Note that it won't automatically resolve symbolic links. So, if you
|
||||
call `fstream.Reader('/some/symlink')` then you'll get an object
|
||||
that stats and then ends immediately (since it has no data). To follow
|
||||
symbolic links, do this: `fstream.Reader({path:'/some/symlink', follow:
|
||||
true })`.
|
||||
|
||||
There are various checks to make sure that the bytes emitted are the
|
||||
same as the intended size, if the size is set.
|
||||
|
||||
## Examples
|
||||
|
||||
```javascript
|
||||
fstream
|
||||
.Writer({ path: "path/to/file"
|
||||
, mode: 0755
|
||||
, size: 6
|
||||
})
|
||||
.write("hello\n")
|
||||
.end()
|
||||
```
|
||||
|
||||
This will create the directories if they're missing, and then write
|
||||
`hello\n` into the file, chmod it to 0755, and assert that 6 bytes have
|
||||
been written when it's done.
|
||||
|
||||
```javascript
|
||||
fstream
|
||||
.Writer({ path: "path/to/file"
|
||||
, mode: 0755
|
||||
, size: 6
|
||||
, flags: "a"
|
||||
})
|
||||
.write("hello\n")
|
||||
.end()
|
||||
```
|
||||
|
||||
You can pass flags in, if you want to append to a file.
|
||||
|
||||
```javascript
|
||||
fstream
|
||||
.Writer({ path: "path/to/symlink"
|
||||
, linkpath: "./file"
|
||||
, SymbolicLink: true
|
||||
, mode: "0755" // octal strings supported
|
||||
})
|
||||
.end()
|
||||
```
|
||||
|
||||
If isSymbolicLink is a function, it'll be called, and if it returns
|
||||
true, then it'll treat it as a symlink. If it's not a function, then
|
||||
any truish value will make a symlink, or you can set `type:
|
||||
'SymbolicLink'`, which does the same thing.
|
||||
|
||||
Note that the linkpath is relative to the symbolic link location, not
|
||||
the parent dir or cwd.
|
||||
|
||||
```javascript
|
||||
fstream
|
||||
.Reader("path/to/dir")
|
||||
.pipe(fstream.Writer("path/to/other/dir"))
|
||||
```
|
||||
|
||||
This will do like `cp -Rp path/to/dir path/to/other/dir`. If the other
|
||||
dir exists and isn't a directory, then it'll emit an error. It'll also
|
||||
set the uid, gid, mode, etc. to be identical. In this way, it's more
|
||||
like `rsync -a` than simply a copy.
|
131
app/node_modules/fstream/examples/filter-pipe.js
generated
vendored
131
app/node_modules/fstream/examples/filter-pipe.js
generated
vendored
|
@ -1,131 +0,0 @@
|
|||
var fstream = require("../fstream.js")
|
||||
var path = require("path")
|
||||
|
||||
var r = fstream.Reader({ path: path.dirname(__dirname)
|
||||
, filter: function () {
|
||||
return !this.basename.match(/^\./) &&
|
||||
!this.basename.match(/^node_modules$/)
|
||||
!this.basename.match(/^deep-copy$/)
|
||||
!this.basename.match(/^filter-copy$/)
|
||||
}
|
||||
})
|
||||
|
||||
// this writer will only write directories
|
||||
var w = fstream.Writer({ path: path.resolve(__dirname, "filter-copy")
|
||||
, type: "Directory"
|
||||
, filter: function () {
|
||||
return this.type === "Directory"
|
||||
}
|
||||
})
|
||||
|
||||
var indent = ""
|
||||
var escape = {}
|
||||
|
||||
r.on("entry", appears)
|
||||
r.on("ready", function () {
|
||||
console.error("ready to begin!", r.path)
|
||||
})
|
||||
|
||||
function appears (entry) {
|
||||
console.error(indent + "a %s appears!", entry.type, entry.basename, typeof entry.basename)
|
||||
if (foggy) {
|
||||
console.error("FOGGY!")
|
||||
var p = entry
|
||||
do {
|
||||
console.error(p.depth, p.path, p._paused)
|
||||
} while (p = p.parent)
|
||||
|
||||
throw new Error("\033[mshould not have entries while foggy")
|
||||
}
|
||||
indent += "\t"
|
||||
entry.on("data", missile(entry))
|
||||
entry.on("end", runaway(entry))
|
||||
entry.on("entry", appears)
|
||||
}
|
||||
|
||||
var foggy
|
||||
function missile (entry) {
|
||||
if (entry.type === "Directory") {
|
||||
var ended = false
|
||||
entry.once("end", function () { ended = true })
|
||||
return function (c) {
|
||||
// throw in some pathological pause()/resume() behavior
|
||||
// just for extra fun.
|
||||
process.nextTick(function () {
|
||||
if (!foggy && !ended) { // && Math.random() < 0.3) {
|
||||
console.error(indent +"%s casts a spell", entry.basename)
|
||||
console.error("\na slowing fog comes over the battlefield...\n\033[32m")
|
||||
entry.pause()
|
||||
entry.once("resume", liftFog)
|
||||
foggy = setTimeout(liftFog, 1000)
|
||||
|
||||
function liftFog (who) {
|
||||
if (!foggy) return
|
||||
if (who) {
|
||||
console.error("%s breaks the spell!", who && who.path)
|
||||
} else {
|
||||
console.error("the spell expires!")
|
||||
}
|
||||
console.error("\033[mthe fog lifts!\n")
|
||||
clearTimeout(foggy)
|
||||
foggy = null
|
||||
if (entry._paused) entry.resume()
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return function (c) {
|
||||
var e = Math.random() < 0.5
|
||||
console.error(indent + "%s %s for %d damage!",
|
||||
entry.basename,
|
||||
e ? "is struck" : "fires a chunk",
|
||||
c.length)
|
||||
}
|
||||
}
|
||||
|
||||
function runaway (entry) { return function () {
|
||||
var e = Math.random() < 0.5
|
||||
console.error(indent + "%s %s",
|
||||
entry.basename,
|
||||
e ? "turns to flee" : "is vanquished!")
|
||||
indent = indent.slice(0, -1)
|
||||
}}
|
||||
|
||||
|
||||
w.on("entry", attacks)
|
||||
//w.on("ready", function () { attacks(w) })
|
||||
function attacks (entry) {
|
||||
console.error(indent + "%s %s!", entry.basename,
|
||||
entry.type === "Directory" ? "calls for backup" : "attacks")
|
||||
entry.on("entry", attacks)
|
||||
}
|
||||
|
||||
ended = false
|
||||
var i = 1
|
||||
r.on("end", function () {
|
||||
if (foggy) clearTimeout(foggy)
|
||||
console.error("\033[mIT'S OVER!!")
|
||||
console.error("A WINNAR IS YOU!")
|
||||
|
||||
console.log("ok " + (i ++) + " A WINNAR IS YOU")
|
||||
ended = true
|
||||
// now go through and verify that everything in there is a dir.
|
||||
var p = path.resolve(__dirname, "filter-copy")
|
||||
var checker = fstream.Reader({ path: p })
|
||||
checker.checker = true
|
||||
checker.on("child", function (e) {
|
||||
var ok = e.type === "Directory"
|
||||
console.log((ok ? "" : "not ") + "ok " + (i ++) +
|
||||
" should be a dir: " +
|
||||
e.path.substr(checker.path.length + 1))
|
||||
})
|
||||
})
|
||||
|
||||
process.on("exit", function () {
|
||||
console.log((ended ? "" : "not ") + "ok " + (i ++) + " ended")
|
||||
})
|
||||
|
||||
r.pipe(w)
|
115
app/node_modules/fstream/examples/pipe.js
generated
vendored
115
app/node_modules/fstream/examples/pipe.js
generated
vendored
|
@ -1,115 +0,0 @@
|
|||
var fstream = require("../fstream.js")
|
||||
var path = require("path")
|
||||
|
||||
var r = fstream.Reader({ path: path.dirname(__dirname)
|
||||
, filter: function () {
|
||||
return !this.basename.match(/^\./) &&
|
||||
!this.basename.match(/^node_modules$/)
|
||||
!this.basename.match(/^deep-copy$/)
|
||||
}
|
||||
})
|
||||
|
||||
var w = fstream.Writer({ path: path.resolve(__dirname, "deep-copy")
|
||||
, type: "Directory"
|
||||
})
|
||||
|
||||
var indent = ""
|
||||
var escape = {}
|
||||
|
||||
r.on("entry", appears)
|
||||
r.on("ready", function () {
|
||||
console.error("ready to begin!", r.path)
|
||||
})
|
||||
|
||||
function appears (entry) {
|
||||
console.error(indent + "a %s appears!", entry.type, entry.basename, typeof entry.basename, entry)
|
||||
if (foggy) {
|
||||
console.error("FOGGY!")
|
||||
var p = entry
|
||||
do {
|
||||
console.error(p.depth, p.path, p._paused)
|
||||
} while (p = p.parent)
|
||||
|
||||
throw new Error("\033[mshould not have entries while foggy")
|
||||
}
|
||||
indent += "\t"
|
||||
entry.on("data", missile(entry))
|
||||
entry.on("end", runaway(entry))
|
||||
entry.on("entry", appears)
|
||||
}
|
||||
|
||||
var foggy
|
||||
function missile (entry) {
|
||||
if (entry.type === "Directory") {
|
||||
var ended = false
|
||||
entry.once("end", function () { ended = true })
|
||||
return function (c) {
|
||||
// throw in some pathological pause()/resume() behavior
|
||||
// just for extra fun.
|
||||
process.nextTick(function () {
|
||||
if (!foggy && !ended) { // && Math.random() < 0.3) {
|
||||
console.error(indent +"%s casts a spell", entry.basename)
|
||||
console.error("\na slowing fog comes over the battlefield...\n\033[32m")
|
||||
entry.pause()
|
||||
entry.once("resume", liftFog)
|
||||
foggy = setTimeout(liftFog, 10)
|
||||
|
||||
function liftFog (who) {
|
||||
if (!foggy) return
|
||||
if (who) {
|
||||
console.error("%s breaks the spell!", who && who.path)
|
||||
} else {
|
||||
console.error("the spell expires!")
|
||||
}
|
||||
console.error("\033[mthe fog lifts!\n")
|
||||
clearTimeout(foggy)
|
||||
foggy = null
|
||||
if (entry._paused) entry.resume()
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return function (c) {
|
||||
var e = Math.random() < 0.5
|
||||
console.error(indent + "%s %s for %d damage!",
|
||||
entry.basename,
|
||||
e ? "is struck" : "fires a chunk",
|
||||
c.length)
|
||||
}
|
||||
}
|
||||
|
||||
function runaway (entry) { return function () {
|
||||
var e = Math.random() < 0.5
|
||||
console.error(indent + "%s %s",
|
||||
entry.basename,
|
||||
e ? "turns to flee" : "is vanquished!")
|
||||
indent = indent.slice(0, -1)
|
||||
}}
|
||||
|
||||
|
||||
w.on("entry", attacks)
|
||||
//w.on("ready", function () { attacks(w) })
|
||||
function attacks (entry) {
|
||||
console.error(indent + "%s %s!", entry.basename,
|
||||
entry.type === "Directory" ? "calls for backup" : "attacks")
|
||||
entry.on("entry", attacks)
|
||||
}
|
||||
|
||||
ended = false
|
||||
r.on("end", function () {
|
||||
if (foggy) clearTimeout(foggy)
|
||||
console.error("\033[mIT'S OVER!!")
|
||||
console.error("A WINNAR IS YOU!")
|
||||
|
||||
console.log("ok 1 A WINNAR IS YOU")
|
||||
ended = true
|
||||
})
|
||||
|
||||
process.on("exit", function () {
|
||||
console.log((ended ? "" : "not ") + "ok 2 ended")
|
||||
})
|
||||
|
||||
r.pipe(w)
|
54
app/node_modules/fstream/examples/reader.js
generated
vendored
54
app/node_modules/fstream/examples/reader.js
generated
vendored
|
@ -1,54 +0,0 @@
|
|||
var fstream = require("../fstream.js")
|
||||
var tap = require("tap")
|
||||
var fs = require("fs")
|
||||
var path = require("path")
|
||||
var children = -1
|
||||
var dir = path.dirname(__dirname)
|
||||
|
||||
var gotReady = false
|
||||
var ended = false
|
||||
|
||||
tap.test("reader test", function (t) {
|
||||
|
||||
var r = fstream.Reader({ path: dir
|
||||
, filter: function () {
|
||||
// return this.parent === r
|
||||
return this.parent === r || this === r
|
||||
}
|
||||
})
|
||||
|
||||
r.on("ready", function () {
|
||||
gotReady = true
|
||||
children = fs.readdirSync(dir).length
|
||||
console.error("Setting expected children to "+children)
|
||||
t.equal(r.type, "Directory", "should be a directory")
|
||||
})
|
||||
|
||||
r.on("entry", function (entry) {
|
||||
children --
|
||||
if (!gotReady) {
|
||||
t.fail("children before ready!")
|
||||
}
|
||||
t.equal(entry.dirname, r.path, "basename is parent dir")
|
||||
})
|
||||
|
||||
r.on("error", function (er) {
|
||||
t.fail(er)
|
||||
t.end()
|
||||
process.exit(1)
|
||||
})
|
||||
|
||||
r.on("end", function () {
|
||||
t.equal(children, 0, "should have seen all children")
|
||||
ended = true
|
||||
})
|
||||
|
||||
var closed = false
|
||||
r.on("close", function () {
|
||||
t.ok(ended, "saw end before close")
|
||||
t.notOk(closed, "close should only happen once")
|
||||
closed = true
|
||||
t.end()
|
||||
})
|
||||
|
||||
})
|
24
app/node_modules/fstream/examples/symlink-write.js
generated
vendored
24
app/node_modules/fstream/examples/symlink-write.js
generated
vendored
|
@ -1,24 +0,0 @@
|
|||
var fstream = require("../fstream.js")
|
||||
, closed = false
|
||||
|
||||
fstream
|
||||
.Writer({ path: "path/to/symlink"
|
||||
, linkpath: "./file"
|
||||
, isSymbolicLink: true
|
||||
, mode: "0755" // octal strings supported
|
||||
})
|
||||
.on("close", function () {
|
||||
closed = true
|
||||
var fs = require("fs")
|
||||
var s = fs.lstatSync("path/to/symlink")
|
||||
var isSym = s.isSymbolicLink()
|
||||
console.log((isSym?"":"not ") +"ok 1 should be symlink")
|
||||
var t = fs.readlinkSync("path/to/symlink")
|
||||
var isTarget = t === "./file"
|
||||
console.log((isTarget?"":"not ") +"ok 2 should link to ./file")
|
||||
})
|
||||
.end()
|
||||
|
||||
process.on("exit", function () {
|
||||
console.log((closed?"":"not ")+"ok 3 should be closed")
|
||||
})
|
31
app/node_modules/fstream/fstream.js
generated
vendored
31
app/node_modules/fstream/fstream.js
generated
vendored
|
@ -1,31 +0,0 @@
|
|||
exports.Abstract = require("./lib/abstract.js")
|
||||
exports.Reader = require("./lib/reader.js")
|
||||
exports.Writer = require("./lib/writer.js")
|
||||
|
||||
exports.File =
|
||||
{ Reader: require("./lib/file-reader.js")
|
||||
, Writer: require("./lib/file-writer.js") }
|
||||
|
||||
exports.Dir =
|
||||
{ Reader : require("./lib/dir-reader.js")
|
||||
, Writer : require("./lib/dir-writer.js") }
|
||||
|
||||
exports.Link =
|
||||
{ Reader : require("./lib/link-reader.js")
|
||||
, Writer : require("./lib/link-writer.js") }
|
||||
|
||||
exports.Proxy =
|
||||
{ Reader : require("./lib/proxy-reader.js")
|
||||
, Writer : require("./lib/proxy-writer.js") }
|
||||
|
||||
exports.Reader.Dir = exports.DirReader = exports.Dir.Reader
|
||||
exports.Reader.File = exports.FileReader = exports.File.Reader
|
||||
exports.Reader.Link = exports.LinkReader = exports.Link.Reader
|
||||
exports.Reader.Proxy = exports.ProxyReader = exports.Proxy.Reader
|
||||
|
||||
exports.Writer.Dir = exports.DirWriter = exports.Dir.Writer
|
||||
exports.Writer.File = exports.FileWriter = exports.File.Writer
|
||||
exports.Writer.Link = exports.LinkWriter = exports.Link.Writer
|
||||
exports.Writer.Proxy = exports.ProxyWriter = exports.Proxy.Writer
|
||||
|
||||
exports.collect = require("./lib/collect.js")
|
85
app/node_modules/fstream/lib/abstract.js
generated
vendored
85
app/node_modules/fstream/lib/abstract.js
generated
vendored
|
@ -1,85 +0,0 @@
|
|||
// the parent class for all fstreams.
|
||||
|
||||
module.exports = Abstract
|
||||
|
||||
var Stream = require("stream").Stream
|
||||
, inherits = require("inherits")
|
||||
|
||||
function Abstract () {
|
||||
Stream.call(this)
|
||||
}
|
||||
|
||||
inherits(Abstract, Stream)
|
||||
|
||||
Abstract.prototype.on = function (ev, fn) {
|
||||
if (ev === "ready" && this.ready) {
|
||||
process.nextTick(fn.bind(this))
|
||||
} else {
|
||||
Stream.prototype.on.call(this, ev, fn)
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
||||
Abstract.prototype.abort = function () {
|
||||
this._aborted = true
|
||||
this.emit("abort")
|
||||
}
|
||||
|
||||
Abstract.prototype.destroy = function () {}
|
||||
|
||||
Abstract.prototype.warn = function (msg, code) {
|
||||
var me = this
|
||||
, er = decorate(msg, code, me)
|
||||
if (!me.listeners("warn")) {
|
||||
console.error("%s %s\n" +
|
||||
"path = %s\n" +
|
||||
"syscall = %s\n" +
|
||||
"fstream_type = %s\n" +
|
||||
"fstream_path = %s\n" +
|
||||
"fstream_unc_path = %s\n" +
|
||||
"fstream_class = %s\n" +
|
||||
"fstream_stack =\n%s\n",
|
||||
code || "UNKNOWN",
|
||||
er.stack,
|
||||
er.path,
|
||||
er.syscall,
|
||||
er.fstream_type,
|
||||
er.fstream_path,
|
||||
er.fstream_unc_path,
|
||||
er.fstream_class,
|
||||
er.fstream_stack.join("\n"))
|
||||
} else {
|
||||
me.emit("warn", er)
|
||||
}
|
||||
}
|
||||
|
||||
Abstract.prototype.info = function (msg, code) {
|
||||
this.emit("info", msg, code)
|
||||
}
|
||||
|
||||
Abstract.prototype.error = function (msg, code, th) {
|
||||
var er = decorate(msg, code, this)
|
||||
if (th) throw er
|
||||
else this.emit("error", er)
|
||||
}
|
||||
|
||||
function decorate (er, code, me) {
|
||||
if (!(er instanceof Error)) er = new Error(er)
|
||||
er.code = er.code || code
|
||||
er.path = er.path || me.path
|
||||
er.fstream_type = er.fstream_type || me.type
|
||||
er.fstream_path = er.fstream_path || me.path
|
||||
if (me._path !== me.path) {
|
||||
er.fstream_unc_path = er.fstream_unc_path || me._path
|
||||
}
|
||||
if (me.linkpath) {
|
||||
er.fstream_linkpath = er.fstream_linkpath || me.linkpath
|
||||
}
|
||||
er.fstream_class = er.fstream_class || me.constructor.name
|
||||
er.fstream_stack = er.fstream_stack ||
|
||||
new Error().stack.split(/\n/).slice(3).map(function (s) {
|
||||
return s.replace(/^ at /, "")
|
||||
})
|
||||
|
||||
return er
|
||||
}
|
67
app/node_modules/fstream/lib/collect.js
generated
vendored
67
app/node_modules/fstream/lib/collect.js
generated
vendored
|
@ -1,67 +0,0 @@
|
|||
module.exports = collect
|
||||
|
||||
function collect (stream) {
|
||||
if (stream._collected) return
|
||||
|
||||
stream._collected = true
|
||||
stream.pause()
|
||||
|
||||
stream.on("data", save)
|
||||
stream.on("end", save)
|
||||
var buf = []
|
||||
function save (b) {
|
||||
if (typeof b === "string") b = new Buffer(b)
|
||||
if (Buffer.isBuffer(b) && !b.length) return
|
||||
buf.push(b)
|
||||
}
|
||||
|
||||
stream.on("entry", saveEntry)
|
||||
var entryBuffer = []
|
||||
function saveEntry (e) {
|
||||
collect(e)
|
||||
entryBuffer.push(e)
|
||||
}
|
||||
|
||||
stream.on("proxy", proxyPause)
|
||||
function proxyPause (p) {
|
||||
p.pause()
|
||||
}
|
||||
|
||||
|
||||
// replace the pipe method with a new version that will
|
||||
// unlock the buffered stuff. if you just call .pipe()
|
||||
// without a destination, then it'll re-play the events.
|
||||
stream.pipe = (function (orig) { return function (dest) {
|
||||
// console.error(" === open the pipes", dest && dest.path)
|
||||
|
||||
// let the entries flow through one at a time.
|
||||
// Once they're all done, then we can resume completely.
|
||||
var e = 0
|
||||
;(function unblockEntry () {
|
||||
var entry = entryBuffer[e++]
|
||||
// console.error(" ==== unblock entry", entry && entry.path)
|
||||
if (!entry) return resume()
|
||||
entry.on("end", unblockEntry)
|
||||
if (dest) dest.add(entry)
|
||||
else stream.emit("entry", entry)
|
||||
})()
|
||||
|
||||
function resume () {
|
||||
stream.removeListener("entry", saveEntry)
|
||||
stream.removeListener("data", save)
|
||||
stream.removeListener("end", save)
|
||||
|
||||
stream.pipe = orig
|
||||
if (dest) stream.pipe(dest)
|
||||
|
||||
buf.forEach(function (b) {
|
||||
if (b) stream.emit("data", b)
|
||||
else stream.emit("end")
|
||||
})
|
||||
|
||||
stream.resume()
|
||||
}
|
||||
|
||||
return dest
|
||||
}})(stream.pipe)
|
||||
}
|
251
app/node_modules/fstream/lib/dir-reader.js
generated
vendored
251
app/node_modules/fstream/lib/dir-reader.js
generated
vendored
|
@ -1,251 +0,0 @@
|
|||
// A thing that emits "entry" events with Reader objects
|
||||
// Pausing it causes it to stop emitting entry events, and also
|
||||
// pauses the current entry if there is one.
|
||||
|
||||
module.exports = DirReader
|
||||
|
||||
var fs = require("graceful-fs")
|
||||
, fstream = require("../fstream.js")
|
||||
, Reader = fstream.Reader
|
||||
, inherits = require("inherits")
|
||||
, mkdir = require("mkdirp")
|
||||
, path = require("path")
|
||||
, Reader = require("./reader.js")
|
||||
, assert = require("assert").ok
|
||||
|
||||
inherits(DirReader, Reader)
|
||||
|
||||
function DirReader (props) {
|
||||
var me = this
|
||||
if (!(me instanceof DirReader)) throw new Error(
|
||||
"DirReader must be called as constructor.")
|
||||
|
||||
// should already be established as a Directory type
|
||||
if (props.type !== "Directory" || !props.Directory) {
|
||||
throw new Error("Non-directory type "+ props.type)
|
||||
}
|
||||
|
||||
me.entries = null
|
||||
me._index = -1
|
||||
me._paused = false
|
||||
me._length = -1
|
||||
|
||||
if (props.sort) {
|
||||
this.sort = props.sort
|
||||
}
|
||||
|
||||
Reader.call(this, props)
|
||||
}
|
||||
|
||||
DirReader.prototype._getEntries = function () {
|
||||
var me = this
|
||||
|
||||
// race condition. might pause() before calling _getEntries,
|
||||
// and then resume, and try to get them a second time.
|
||||
if (me._gotEntries) return
|
||||
me._gotEntries = true
|
||||
|
||||
fs.readdir(me._path, function (er, entries) {
|
||||
if (er) return me.error(er)
|
||||
|
||||
me.entries = entries
|
||||
|
||||
me.emit("entries", entries)
|
||||
if (me._paused) me.once("resume", processEntries)
|
||||
else processEntries()
|
||||
|
||||
function processEntries () {
|
||||
me._length = me.entries.length
|
||||
if (typeof me.sort === "function") {
|
||||
me.entries = me.entries.sort(me.sort.bind(me))
|
||||
}
|
||||
me._read()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// start walking the dir, and emit an "entry" event for each one.
|
||||
DirReader.prototype._read = function () {
|
||||
var me = this
|
||||
|
||||
if (!me.entries) return me._getEntries()
|
||||
|
||||
if (me._paused || me._currentEntry || me._aborted) {
|
||||
// console.error("DR paused=%j, current=%j, aborted=%j", me._paused, !!me._currentEntry, me._aborted)
|
||||
return
|
||||
}
|
||||
|
||||
me._index ++
|
||||
if (me._index >= me.entries.length) {
|
||||
if (!me._ended) {
|
||||
me._ended = true
|
||||
me.emit("end")
|
||||
me.emit("close")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// ok, handle this one, then.
|
||||
|
||||
// save creating a proxy, by stat'ing the thing now.
|
||||
var p = path.resolve(me._path, me.entries[me._index])
|
||||
assert(p !== me._path)
|
||||
assert(me.entries[me._index])
|
||||
|
||||
// set this to prevent trying to _read() again in the stat time.
|
||||
me._currentEntry = p
|
||||
fs[ me.props.follow ? "stat" : "lstat" ](p, function (er, stat) {
|
||||
if (er) return me.error(er)
|
||||
|
||||
var who = me._proxy || me
|
||||
|
||||
stat.path = p
|
||||
stat.basename = path.basename(p)
|
||||
stat.dirname = path.dirname(p)
|
||||
var childProps = me.getChildProps.call(who, stat)
|
||||
childProps.path = p
|
||||
childProps.basename = path.basename(p)
|
||||
childProps.dirname = path.dirname(p)
|
||||
|
||||
var entry = Reader(childProps, stat)
|
||||
|
||||
// console.error("DR Entry", p, stat.size)
|
||||
|
||||
me._currentEntry = entry
|
||||
|
||||
// "entry" events are for direct entries in a specific dir.
|
||||
// "child" events are for any and all children at all levels.
|
||||
// This nomenclature is not completely final.
|
||||
|
||||
entry.on("pause", function (who) {
|
||||
if (!me._paused && !entry._disowned) {
|
||||
me.pause(who)
|
||||
}
|
||||
})
|
||||
|
||||
entry.on("resume", function (who) {
|
||||
if (me._paused && !entry._disowned) {
|
||||
me.resume(who)
|
||||
}
|
||||
})
|
||||
|
||||
entry.on("stat", function (props) {
|
||||
me.emit("_entryStat", entry, props)
|
||||
if (entry._aborted) return
|
||||
if (entry._paused) entry.once("resume", function () {
|
||||
me.emit("entryStat", entry, props)
|
||||
})
|
||||
else me.emit("entryStat", entry, props)
|
||||
})
|
||||
|
||||
entry.on("ready", function EMITCHILD () {
|
||||
// console.error("DR emit child", entry._path)
|
||||
if (me._paused) {
|
||||
// console.error(" DR emit child - try again later")
|
||||
// pause the child, and emit the "entry" event once we drain.
|
||||
// console.error("DR pausing child entry")
|
||||
entry.pause(me)
|
||||
return me.once("resume", EMITCHILD)
|
||||
}
|
||||
|
||||
// skip over sockets. they can't be piped around properly,
|
||||
// so there's really no sense even acknowledging them.
|
||||
// if someone really wants to see them, they can listen to
|
||||
// the "socket" events.
|
||||
if (entry.type === "Socket") {
|
||||
me.emit("socket", entry)
|
||||
} else {
|
||||
me.emitEntry(entry)
|
||||
}
|
||||
})
|
||||
|
||||
var ended = false
|
||||
entry.on("close", onend)
|
||||
entry.on("disown", onend)
|
||||
function onend () {
|
||||
if (ended) return
|
||||
ended = true
|
||||
me.emit("childEnd", entry)
|
||||
me.emit("entryEnd", entry)
|
||||
me._currentEntry = null
|
||||
if (!me._paused) {
|
||||
me._read()
|
||||
}
|
||||
}
|
||||
|
||||
// XXX Remove this. Works in node as of 0.6.2 or so.
|
||||
// Long filenames should not break stuff.
|
||||
entry.on("error", function (er) {
|
||||
if (entry._swallowErrors) {
|
||||
me.warn(er)
|
||||
entry.emit("end")
|
||||
entry.emit("close")
|
||||
} else {
|
||||
me.emit("error", er)
|
||||
}
|
||||
})
|
||||
|
||||
// proxy up some events.
|
||||
; [ "child"
|
||||
, "childEnd"
|
||||
, "warn"
|
||||
].forEach(function (ev) {
|
||||
entry.on(ev, me.emit.bind(me, ev))
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
DirReader.prototype.disown = function (entry) {
|
||||
entry.emit("beforeDisown")
|
||||
entry._disowned = true
|
||||
entry.parent = entry.root = null
|
||||
if (entry === this._currentEntry) {
|
||||
this._currentEntry = null
|
||||
}
|
||||
entry.emit("disown")
|
||||
}
|
||||
|
||||
DirReader.prototype.getChildProps = function (stat) {
|
||||
return { depth: this.depth + 1
|
||||
, root: this.root || this
|
||||
, parent: this
|
||||
, follow: this.follow
|
||||
, filter: this.filter
|
||||
, sort: this.props.sort
|
||||
, hardlinks: this.props.hardlinks
|
||||
}
|
||||
}
|
||||
|
||||
DirReader.prototype.pause = function (who) {
|
||||
var me = this
|
||||
if (me._paused) return
|
||||
who = who || me
|
||||
me._paused = true
|
||||
if (me._currentEntry && me._currentEntry.pause) {
|
||||
me._currentEntry.pause(who)
|
||||
}
|
||||
me.emit("pause", who)
|
||||
}
|
||||
|
||||
DirReader.prototype.resume = function (who) {
|
||||
var me = this
|
||||
if (!me._paused) return
|
||||
who = who || me
|
||||
|
||||
me._paused = false
|
||||
// console.error("DR Emit Resume", me._path)
|
||||
me.emit("resume", who)
|
||||
if (me._paused) {
|
||||
// console.error("DR Re-paused", me._path)
|
||||
return
|
||||
}
|
||||
|
||||
if (me._currentEntry) {
|
||||
if (me._currentEntry.resume) me._currentEntry.resume(who)
|
||||
} else me._read()
|
||||
}
|
||||
|
||||
DirReader.prototype.emitEntry = function (entry) {
|
||||
this.emit("entry", entry)
|
||||
this.emit("child", entry)
|
||||
}
|
171
app/node_modules/fstream/lib/dir-writer.js
generated
vendored
171
app/node_modules/fstream/lib/dir-writer.js
generated
vendored
|
@ -1,171 +0,0 @@
|
|||
// It is expected that, when .add() returns false, the consumer
|
||||
// of the DirWriter will pause until a "drain" event occurs. Note
|
||||
// that this is *almost always going to be the case*, unless the
|
||||
// thing being written is some sort of unsupported type, and thus
|
||||
// skipped over.
|
||||
|
||||
module.exports = DirWriter
|
||||
|
||||
var fs = require("graceful-fs")
|
||||
, fstream = require("../fstream.js")
|
||||
, Writer = require("./writer.js")
|
||||
, inherits = require("inherits")
|
||||
, mkdir = require("mkdirp")
|
||||
, path = require("path")
|
||||
, collect = require("./collect.js")
|
||||
|
||||
inherits(DirWriter, Writer)
|
||||
|
||||
function DirWriter (props) {
|
||||
var me = this
|
||||
if (!(me instanceof DirWriter)) me.error(
|
||||
"DirWriter must be called as constructor.", null, true)
|
||||
|
||||
// should already be established as a Directory type
|
||||
if (props.type !== "Directory" || !props.Directory) {
|
||||
me.error("Non-directory type "+ props.type + " " +
|
||||
JSON.stringify(props), null, true)
|
||||
}
|
||||
|
||||
Writer.call(this, props)
|
||||
}
|
||||
|
||||
DirWriter.prototype._create = function () {
|
||||
var me = this
|
||||
mkdir(me._path, Writer.dirmode, function (er) {
|
||||
if (er) return me.error(er)
|
||||
// ready to start getting entries!
|
||||
me.ready = true
|
||||
me.emit("ready")
|
||||
me._process()
|
||||
})
|
||||
}
|
||||
|
||||
// a DirWriter has an add(entry) method, but its .write() doesn't
|
||||
// do anything. Why a no-op rather than a throw? Because this
|
||||
// leaves open the door for writing directory metadata for
|
||||
// gnu/solaris style dumpdirs.
|
||||
DirWriter.prototype.write = function () {
|
||||
return true
|
||||
}
|
||||
|
||||
DirWriter.prototype.end = function () {
|
||||
this._ended = true
|
||||
this._process()
|
||||
}
|
||||
|
||||
DirWriter.prototype.add = function (entry) {
|
||||
var me = this
|
||||
|
||||
// console.error("\tadd", entry._path, "->", me._path)
|
||||
collect(entry)
|
||||
if (!me.ready || me._currentEntry) {
|
||||
me._buffer.push(entry)
|
||||
return false
|
||||
}
|
||||
|
||||
// create a new writer, and pipe the incoming entry into it.
|
||||
if (me._ended) {
|
||||
return me.error("add after end")
|
||||
}
|
||||
|
||||
me._buffer.push(entry)
|
||||
me._process()
|
||||
|
||||
return 0 === this._buffer.length
|
||||
}
|
||||
|
||||
DirWriter.prototype._process = function () {
|
||||
var me = this
|
||||
|
||||
// console.error("DW Process p=%j", me._processing, me.basename)
|
||||
|
||||
if (me._processing) return
|
||||
|
||||
var entry = me._buffer.shift()
|
||||
if (!entry) {
|
||||
// console.error("DW Drain")
|
||||
me.emit("drain")
|
||||
if (me._ended) me._finish()
|
||||
return
|
||||
}
|
||||
|
||||
me._processing = true
|
||||
// console.error("DW Entry", entry._path)
|
||||
|
||||
me.emit("entry", entry)
|
||||
|
||||
// ok, add this entry
|
||||
//
|
||||
// don't allow recursive copying
|
||||
var p = entry
|
||||
do {
|
||||
var pp = p._path || p.path
|
||||
if (pp === me.root._path || pp === me._path ||
|
||||
(pp && pp.indexOf(me._path) === 0)) {
|
||||
// console.error("DW Exit (recursive)", entry.basename, me._path)
|
||||
me._processing = false
|
||||
if (entry._collected) entry.pipe()
|
||||
return me._process()
|
||||
}
|
||||
} while (p = p.parent)
|
||||
|
||||
// console.error("DW not recursive")
|
||||
|
||||
// chop off the entry's root dir, replace with ours
|
||||
var props = { parent: me
|
||||
, root: me.root || me
|
||||
, type: entry.type
|
||||
, depth: me.depth + 1 }
|
||||
|
||||
var p = entry._path || entry.path || entry.props.path
|
||||
if (entry.parent) {
|
||||
p = p.substr(entry.parent._path.length + 1)
|
||||
}
|
||||
// get rid of any ../../ shenanigans
|
||||
props.path = path.join(me.path, path.join("/", p))
|
||||
|
||||
// if i have a filter, the child should inherit it.
|
||||
props.filter = me.filter
|
||||
|
||||
// all the rest of the stuff, copy over from the source.
|
||||
Object.keys(entry.props).forEach(function (k) {
|
||||
if (!props.hasOwnProperty(k)) {
|
||||
props[k] = entry.props[k]
|
||||
}
|
||||
})
|
||||
|
||||
// not sure at this point what kind of writer this is.
|
||||
var child = me._currentChild = new Writer(props)
|
||||
child.on("ready", function () {
|
||||
// console.error("DW Child Ready", child.type, child._path)
|
||||
// console.error(" resuming", entry._path)
|
||||
entry.pipe(child)
|
||||
entry.resume()
|
||||
})
|
||||
|
||||
// XXX Make this work in node.
|
||||
// Long filenames should not break stuff.
|
||||
child.on("error", function (er) {
|
||||
if (child._swallowErrors) {
|
||||
me.warn(er)
|
||||
child.emit("end")
|
||||
child.emit("close")
|
||||
} else {
|
||||
me.emit("error", er)
|
||||
}
|
||||
})
|
||||
|
||||
// we fire _end internally *after* end, so that we don't move on
|
||||
// until any "end" listeners have had their chance to do stuff.
|
||||
child.on("close", onend)
|
||||
var ended = false
|
||||
function onend () {
|
||||
if (ended) return
|
||||
ended = true
|
||||
// console.error("* DW Child end", child.basename)
|
||||
me._currentChild = null
|
||||
me._processing = false
|
||||
me._process()
|
||||
}
|
||||
}
|
147
app/node_modules/fstream/lib/file-reader.js
generated
vendored
147
app/node_modules/fstream/lib/file-reader.js
generated
vendored
|
@ -1,147 +0,0 @@
|
|||
// Basically just a wrapper around an fs.ReadStream
|
||||
|
||||
module.exports = FileReader
|
||||
|
||||
var fs = require("graceful-fs")
|
||||
, fstream = require("../fstream.js")
|
||||
, Reader = fstream.Reader
|
||||
, inherits = require("inherits")
|
||||
, mkdir = require("mkdirp")
|
||||
, Reader = require("./reader.js")
|
||||
, EOF = {EOF: true}
|
||||
, CLOSE = {CLOSE: true}
|
||||
|
||||
inherits(FileReader, Reader)
|
||||
|
||||
function FileReader (props) {
|
||||
// console.error(" FR create", props.path, props.size, new Error().stack)
|
||||
var me = this
|
||||
if (!(me instanceof FileReader)) throw new Error(
|
||||
"FileReader must be called as constructor.")
|
||||
|
||||
// should already be established as a File type
|
||||
// XXX Todo: preserve hardlinks by tracking dev+inode+nlink,
|
||||
// with a HardLinkReader class.
|
||||
if (!((props.type === "Link" && props.Link) ||
|
||||
(props.type === "File" && props.File))) {
|
||||
throw new Error("Non-file type "+ props.type)
|
||||
}
|
||||
|
||||
me._buffer = []
|
||||
me._bytesEmitted = 0
|
||||
Reader.call(me, props)
|
||||
}
|
||||
|
||||
FileReader.prototype._getStream = function () {
|
||||
var me = this
|
||||
, stream = me._stream = fs.createReadStream(me._path, me.props)
|
||||
|
||||
if (me.props.blksize) {
|
||||
stream.bufferSize = me.props.blksize
|
||||
}
|
||||
|
||||
stream.on("open", me.emit.bind(me, "open"))
|
||||
|
||||
stream.on("data", function (c) {
|
||||
// console.error("\t\t%d %s", c.length, me.basename)
|
||||
me._bytesEmitted += c.length
|
||||
// no point saving empty chunks
|
||||
if (!c.length) return
|
||||
else if (me._paused || me._buffer.length) {
|
||||
me._buffer.push(c)
|
||||
me._read()
|
||||
} else me.emit("data", c)
|
||||
})
|
||||
|
||||
stream.on("end", function () {
|
||||
if (me._paused || me._buffer.length) {
|
||||
// console.error("FR Buffering End", me._path)
|
||||
me._buffer.push(EOF)
|
||||
me._read()
|
||||
} else {
|
||||
me.emit("end")
|
||||
}
|
||||
|
||||
if (me._bytesEmitted !== me.props.size) {
|
||||
me.error("Didn't get expected byte count\n"+
|
||||
"expect: "+me.props.size + "\n" +
|
||||
"actual: "+me._bytesEmitted)
|
||||
}
|
||||
})
|
||||
|
||||
stream.on("close", function () {
|
||||
if (me._paused || me._buffer.length) {
|
||||
// console.error("FR Buffering Close", me._path)
|
||||
me._buffer.push(CLOSE)
|
||||
me._read()
|
||||
} else {
|
||||
// console.error("FR close 1", me._path)
|
||||
me.emit("close")
|
||||
}
|
||||
})
|
||||
|
||||
me._read()
|
||||
}
|
||||
|
||||
FileReader.prototype._read = function () {
|
||||
var me = this
|
||||
// console.error("FR _read", me._path)
|
||||
if (me._paused) {
|
||||
// console.error("FR _read paused", me._path)
|
||||
return
|
||||
}
|
||||
|
||||
if (!me._stream) {
|
||||
// console.error("FR _getStream calling", me._path)
|
||||
return me._getStream()
|
||||
}
|
||||
|
||||
// clear out the buffer, if there is one.
|
||||
if (me._buffer.length) {
|
||||
// console.error("FR _read has buffer", me._buffer.length, me._path)
|
||||
var buf = me._buffer
|
||||
for (var i = 0, l = buf.length; i < l; i ++) {
|
||||
var c = buf[i]
|
||||
if (c === EOF) {
|
||||
// console.error("FR Read emitting buffered end", me._path)
|
||||
me.emit("end")
|
||||
} else if (c === CLOSE) {
|
||||
// console.error("FR Read emitting buffered close", me._path)
|
||||
me.emit("close")
|
||||
} else {
|
||||
// console.error("FR Read emitting buffered data", me._path)
|
||||
me.emit("data", c)
|
||||
}
|
||||
|
||||
if (me._paused) {
|
||||
// console.error("FR Read Re-pausing at "+i, me._path)
|
||||
me._buffer = buf.slice(i)
|
||||
return
|
||||
}
|
||||
}
|
||||
me._buffer.length = 0
|
||||
}
|
||||
// console.error("FR _read done")
|
||||
// that's about all there is to it.
|
||||
}
|
||||
|
||||
FileReader.prototype.pause = function (who) {
|
||||
var me = this
|
||||
// console.error("FR Pause", me._path)
|
||||
if (me._paused) return
|
||||
who = who || me
|
||||
me._paused = true
|
||||
if (me._stream) me._stream.pause()
|
||||
me.emit("pause", who)
|
||||
}
|
||||
|
||||
FileReader.prototype.resume = function (who) {
|
||||
var me = this
|
||||
// console.error("FR Resume", me._path)
|
||||
if (!me._paused) return
|
||||
who = who || me
|
||||
me.emit("resume", who)
|
||||
me._paused = false
|
||||
if (me._stream) me._stream.resume()
|
||||
me._read()
|
||||
}
|
104
app/node_modules/fstream/lib/file-writer.js
generated
vendored
104
app/node_modules/fstream/lib/file-writer.js
generated
vendored
|
@ -1,104 +0,0 @@
|
|||
module.exports = FileWriter
|
||||
|
||||
var fs = require("graceful-fs")
|
||||
, mkdir = require("mkdirp")
|
||||
, Writer = require("./writer.js")
|
||||
, inherits = require("inherits")
|
||||
, EOF = {}
|
||||
|
||||
inherits(FileWriter, Writer)
|
||||
|
||||
function FileWriter (props) {
|
||||
var me = this
|
||||
if (!(me instanceof FileWriter)) throw new Error(
|
||||
"FileWriter must be called as constructor.")
|
||||
|
||||
// should already be established as a File type
|
||||
if (props.type !== "File" || !props.File) {
|
||||
throw new Error("Non-file type "+ props.type)
|
||||
}
|
||||
|
||||
me._buffer = []
|
||||
me._bytesWritten = 0
|
||||
|
||||
Writer.call(this, props)
|
||||
}
|
||||
|
||||
FileWriter.prototype._create = function () {
|
||||
var me = this
|
||||
if (me._stream) return
|
||||
|
||||
var so = {}
|
||||
if (me.props.flags) so.flags = me.props.flags
|
||||
so.mode = Writer.filemode
|
||||
if (me._old && me._old.blksize) so.bufferSize = me._old.blksize
|
||||
|
||||
me._stream = fs.createWriteStream(me._path, so)
|
||||
|
||||
me._stream.on("open", function (fd) {
|
||||
// console.error("FW open", me._buffer, me._path)
|
||||
me.ready = true
|
||||
me._buffer.forEach(function (c) {
|
||||
if (c === EOF) me._stream.end()
|
||||
else me._stream.write(c)
|
||||
})
|
||||
me.emit("ready")
|
||||
// give this a kick just in case it needs it.
|
||||
me.emit("drain")
|
||||
})
|
||||
|
||||
me._stream.on("drain", function () { me.emit("drain") })
|
||||
|
||||
me._stream.on("close", function () {
|
||||
// console.error("\n\nFW Stream Close", me._path, me.size)
|
||||
me._finish()
|
||||
})
|
||||
}
|
||||
|
||||
FileWriter.prototype.write = function (c) {
|
||||
var me = this
|
||||
|
||||
me._bytesWritten += c.length
|
||||
|
||||
if (!me.ready) {
|
||||
if (!Buffer.isBuffer(c) && typeof c !== 'string')
|
||||
throw new Error('invalid write data')
|
||||
me._buffer.push(c)
|
||||
return false
|
||||
}
|
||||
|
||||
var ret = me._stream.write(c)
|
||||
// console.error("\t-- fw wrote, _stream says", ret, me._stream._queue.length)
|
||||
|
||||
// allow 2 buffered writes, because otherwise there's just too
|
||||
// much stop and go bs.
|
||||
if (ret === false && me._stream._queue) {
|
||||
return me._stream._queue.length <= 2;
|
||||
} else {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
FileWriter.prototype.end = function (c) {
|
||||
var me = this
|
||||
|
||||
if (c) me.write(c)
|
||||
|
||||
if (!me.ready) {
|
||||
me._buffer.push(EOF)
|
||||
return false
|
||||
}
|
||||
|
||||
return me._stream.end()
|
||||
}
|
||||
|
||||
FileWriter.prototype._finish = function () {
|
||||
var me = this
|
||||
if (typeof me.size === "number" && me._bytesWritten != me.size) {
|
||||
me.error(
|
||||
"Did not get expected byte count.\n" +
|
||||
"expect: " + me.size + "\n" +
|
||||
"actual: " + me._bytesWritten)
|
||||
}
|
||||
Writer.prototype._finish.call(me)
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user