Made communication more stable

This commit is contained in:
jsrobson10 2019-04-09 19:18:47 +10:00
parent 914742051c
commit 6447085c29
72 changed files with 5613 additions and 184 deletions

View File

@ -10,3 +10,4 @@ An open source chat client
- electron
- node-rsa
- buffer-split
- worker-farm

View File

@ -2,10 +2,16 @@
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Chat Console</title>
<title>Connect</title>
<script src="index.js"></script>
<script src="scripts.js"></script>
</head>
<body>
<p id="server-response">xD</p>
<p>Direct Connect:</p>
<p>
<input type="text" id="hostname"><br/>
<input type="text" id="port" value="22068"></br>
<button onclick="connect_direct()">
</p>
</body>
</html>

356
index.js
View File

@ -1,36 +1,132 @@
// Get some libraries
const fs = require("fs");
const net = require("net");
const path = require("path");
const node_rsa = require("node-rsa");
const bsplit = require("buffer-split");
const child_process = require('child_process');
// Load the settings
var settings = require("./settings.json");
function connect(hostname, port=22068)
// Create an rsa key
var rsa_key;
function toBuffer(bytes)
{
// Make an accessible global object
var g = new Object();
// Encryption varibles
g.encryption;
g.rsa_key;
// Set new
g.sock_new = 2;
// Set a temporary encryption varible
g.raw_encryption_data = "";
g.raw_encryption_data_upto = 0;
g.raw_encryption_data_size = 0;
// Create a client
var client = new net.Socket();
function string_decrypt(key, string)
// String
if(typeof(bytes) == 'string')
{
// Create a buffer
var buffer = new Buffer.alloc(bytes.length);
// Loop over the bytes
for(var i=0;i<bytes.length;i++)
{
// Save to the buffer
buffer[i] = bytes[i].charCodeAt(0);
}
// Return the buffer
return buffer;
}
// Return if this is anything else
return bytes;
}
function toBytes(buffer)
{
// Make sure the buffer is a buffer
buffer = toBuffer(buffer);
// Create some bytes
var bytes = "";
// Loop over the buffer
for(var i=0;i<buffer.length;i++)
{
// Add to the bytes string
bytes += String.fromCharCode(buffer[i]);
}
// Return the bytes
return bytes;
}
// Recieve helper global varibles
var recieve_buffer = new Buffer.alloc(0);
var recieve_get = false;
var recieve_size = 0;
function recieve_ordered(data, callback)
{
// Convert the data into a buffer
data = toBuffer(data);
// Loop over the data
for(var i=0;i<data.length;i++)
{
// Add the data to the buffer
recieve_buffer = new Buffer.concat([recieve_buffer, Buffer.from([data[i]])]);
// Is the buffer getting data
if(!recieve_get)
{
// Does the buffer contain a number
if(recieve_buffer.length >= 4)
{
// Get the number
recieve_size = recieve_buffer.readUInt32BE(0);
// Reset the buffer
recieve_buffer = new Buffer.alloc(0);
// Set the get data mode to true
recieve_get = true;
}
}
else
{
// Is the recieve buffer as big as the size
if(recieve_buffer.length == recieve_size)
{
// Call the callback
callback(recieve_buffer);
// Reset the buffer and the size
recieve_buffer = new Buffer.alloc(0);
recieve_size = 0;
// Set the get data mode to false
recieve_get = false;
}
}
}
}
function send_ordered(data)
{
// Convert the data into a buffer
data = toBuffer(data);
// Get the size of the data
var size = data.length;
// Turn it into a 32 bit buffer
var bytes = new Buffer.alloc(4);
bytes.writeUInt32BE(size, 0);
// Return the buffer and the data
return new Buffer.concat([bytes, data]);
}
function string_decrypt(key, string)
{
// Convert the string to a buffer
var buff = new Buffer.from(string);
var buff = toBuffer(string);
// Create some new data
var decrypted = new Buffer.alloc(buff.length);
@ -56,12 +152,12 @@ function connect(hostname, port=22068)
// Return the encrypted data
return decrypted;
}
}
function string_encrypt(key, string)
{
function string_encrypt(key, string)
{
// Convert the string to a buffer
var buff = new Buffer.from(string);
var buff = toBuffer(string);
// Create some new data
var encrypted = new Buffer.alloc(buff.length);
@ -87,10 +183,10 @@ function connect(hostname, port=22068)
// Return the encrypted data
return encrypted;
}
}
function make_encryption_key(string)
{
function make_encryption_key(string)
{
// Make a new key
var key = new Object();
@ -102,40 +198,101 @@ function connect(hostname, port=22068)
// Return the key
return key;
}
function socket_write(socket, encryption, data)
{
console.log("socket_write() b4:", data);
// Convert the data to JSON
data = JSON.stringify(data);
console.log("socket_write() stringify:", data);
// Encrypt the data
data = string_encrypt(encryption, data);
console.log("socket_write() encrypt:", data);
// Order the request
data = send_ordered(data);
console.log("socket_write() ordered:", data);
// Send the data
socket.write(data);
}
function connect(hostname, port=22068)
{
// Make an accessible global object
var g = new Object();
// RSA child task
g.rsa_task = child_process.fork(
path.resolve('rsa.js'), [],
{
stdio: [ 'pipe', 'pipe', 'pipe', 'ipc' ],
silent: false
}
);
function socket_write(socket, encryption, data)
{
// Send the data encrypted with JSON
socket.write(string_encrypt(encryption, JSON.stringify(data)+"\n"));
}
g.rsa_task.unref();
function socket_ondata(socket, callback)
g.rsa_task.stdout.on('data', function(data)
{
// Wait for a response
socket.on('data', function(data)
{
// Decode the data
data = JSON.parse(data);
// Call the callback
callback(data);
console.log("child stdout:", data.toString());
});
}
g.rsa_task.stderr.on('data', function(data)
{
console.log("child stderr:", data.toString());
});
g.rsa_task.on('error', function(error)
{
console.log("Error on child process:", error);
})
g.rsa_task.on('exit', function(code, signal)
{
console.log("Child process closed:", code, signal);
});
// Encryption varibles
g.encryption;
// Set new
g.sock_new = 2;
// Set a temporary encryption varible
g.raw_encryption_data = "";
g.raw_encryption_data_upto = 0;
g.raw_encryption_data_size = 0;
// Create a client
var client = new net.Socket();
function rsa_task_send(data)
{
console.log("Send to child:", JSON.stringify(data));
g.rsa_task.send(JSON.stringify(data));
}
// Connect to the server
client.connect(port, hostname, function()
{
// Create an rsa key
g.rsa_key = new node_rsa({b:settings.rsa_size});
// Send the public key to the server
client.write(g.rsa_key.exportKey("public")+"\n");
// Load the RSA key
rsa_task_send({
mode: "load"
});
});
// Wait for data
client.on('data', function(data)
{
// Recieve data in order
recieve_ordered(data, function(data)
{
console.log("RAW: ", {
input: data,
@ -147,61 +304,16 @@ function connect(hostname, port=22068)
if(g.sock_new != 0)
{
// Split the data by newlines
data = bsplit(data, Buffer.from("\n"));
data = JSON.parse(data.toString());
// Iterate over the values
for(var i=0;i<data.length;i++)
// Is this the key
if(data.mode == "encryption_key")
{
// Done signal
if(data[i]=="done")
{
/*// Set sock new to 0
sock_new = 0;
// Set the key
encryption = make_encryption_key(rsa_key.decrypt(raw_encryption_data));
console.log("Done.");
socket_write(client, encryption, {message: "hello, world!", number: 53});*/
}
// Is the client recieving the key size
if(g.sock_new == 2)
{
console.log("Recieved key.");
// Set the size of the key
g.raw_encryption_data_size = parseInt(data[i]);
// Set sock new to 1
g.sock_new = 1;
}
// Is the client recieving the key
else if(g.sock_new == 1)
{
console.log(data[i]);
// Decode the data
g.raw_encryption_data += data[i];
g.raw_encryption_data_upto += data[i].length;
console.log(data[i].length);
// Is this the end of the stream
if(g.raw_encryption_data_upto == g.raw_encryption_data_size)
{
// Set sock new to 0
g.sock_new = 0;
// Set the key
g.encryption = make_encryption_key(g.rsa_key.decrypt(g.raw_encryption_data));
console.log("Done.");
socket_write(client, g.encryption, {message: "hello, world!", number: 53});
}
}
// Send the key to be decrypted
g.rsa_task.send(JSON.stringify({
mode: "decrypt",
data: data.key
}));
}
}
@ -220,6 +332,7 @@ function connect(hostname, port=22068)
}
}
});
});
client.on('close', function(data)
{
@ -227,6 +340,47 @@ function connect(hostname, port=22068)
//window.close();
});
g.rsa_task.on('message', function(message)
{
console.log(message)
// Parse the message from JSON
var data = JSON.parse(message);
// Is this a rsa load response
if(data['mode'] == 'load')
{
// Get the rsa key
g.rsa_task.send(JSON.stringify({
mode: "get"
}));
}
// Is this an rsa get response
if(data['mode'] == 'get')
{
// Send the public key to the server
client.write(send_ordered(JSON.stringify({
key: data['public'],
mode: "pubkey"
})));
}
// Is this an rsa data decrypt response
if(data['mode'] == 'decrypt')
{
// Set the key
g.encryption = make_encryption_key(atob(data['out']));
console.log("Sending 1:",atob(data['out']));
// Send status
socket_write(client, g.encryption, 1);
console.log("Done.");
}
});
// Return the global varibles
return g;
}

51
key Normal file
View File

@ -0,0 +1,51 @@
-----BEGIN RSA PRIVATE KEY-----
MIIJJwIBAAKCAgEAjj0aDW3uJI8tivbJEk2q0EAWnkwmR3k91P61WFhFtA5j6rl+
DqF5Fr1AhjutkZT+xeno0n3Mm+/XqTTABKfcYpMmmGCHMvIc3AkFb0deXXHBqLeS
Soid+MsmMp/68/jvtvWGQzJKEPURHndcupTXFJmclYpHrHOLjndX01ofLaUg2fT+
3Pu81gVJBE53xT97KQQvHN+xpGJYPTts0A3blrWyJ44WQha/jWQN84hRJuDe1SA2
bTPx4UIyAmfY7RG3j2nLJgzZUTI2Z35mKhfgvdYazTpYld9bm9CfLljCr4lKR50A
Zo4qZuIgD5+qYq1PUpsqQX04KcTOUiDHRFlD06Wn9l7eeFZNwbDp7e397vueDdVB
we0sujuefwDyVon43DaO8ljEz+H0iq9L+0Mwx8UshuQtWUAvgFqctJoITWNUEe78
ib/3KXO4CurXcuOqfW+KA1TQQi3KKnP9cuTgajoxv4LPrBR6CtFzN/1TjzEjwdSX
secZ5Kz9SJVf1ZDDKl4CnGMFug1V9UGpbV4gAPGcZBvhVM1lWFC25T6YfviO/e1n
PKTaLgFNsyzAFbX508Ta/9K5V8xw9JDfpoEbHuFPFqsKTVV9pva8A1djfhMRTFCu
jQVpYTDp8tdmKoE0crAeJU+1EwlCZSSlz1KhCqBh5wLmGQNLbxSInu8oPYcCAwEA
AQKCAgBAkoyZPCa4gidyxsZRgODi2bVq97cJC4l+gINjL++05jOGA9+uVK/cGt6I
Ed+iD7n5r077ABE7WY7WShRCCNKMDbGfy3KVNkTTv2SwN/4m/dWk+nF3VL4ijFcy
9F3BFGn+7Ueeid4GBLtY0WdPbPKXb4UefkA7kdjxPEyqrmcpGaXoTMjHGaGIp62W
PukwqrkGzdd1jDfhIKReZ/PmH+RobuQKAP8p0Zn0Xk/XFzOAKuX+azlKKiLM2HhL
j0lzlm92s9h91adyrRD1uvQ2d9CXXfOc57f/kf7MpdEeAT2g4vrNuADOjgvB2TYk
4Z9AXN196uMsB+TPUYE415ie9sdLRxjQ+uvHYIigrJwjfYdcwcn/06tOFEyDz5Ho
z2qP2l+XLbccQ5+CqU8ITO8pHg5HAYbQQnhs3FecWO3i6sQADPSnSqtlvDHiOu/1
L0uqMoMfcremu/nvFREzqwZ6DYCYtTfV2Lp6MAL2ecbFZzs75DfRYySgvITzoFFq
BVDE6bBXpGUP3KJPdOrsjtI6WrjGWAKzVp7VPp4yAV2zwuEldG46oAcXzGnKwNDN
ptimQ6w8EklfCudlJsFxByI2vSmhrXzXKwEkbGZZkEkTMlWjAy5daEO5lYzvfN/3
sgkI1txTVBFp0P8J+2FGM23N0IrwQVG8urh4K7HF8rn5JPsBwQKCAQEA25c1JYBP
CU3unDj24pjClr8Px+UFtx8uRuHLP5lDH6kybrTDGSrylY4gK0Yo9xNHXr/853Qj
9zqs9W/SlAz/0eBkUah/xP6FdFX7TqW4YQixVdYkQSdDCKb59JdyJiJpRCilModO
Y70SZOPMOb1WpHNeDVpU53Zbszcd6eZQOwPwzPAtJGPSqGYnFu1BbAn61YMtAVvI
xiHpukvLxU013+tOuwjkujMR5YH4aSxLfWYOzW6QTm9Vyp8qY2QsGvgr8Ofx1KkW
PLibtJQtV2GjepAdcJXXs5PH8oOxnEcqugOJtGqQNLayxAHI+PdHcFm4wwHu8y3V
kOUXMBmyY2+5tQKCAQEApdKYcPI1CNoXmJugBZaliPOhE0FS07uzOd4nLmxsyld/
Q21WmVSPyEot+ZlIyZuiRNnVsgfkoylXat6VZ1Mc9kF13QwIic8CMTOG6KnVgnLV
nkm22HSnu3jiMfCYJj+RZa6x9C1+tcmmMYXcHv7BZlDMLTPUoAvARjUKdzRSYBiP
6ix8lY2hiF3cZqHvZX8gd5J5lmhCMIkE/1OVGQUAW5W4BdEpsptYl70DC2M3frMF
5Cvs1G1jkC8QYph57CgNhGmU+N0f2fe5fkuZvUxbYVr5Zt35uzwNN2IEOatUladb
hb7AhSGGhbkyVGXl/x1BGd1ESwLs4nKU+s46aHDvywKCAQAqcUhhbjJYjwqOgWge
lf4OWvF25mo7Ybh1FNFPApV5uh84TJHk/GsUwvquwonKb5x80MjWB5moAFxLuAhQ
e066xw88xT+k2Lj8ql2/bsJ7Zs231IL/YNJRCs0HHHqAqmgEN4LuiD57gqDahTkE
8/aaJH5KQGpmrna85etPOSfKsFFLmyRugyjFSbFGeicJ9cfYmtkJCS9+NDHTwzCo
eurt07JM7kQfRR2xaXSVB22z2BUGWddkgZpoZmkv+r2XnN4JWxtfyiq1I81cksNM
v190ogQ+rYeaevbLhe6/UPYOK/7iszIaLjHRNrMcg9b3/S976ZTAxdwgfFcGAgF7
vK19AoIBAC0NkNlvFTW4e5y8+7dI/OS+vM7MesKIRuO8Fg0o7E31g+A//r1eGkqi
zOb53KraHDZ0sPjT6CzkeJnSq+kMzduiYXGTaWZ31fKkO01Ph3EP3jZJdOJOn5vx
9hL3eX862jg0RKlBCyI9DWh7JBlPwiAYZ8EISgbJ6o2or5U/o/nz8nX/bEH93xt7
1PwVl0OOTLXwGBTjcshZEgCFJwdLMpOvk/YQpDGgv2tKsV8Qr+0+mqUpwgjdR6XP
A7amEso0/6cwQId1HMhN5BoKVFT4QAOtggGO4eEbKcQYX2mDwVF/zQADma8SMsh2
TtRbcyfjPOLYGUwAGXhVBWE3Uus5dA0CggEAOzrvlk+a7e6o5Z8ecLt7fLBe5BaC
qHyu5E6VKMRcBAA5/mU8VvTuwQFDFfpcJbEJrObc4zOQpr/flxCnzSut9ZM2HcWf
r35Wg45lL5ZvQnCHtlM7O546TmpVvI2dgbGsxgyJxbx/QLwKF41P7zuX6tHLBEeb
hjEvknVc1uT1HGrRjG8rP+hkhxug/QsmsIPttLbuZSbwtVpSQeWQjCpBOeC8FORj
STwlMf9CfQ6bGp+0UkN8Tj4y/UoqrwO5T+uXHB7OmEivpfMFEimA95F4kyxykEzv
NM1DLa++EDIeuiP0MF+yphjW8qJ0F9KuZaS0MYnsTPvV08/IvPrtGt2U2g==
-----END RSA PRIVATE KEY-----

14
key.pub Normal file
View File

@ -0,0 +1,14 @@
-----BEGIN PUBLIC KEY-----
MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAjj0aDW3uJI8tivbJEk2q
0EAWnkwmR3k91P61WFhFtA5j6rl+DqF5Fr1AhjutkZT+xeno0n3Mm+/XqTTABKfc
YpMmmGCHMvIc3AkFb0deXXHBqLeSSoid+MsmMp/68/jvtvWGQzJKEPURHndcupTX
FJmclYpHrHOLjndX01ofLaUg2fT+3Pu81gVJBE53xT97KQQvHN+xpGJYPTts0A3b
lrWyJ44WQha/jWQN84hRJuDe1SA2bTPx4UIyAmfY7RG3j2nLJgzZUTI2Z35mKhfg
vdYazTpYld9bm9CfLljCr4lKR50AZo4qZuIgD5+qYq1PUpsqQX04KcTOUiDHRFlD
06Wn9l7eeFZNwbDp7e397vueDdVBwe0sujuefwDyVon43DaO8ljEz+H0iq9L+0Mw
x8UshuQtWUAvgFqctJoITWNUEe78ib/3KXO4CurXcuOqfW+KA1TQQi3KKnP9cuTg
ajoxv4LPrBR6CtFzN/1TjzEjwdSXsecZ5Kz9SJVf1ZDDKl4CnGMFug1V9UGpbV4g
APGcZBvhVM1lWFC25T6YfviO/e1nPKTaLgFNsyzAFbX508Ta/9K5V8xw9JDfpoEb
HuFPFqsKTVV9pva8A1djfhMRTFCujQVpYTDp8tdmKoE0crAeJU+1EwlCZSSlz1Kh
CqBh5wLmGQNLbxSInu8oPYcCAwEAAQ==
-----END PUBLIC KEY-----

1
node_modules/.bin/atob generated vendored Symbolic link
View File

@ -0,0 +1 @@
../atob/bin/atob.js

1
node_modules/.bin/btoa generated vendored Symbolic link
View File

@ -0,0 +1 @@
../btoa/bin/btoa.js

1
node_modules/.bin/errno generated vendored Symbolic link
View File

@ -0,0 +1 @@
../errno/cli.js

230
node_modules/atob/LICENSE generated vendored Normal file
View File

@ -0,0 +1,230 @@
At your option you may choose either of the following licenses:
* The MIT License (MIT)
* The Apache License 2.0 (Apache-2.0)
The MIT License (MIT)
Copyright (c) 2015 AJ ONeal
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.
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright 2015 AJ ONeal
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

319
node_modules/atob/LICENSE.DOCS generated vendored Normal file
View File

@ -0,0 +1,319 @@
Creative Commons Legal Code
Attribution 3.0 Unported
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
LEGAL SERVICES. DISTRIBUTION OF THIS LICENSE DOES NOT CREATE AN
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
REGARDING THE INFORMATION PROVIDED, AND DISCLAIMS LIABILITY FOR
DAMAGES RESULTING FROM ITS USE.
License
THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE
COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY
COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS
AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE
TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY
BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS
CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND
CONDITIONS.
1. Definitions
a. "Adaptation" means a work based upon the Work, or upon the Work and
other pre-existing works, such as a translation, adaptation,
derivative work, arrangement of music or other alterations of a
literary or artistic work, or phonogram or performance and includes
cinematographic adaptations or any other form in which the Work may be
recast, transformed, or adapted including in any form recognizably
derived from the original, except that a work that constitutes a
Collection will not be considered an Adaptation for the purpose of
this License. For the avoidance of doubt, where the Work is a musical
work, performance or phonogram, the synchronization of the Work in
timed-relation with a moving image ("synching") will be considered an
Adaptation for the purpose of this License.
b. "Collection" means a collection of literary or artistic works, such as
encyclopedias and anthologies, or performances, phonograms or
broadcasts, or other works or subject matter other than works listed
in Section 1(f) below, which, by reason of the selection and
arrangement of their contents, constitute intellectual creations, in
which the Work is included in its entirety in unmodified form along
with one or more other contributions, each constituting separate and
independent works in themselves, which together are assembled into a
collective whole. A work that constitutes a Collection will not be
considered an Adaptation (as defined above) for the purposes of this
License.
c. "Distribute" means to make available to the public the original and
copies of the Work or Adaptation, as appropriate, through sale or
other transfer of ownership.
d. "Licensor" means the individual, individuals, entity or entities that
offer(s) the Work under the terms of this License.
e. "Original Author" means, in the case of a literary or artistic work,
the individual, individuals, entity or entities who created the Work
or if no individual or entity can be identified, the publisher; and in
addition (i) in the case of a performance the actors, singers,
musicians, dancers, and other persons who act, sing, deliver, declaim,
play in, interpret or otherwise perform literary or artistic works or
expressions of folklore; (ii) in the case of a phonogram the producer
being the person or legal entity who first fixes the sounds of a
performance or other sounds; and, (iii) in the case of broadcasts, the
organization that transmits the broadcast.
f. "Work" means the literary and/or artistic work offered under the terms
of this License including without limitation any production in the
literary, scientific and artistic domain, whatever may be the mode or
form of its expression including digital form, such as a book,
pamphlet and other writing; a lecture, address, sermon or other work
of the same nature; a dramatic or dramatico-musical work; a
choreographic work or entertainment in dumb show; a musical
composition with or without words; a cinematographic work to which are
assimilated works expressed by a process analogous to cinematography;
a work of drawing, painting, architecture, sculpture, engraving or
lithography; a photographic work to which are assimilated works
expressed by a process analogous to photography; a work of applied
art; an illustration, map, plan, sketch or three-dimensional work
relative to geography, topography, architecture or science; a
performance; a broadcast; a phonogram; a compilation of data to the
extent it is protected as a copyrightable work; or a work performed by
a variety or circus performer to the extent it is not otherwise
considered a literary or artistic work.
g. "You" means an individual or entity exercising rights under this
License who has not previously violated the terms of this License with
respect to the Work, or who has received express permission from the
Licensor to exercise rights under this License despite a previous
violation.
h. "Publicly Perform" means to perform public recitations of the Work and
to communicate to the public those public recitations, by any means or
process, including by wire or wireless means or public digital
performances; to make available to the public Works in such a way that
members of the public may access these Works from a place and at a
place individually chosen by them; to perform the Work to the public
by any means or process and the communication to the public of the
performances of the Work, including by public digital performance; to
broadcast and rebroadcast the Work by any means including signs,
sounds or images.
i. "Reproduce" means to make copies of the Work by any means including
without limitation by sound or visual recordings and the right of
fixation and reproducing fixations of the Work, including storage of a
protected performance or phonogram in digital form or other electronic
medium.
2. Fair Dealing Rights. Nothing in this License is intended to reduce,
limit, or restrict any uses free from copyright or rights arising from
limitations or exceptions that are provided for in connection with the
copyright protection under copyright law or other applicable laws.
3. License Grant. Subject to the terms and conditions of this License,
Licensor hereby grants You a worldwide, royalty-free, non-exclusive,
perpetual (for the duration of the applicable copyright) license to
exercise the rights in the Work as stated below:
a. to Reproduce the Work, to incorporate the Work into one or more
Collections, and to Reproduce the Work as incorporated in the
Collections;
b. to create and Reproduce Adaptations provided that any such Adaptation,
including any translation in any medium, takes reasonable steps to
clearly label, demarcate or otherwise identify that changes were made
to the original Work. For example, a translation could be marked "The
original work was translated from English to Spanish," or a
modification could indicate "The original work has been modified.";
c. to Distribute and Publicly Perform the Work including as incorporated
in Collections; and,
d. to Distribute and Publicly Perform Adaptations.
e. For the avoidance of doubt:
i. Non-waivable Compulsory License Schemes. In those jurisdictions in
which the right to collect royalties through any statutory or
compulsory licensing scheme cannot be waived, the Licensor
reserves the exclusive right to collect such royalties for any
exercise by You of the rights granted under this License;
ii. Waivable Compulsory License Schemes. In those jurisdictions in
which the right to collect royalties through any statutory or
compulsory licensing scheme can be waived, the Licensor waives the
exclusive right to collect such royalties for any exercise by You
of the rights granted under this License; and,
iii. Voluntary License Schemes. The Licensor waives the right to
collect royalties, whether individually or, in the event that the
Licensor is a member of a collecting society that administers
voluntary licensing schemes, via that society, from any exercise
by You of the rights granted under this License.
The above rights may be exercised in all media and formats whether now
known or hereafter devised. The above rights include the right to make
such modifications as are technically necessary to exercise the rights in
other media and formats. Subject to Section 8(f), all rights not expressly
granted by Licensor are hereby reserved.
4. Restrictions. The license granted in Section 3 above is expressly made
subject to and limited by the following restrictions:
a. You may Distribute or Publicly Perform the Work only under the terms
of this License. You must include a copy of, or the Uniform Resource
Identifier (URI) for, this License with every copy of the Work You
Distribute or Publicly Perform. You may not offer or impose any terms
on the Work that restrict the terms of this License or the ability of
the recipient of the Work to exercise the rights granted to that
recipient under the terms of the License. You may not sublicense the
Work. You must keep intact all notices that refer to this License and
to the disclaimer of warranties with every copy of the Work You
Distribute or Publicly Perform. When You Distribute or Publicly
Perform the Work, You may not impose any effective technological
measures on the Work that restrict the ability of a recipient of the
Work from You to exercise the rights granted to that recipient under
the terms of the License. This Section 4(a) applies to the Work as
incorporated in a Collection, but this does not require the Collection
apart from the Work itself to be made subject to the terms of this
License. If You create a Collection, upon notice from any Licensor You
must, to the extent practicable, remove from the Collection any credit
as required by Section 4(b), as requested. If You create an
Adaptation, upon notice from any Licensor You must, to the extent
practicable, remove from the Adaptation any credit as required by
Section 4(b), as requested.
b. If You Distribute, or Publicly Perform the Work or any Adaptations or
Collections, You must, unless a request has been made pursuant to
Section 4(a), keep intact all copyright notices for the Work and
provide, reasonable to the medium or means You are utilizing: (i) the
name of the Original Author (or pseudonym, if applicable) if supplied,
and/or if the Original Author and/or Licensor designate another party
or parties (e.g., a sponsor institute, publishing entity, journal) for
attribution ("Attribution Parties") in Licensor's copyright notice,
terms of service or by other reasonable means, the name of such party
or parties; (ii) the title of the Work if supplied; (iii) to the
extent reasonably practicable, the URI, if any, that Licensor
specifies to be associated with the Work, unless such URI does not
refer to the copyright notice or licensing information for the Work;
and (iv) , consistent with Section 3(b), in the case of an Adaptation,
a credit identifying the use of the Work in the Adaptation (e.g.,
"French translation of the Work by Original Author," or "Screenplay
based on original Work by Original Author"). The credit required by
this Section 4 (b) may be implemented in any reasonable manner;
provided, however, that in the case of a Adaptation or Collection, at
a minimum such credit will appear, if a credit for all contributing
authors of the Adaptation or Collection appears, then as part of these
credits and in a manner at least as prominent as the credits for the
other contributing authors. For the avoidance of doubt, You may only
use the credit required by this Section for the purpose of attribution
in the manner set out above and, by exercising Your rights under this
License, You may not implicitly or explicitly assert or imply any
connection with, sponsorship or endorsement by the Original Author,
Licensor and/or Attribution Parties, as appropriate, of You or Your
use of the Work, without the separate, express prior written
permission of the Original Author, Licensor and/or Attribution
Parties.
c. Except as otherwise agreed in writing by the Licensor or as may be
otherwise permitted by applicable law, if You Reproduce, Distribute or
Publicly Perform the Work either by itself or as part of any
Adaptations or Collections, You must not distort, mutilate, modify or
take other derogatory action in relation to the Work which would be
prejudicial to the Original Author's honor or reputation. Licensor
agrees that in those jurisdictions (e.g. Japan), in which any exercise
of the right granted in Section 3(b) of this License (the right to
make Adaptations) would be deemed to be a distortion, mutilation,
modification or other derogatory action prejudicial to the Original
Author's honor and reputation, the Licensor will waive or not assert,
as appropriate, this Section, to the fullest extent permitted by the
applicable national law, to enable You to reasonably exercise Your
right under Section 3(b) of this License (right to make Adaptations)
but not otherwise.
5. Representations, Warranties and Disclaimer
UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, LICENSOR
OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY
KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE,
INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY,
FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF
LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS,
WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION
OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU.
6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE
LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR
ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES
ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS
BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
7. Termination
a. This License and the rights granted hereunder will terminate
automatically upon any breach by You of the terms of this License.
Individuals or entities who have received Adaptations or Collections
from You under this License, however, will not have their licenses
terminated provided such individuals or entities remain in full
compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will
survive any termination of this License.
b. Subject to the above terms and conditions, the license granted here is
perpetual (for the duration of the applicable copyright in the Work).
Notwithstanding the above, Licensor reserves the right to release the
Work under different license terms or to stop distributing the Work at
any time; provided, however that any such election will not serve to
withdraw this License (or any other license that has been, or is
required to be, granted under the terms of this License), and this
License will continue in full force and effect unless terminated as
stated above.
8. Miscellaneous
a. Each time You Distribute or Publicly Perform the Work or a Collection,
the Licensor offers to the recipient a license to the Work on the same
terms and conditions as the license granted to You under this License.
b. Each time You Distribute or Publicly Perform an Adaptation, Licensor
offers to the recipient a license to the original Work on the same
terms and conditions as the license granted to You under this License.
c. If any provision of this License is invalid or unenforceable under
applicable law, it shall not affect the validity or enforceability of
the remainder of the terms of this License, and without further action
by the parties to this agreement, such provision shall be reformed to
the minimum extent necessary to make such provision valid and
enforceable.
d. No term or provision of this License shall be deemed waived and no
breach consented to unless such waiver or consent shall be in writing
and signed by the party to be charged with such waiver or consent.
e. This License constitutes the entire agreement between the parties with
respect to the Work licensed here. There are no understandings,
agreements or representations with respect to the Work not specified
here. Licensor shall not be bound by any additional provisions that
may appear in any communication from You. This License may not be
modified without the mutual written agreement of the Licensor and You.
f. The rights granted under, and the subject matter referenced, in this
License were drafted utilizing the terminology of the Berne Convention
for the Protection of Literary and Artistic Works (as amended on
September 28, 1979), the Rome Convention of 1961, the WIPO Copyright
Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996
and the Universal Copyright Convention (as revised on July 24, 1971).
These rights and subject matter take effect in the relevant
jurisdiction in which the License terms are sought to be enforced
according to the corresponding provisions of the implementation of
those treaty provisions in the applicable national law. If the
standard suite of rights granted under applicable copyright law
includes additional rights not granted under this License, such
additional rights are deemed to be included in the License; this
License is not intended to restrict the license of any rights under
applicable law.
Creative Commons Notice
Creative Commons is not a party to this License, and makes no warranty
whatsoever in connection with the Work. Creative Commons will not be
liable to You or any party on any legal theory for any damages
whatsoever, including without limitation any general, special,
incidental or consequential damages arising in connection to this
license. Notwithstanding the foregoing two (2) sentences, if Creative
Commons has expressly identified itself as the Licensor hereunder, it
shall have all rights and obligations of Licensor.
Except for the limited purpose of indicating to the public that the
Work is licensed under the CCPL, Creative Commons does not authorize
the use by either party of the trademark "Creative Commons" or any
related trademark or logo of Creative Commons without the prior
written consent of Creative Commons. Any permitted use will be in
compliance with Creative Commons' then-current trademark usage
guidelines, as may be published on its website or otherwise made
available upon request from time to time. For the avoidance of doubt,
this trademark restriction does not form part of this License.
Creative Commons may be contacted at http://creativecommons.org/.

49
node_modules/atob/README.md generated vendored Normal file
View File

@ -0,0 +1,49 @@
atob
===
| **atob**
| [btoa](https://git.coolaj86.com/coolaj86/btoa.js)
| [unibabel.js](https://git.coolaj86.com/coolaj86/unibabel.js)
| Sponsored by [ppl](https://ppl.family)
Uses `Buffer` to emulate the exact functionality of the browser's atob.
Note: Unicode may be handled incorrectly (like the browser).
It turns base64-encoded <strong>a</strong>scii data back **to** <strong>b</strong>inary.
```javascript
(function () {
"use strict";
var atob = require('atob');
var b64 = "SGVsbG8sIFdvcmxkIQ==";
var bin = atob(b64);
console.log(bin); // "Hello, World!"
}());
```
### Need Unicode and Binary Support in the Browser?
Check out [unibabel.js](https://git.coolaj86.com/coolaj86/unibabel.js)
Changelog
=======
* v2.1.0 address a few issues and PRs, update URLs
* v2.0.0 provide browser version for ios web workers
* v1.2.0 provide (empty) browser version
* v1.1.3 add MIT license
* v1.1.2 node only
LICENSE
=======
Code copyright 2012-2018 AJ ONeal
Dual-licensed MIT and Apache-2.0
Docs copyright 2012-2018 AJ ONeal
Docs released under [Creative Commons](https://git.coolaj86.com/coolaj86/atob.js/blob/master/LICENSE.DOCS).

6
node_modules/atob/bin/atob.js generated vendored Normal file
View File

@ -0,0 +1,6 @@
#!/usr/bin/env node
'use strict';
var atob = require('../node-atob');
var str = process.argv[2];
console.log(atob(str));

24
node_modules/atob/bower.json generated vendored Normal file
View File

@ -0,0 +1,24 @@
{
"name": "atob",
"description": "atob for isomorphic environments",
"main": "browser-atob.js",
"authors": [
"AJ ONeal <coolaj86@gmail.com> (https://coolaj86.com)"
],
"license": "(MIT OR Apache-2.0)",
"keywords": [
"atob",
"browser"
],
"homepage": "https://github.com/node-browser-compat/atob",
"moduleType": [
"globals"
],
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
]
}

44
node_modules/atob/browser-atob.js generated vendored Normal file
View File

@ -0,0 +1,44 @@
(function (w) {
"use strict";
function findBest(atobNative) {
// normal window
if ('function' === typeof atobNative) { return atobNative; }
// browserify (web worker)
if ('function' === typeof Buffer) {
return function atobBrowserify(a) {
//!! Deliberately using an API that's deprecated in node.js because
//!! this file is for browsers and we expect them to cope with it.
//!! Discussion: github.com/node-browser-compat/atob/pull/9
return new Buffer(a, 'base64').toString('binary');
};
}
// ios web worker with base64js
if ('object' === typeof w.base64js) {
// bufferToBinaryString
// https://git.coolaj86.com/coolaj86/unibabel.js/blob/master/index.js#L50
return function atobWebWorker_iOS(a) {
var buf = w.base64js.b64ToByteArray(a);
return Array.prototype.map.call(buf, function (ch) {
return String.fromCharCode(ch);
}).join('');
};
}
return function () {
// ios web worker without base64js
throw new Error("You're probably in an old browser or an iOS webworker." +
" It might help to include beatgammit's base64-js.");
};
}
var atobBest = findBest(w.atob);
w.atob = atobBest;
if ((typeof module === 'object') && module && module.exports) {
module.exports = atobBest;
}
}(window));

7
node_modules/atob/node-atob.js generated vendored Normal file
View File

@ -0,0 +1,7 @@
"use strict";
function atob(str) {
return Buffer.from(str, 'base64').toString('binary');
}
module.exports = atob.atob = atob;

86
node_modules/atob/package.json generated vendored Normal file
View File

@ -0,0 +1,86 @@
{
"_args": [
[
"atob",
"/mnt/c/Users/Josua/Desktop/data/nodejs/electron/chat-project/chat-client"
]
],
"_from": "atob@latest",
"_id": "atob@2.1.2",
"_inCache": true,
"_installable": true,
"_location": "/atob",
"_nodeVersion": "10.6.0",
"_npmOperationalInternal": {
"host": "s3://npm-registry-packages",
"tmp": "tmp/atob_2.1.2_1534587539650_0.5963110548313084"
},
"_npmUser": {
"email": "coolaj86@gmail.com",
"name": "coolaj86"
},
"_npmVersion": "6.1.0",
"_phantomChildren": {},
"_requested": {
"name": "atob",
"raw": "atob",
"rawSpec": "",
"scope": null,
"spec": "latest",
"type": "tag"
},
"_requiredBy": [
"#USER"
],
"_resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz",
"_shasum": "6d9517eb9e030d2436666651e86bd9f6f13533c9",
"_shrinkwrap": null,
"_spec": "atob",
"_where": "/mnt/c/Users/Josua/Desktop/data/nodejs/electron/chat-project/chat-client",
"author": {
"email": "coolaj86@gmail.com",
"name": "AJ ONeal",
"url": "https://coolaj86.com"
},
"bin": {
"atob": "bin/atob.js"
},
"browser": "browser-atob.js",
"dependencies": {},
"description": "atob for Node.JS and Linux / Mac / Windows CLI (it's a one-liner)",
"devDependencies": {},
"directories": {},
"dist": {
"fileCount": 9,
"integrity": "sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==",
"npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbd/KUCRA9TVsSAnZWagAAWT8P/3+yl8XFjF0rp1EFhKXr\nwiBksq0aT2A9GHF0nWtytC3MAmn6r9qmY1lmHRoDgwUxQDdrxkYhvljvEFlV\nkzzCnbMOQnTtJubX2lTHG1OLQeUz4DoE7jLEEtnA9UCj5gAZo9eAI+9F4v97\nfRWKlFIJS+miXsLODPww7PAgJKMYBaOkEs6hLW8CIrssIlrdjHAT26ZTYZhY\nFCOvmpT2Mg4BbCE61k8arLNPCqGq7Joh4oJ7BOdosXWnd0snfK4JsXzPFMu8\nLEasrWWAcTJP23k9tDkCn4wtGzt2ZSqRwHXpT7/jEL3GnycctMtefqJdZ6qb\nmRV7/KUVMhGAUnhm5sb0v50NrYx5vO7CGYQqv6IYyNRVbuq3zKjESneyjHzk\nN4Up8SW5UQ8eN+WBRoNfQiOheAk9bdEc02RguuNURng/Pjd9S5xILvg42nfa\np154xFSlNfJASYmH0uDWAzqW+7XZDLxGZOxEuxC52B/aRB3+oZIH/dZOwEw4\nwcQfIzK6421MzIrmBxgU8rL7WCjov4d1spI91jS6bhV6OGsij564gKqbufJq\nHbQUnQeV4PAfU1tLOkUlLxdatt6JL/ekaz0MIE9m35pRf+FRUIbMacJkdHd8\nCftoLutPQ4NR6Ce36ylhZOgoW9tcKUsaTnrwq8M12Y1TAqzHSYKPaVnqMSXN\ngBBD\r\n=TkXF\r\n-----END PGP SIGNATURE-----\r\n",
"shasum": "6d9517eb9e030d2436666651e86bd9f6f13533c9",
"tarball": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz",
"unpackedSize": 36200
},
"engines": {
"node": ">= 4.5.0"
},
"gitHead": "755cfea7899074a17e83a248c7cfc3960d956d82",
"homepage": "https://git.coolaj86.com/coolaj86/atob.js.git",
"keywords": [
"atob",
"browser"
],
"license": "(MIT OR Apache-2.0)",
"main": "node-atob.js",
"maintainers": [
{
"name": "coolaj86",
"email": "coolaj86@gmail.com"
}
],
"name": "atob",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git://git.coolaj86.com/coolaj86/atob.js.git"
},
"version": "2.1.2"
}

18
node_modules/atob/test.js generated vendored Normal file
View File

@ -0,0 +1,18 @@
(function () {
"use strict";
var atob = require('.');
var encoded = "SGVsbG8sIFdvcmxkIQ=="
var unencoded = "Hello, World!";
/*
, encoded = "SGVsbG8sIBZM"
, unencoded = "Hello, 世界"
*/
if (unencoded !== atob(encoded)) {
console.log('[FAIL]', unencoded, atob(encoded));
return;
}
console.log('[PASS] all tests pass');
}());

191
node_modules/btoa/LICENSE generated vendored Normal file
View File

@ -0,0 +1,191 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction, and
distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by the copyright
owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all other entities
that control, are controlled by, or are under common control with that entity.
For the purposes of this definition, "control" means (i) the power, direct or
indirect, to cause the direction or management of such entity, whether by
contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity exercising
permissions granted by this License.
"Source" form shall mean the preferred form for making modifications, including
but not limited to software source code, documentation source, and configuration
files.
"Object" form shall mean any form resulting from mechanical transformation or
translation of a Source form, including but not limited to compiled object code,
generated documentation, and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or Object form, made
available under the License, as indicated by a copyright notice that is included
in or attached to the work (an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object form, that
is based on (or derived from) the Work and for which the editorial revisions,
annotations, elaborations, or other modifications represent, as a whole, an
original work of authorship. For the purposes of this License, Derivative Works
shall not include works that remain separable from, or merely link (or bind by
name) to the interfaces of, the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including the original version
of the Work and any modifications or additions to that Work or Derivative Works
thereof, that is intentionally submitted to Licensor for inclusion in the Work
by the copyright owner or by an individual or Legal Entity authorized to submit
on behalf of the copyright owner. For the purposes of this definition,
"submitted" means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems, and
issue tracking systems that are managed by, or on behalf of, the Licensor for
the purpose of discussing and improving the Work, but excluding communication
that is conspicuously marked or otherwise designated in writing by the copyright
owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf
of whom a Contribution has been received by Licensor and subsequently
incorporated within the Work.
2. Grant of Copyright License.
Subject to the terms and conditions of this License, each Contributor hereby
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
irrevocable copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the Work and such
Derivative Works in Source or Object form.
3. Grant of Patent License.
Subject to the terms and conditions of this License, each Contributor hereby
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
irrevocable (except as stated in this section) patent license to make, have
made, use, offer to sell, sell, import, and otherwise transfer the Work, where
such license applies only to those patent claims licensable by such Contributor
that are necessarily infringed by their Contribution(s) alone or by combination
of their Contribution(s) with the Work to which such Contribution(s) was
submitted. If You institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work or a
Contribution incorporated within the Work constitutes direct or contributory
patent infringement, then any patent licenses granted to You under this License
for that Work shall terminate as of the date such litigation is filed.
4. Redistribution.
You may reproduce and distribute copies of the Work or Derivative Works thereof
in any medium, with or without modifications, and in Source or Object form,
provided that You meet the following conditions:
You must give any other recipients of the Work or Derivative Works a copy of
this License; and
You must cause any modified files to carry prominent notices stating that You
changed the files; and
You must retain, in the Source form of any Derivative Works that You distribute,
all copyright, patent, trademark, and attribution notices from the Source form
of the Work, excluding those notices that do not pertain to any part of the
Derivative Works; and
If the Work includes a "NOTICE" text file as part of its distribution, then any
Derivative Works that You distribute must include a readable copy of the
attribution notices contained within such NOTICE file, excluding those notices
that do not pertain to any part of the Derivative Works, in at least one of the
following places: within a NOTICE text file distributed as part of the
Derivative Works; within the Source form or documentation, if provided along
with the Derivative Works; or, within a display generated by the Derivative
Works, if and wherever such third-party notices normally appear. The contents of
the NOTICE file are for informational purposes only and do not modify the
License. You may add Your own attribution notices within Derivative Works that
You distribute, alongside or as an addendum to the NOTICE text from the Work,
provided that such additional attribution notices cannot be construed as
modifying the License.
You may add Your own copyright statement to Your modifications and may provide
additional or different license terms and conditions for use, reproduction, or
distribution of Your modifications, or for any such Derivative Works as a whole,
provided Your use, reproduction, and distribution of the Work otherwise complies
with the conditions stated in this License.
5. Submission of Contributions.
Unless You explicitly state otherwise, any Contribution intentionally submitted
for inclusion in the Work by You to the Licensor shall be under the terms and
conditions of this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify the terms of
any separate license agreement you may have executed with Licensor regarding
such Contributions.
6. Trademarks.
This License does not grant permission to use the trade names, trademarks,
service marks, or product names of the Licensor, except as required for
reasonable and customary use in describing the origin of the Work and
reproducing the content of the NOTICE file.
7. Disclaimer of Warranty.
Unless required by applicable law or agreed to in writing, Licensor provides the
Work (and each Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
including, without limitation, any warranties or conditions of TITLE,
NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are
solely responsible for determining the appropriateness of using or
redistributing the Work and assume any risks associated with Your exercise of
permissions under this License.
8. Limitation of Liability.
In no event and under no legal theory, whether in tort (including negligence),
contract, or otherwise, unless required by applicable law (such as deliberate
and grossly negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special, incidental,
or consequential damages of any character arising as a result of this License or
out of the use or inability to use the Work (including but not limited to
damages for loss of goodwill, work stoppage, computer failure or malfunction, or
any and all other commercial damages or losses), even if such Contributor has
been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability.
While redistributing the Work or Derivative Works thereof, You may choose to
offer, and charge a fee for, acceptance of support, warranty, indemnity, or
other liability obligations and/or rights consistent with this License. However,
in accepting such obligations, You may act only on Your own behalf and on Your
sole responsibility, not on behalf of any other Contributor, and only if You
agree to indemnify, defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason of your
accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work
To apply the Apache License to your work, attach the following boilerplate
notice, with the fields enclosed by brackets "[]" replaced with your own
identifying information. (Don't include the brackets!) The text should be
enclosed in the appropriate comment syntax for the file format. We also
recommend that a file or class name and description of purpose be included on
the same "printed page" as the copyright notice for easier identification within
third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

319
node_modules/btoa/LICENSE.DOCS generated vendored Normal file
View File

@ -0,0 +1,319 @@
Creative Commons Legal Code
Attribution 3.0 Unported
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
LEGAL SERVICES. DISTRIBUTION OF THIS LICENSE DOES NOT CREATE AN
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
REGARDING THE INFORMATION PROVIDED, AND DISCLAIMS LIABILITY FOR
DAMAGES RESULTING FROM ITS USE.
License
THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE
COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY
COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS
AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE
TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY
BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS
CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND
CONDITIONS.
1. Definitions
a. "Adaptation" means a work based upon the Work, or upon the Work and
other pre-existing works, such as a translation, adaptation,
derivative work, arrangement of music or other alterations of a
literary or artistic work, or phonogram or performance and includes
cinematographic adaptations or any other form in which the Work may be
recast, transformed, or adapted including in any form recognizably
derived from the original, except that a work that constitutes a
Collection will not be considered an Adaptation for the purpose of
this License. For the avoidance of doubt, where the Work is a musical
work, performance or phonogram, the synchronization of the Work in
timed-relation with a moving image ("synching") will be considered an
Adaptation for the purpose of this License.
b. "Collection" means a collection of literary or artistic works, such as
encyclopedias and anthologies, or performances, phonograms or
broadcasts, or other works or subject matter other than works listed
in Section 1(f) below, which, by reason of the selection and
arrangement of their contents, constitute intellectual creations, in
which the Work is included in its entirety in unmodified form along
with one or more other contributions, each constituting separate and
independent works in themselves, which together are assembled into a
collective whole. A work that constitutes a Collection will not be
considered an Adaptation (as defined above) for the purposes of this
License.
c. "Distribute" means to make available to the public the original and
copies of the Work or Adaptation, as appropriate, through sale or
other transfer of ownership.
d. "Licensor" means the individual, individuals, entity or entities that
offer(s) the Work under the terms of this License.
e. "Original Author" means, in the case of a literary or artistic work,
the individual, individuals, entity or entities who created the Work
or if no individual or entity can be identified, the publisher; and in
addition (i) in the case of a performance the actors, singers,
musicians, dancers, and other persons who act, sing, deliver, declaim,
play in, interpret or otherwise perform literary or artistic works or
expressions of folklore; (ii) in the case of a phonogram the producer
being the person or legal entity who first fixes the sounds of a
performance or other sounds; and, (iii) in the case of broadcasts, the
organization that transmits the broadcast.
f. "Work" means the literary and/or artistic work offered under the terms
of this License including without limitation any production in the
literary, scientific and artistic domain, whatever may be the mode or
form of its expression including digital form, such as a book,
pamphlet and other writing; a lecture, address, sermon or other work
of the same nature; a dramatic or dramatico-musical work; a
choreographic work or entertainment in dumb show; a musical
composition with or without words; a cinematographic work to which are
assimilated works expressed by a process analogous to cinematography;
a work of drawing, painting, architecture, sculpture, engraving or
lithography; a photographic work to which are assimilated works
expressed by a process analogous to photography; a work of applied
art; an illustration, map, plan, sketch or three-dimensional work
relative to geography, topography, architecture or science; a
performance; a broadcast; a phonogram; a compilation of data to the
extent it is protected as a copyrightable work; or a work performed by
a variety or circus performer to the extent it is not otherwise
considered a literary or artistic work.
g. "You" means an individual or entity exercising rights under this
License who has not previously violated the terms of this License with
respect to the Work, or who has received express permission from the
Licensor to exercise rights under this License despite a previous
violation.
h. "Publicly Perform" means to perform public recitations of the Work and
to communicate to the public those public recitations, by any means or
process, including by wire or wireless means or public digital
performances; to make available to the public Works in such a way that
members of the public may access these Works from a place and at a
place individually chosen by them; to perform the Work to the public
by any means or process and the communication to the public of the
performances of the Work, including by public digital performance; to
broadcast and rebroadcast the Work by any means including signs,
sounds or images.
i. "Reproduce" means to make copies of the Work by any means including
without limitation by sound or visual recordings and the right of
fixation and reproducing fixations of the Work, including storage of a
protected performance or phonogram in digital form or other electronic
medium.
2. Fair Dealing Rights. Nothing in this License is intended to reduce,
limit, or restrict any uses free from copyright or rights arising from
limitations or exceptions that are provided for in connection with the
copyright protection under copyright law or other applicable laws.
3. License Grant. Subject to the terms and conditions of this License,
Licensor hereby grants You a worldwide, royalty-free, non-exclusive,
perpetual (for the duration of the applicable copyright) license to
exercise the rights in the Work as stated below:
a. to Reproduce the Work, to incorporate the Work into one or more
Collections, and to Reproduce the Work as incorporated in the
Collections;
b. to create and Reproduce Adaptations provided that any such Adaptation,
including any translation in any medium, takes reasonable steps to
clearly label, demarcate or otherwise identify that changes were made
to the original Work. For example, a translation could be marked "The
original work was translated from English to Spanish," or a
modification could indicate "The original work has been modified.";
c. to Distribute and Publicly Perform the Work including as incorporated
in Collections; and,
d. to Distribute and Publicly Perform Adaptations.
e. For the avoidance of doubt:
i. Non-waivable Compulsory License Schemes. In those jurisdictions in
which the right to collect royalties through any statutory or
compulsory licensing scheme cannot be waived, the Licensor
reserves the exclusive right to collect such royalties for any
exercise by You of the rights granted under this License;
ii. Waivable Compulsory License Schemes. In those jurisdictions in
which the right to collect royalties through any statutory or
compulsory licensing scheme can be waived, the Licensor waives the
exclusive right to collect such royalties for any exercise by You
of the rights granted under this License; and,
iii. Voluntary License Schemes. The Licensor waives the right to
collect royalties, whether individually or, in the event that the
Licensor is a member of a collecting society that administers
voluntary licensing schemes, via that society, from any exercise
by You of the rights granted under this License.
The above rights may be exercised in all media and formats whether now
known or hereafter devised. The above rights include the right to make
such modifications as are technically necessary to exercise the rights in
other media and formats. Subject to Section 8(f), all rights not expressly
granted by Licensor are hereby reserved.
4. Restrictions. The license granted in Section 3 above is expressly made
subject to and limited by the following restrictions:
a. You may Distribute or Publicly Perform the Work only under the terms
of this License. You must include a copy of, or the Uniform Resource
Identifier (URI) for, this License with every copy of the Work You
Distribute or Publicly Perform. You may not offer or impose any terms
on the Work that restrict the terms of this License or the ability of
the recipient of the Work to exercise the rights granted to that
recipient under the terms of the License. You may not sublicense the
Work. You must keep intact all notices that refer to this License and
to the disclaimer of warranties with every copy of the Work You
Distribute or Publicly Perform. When You Distribute or Publicly
Perform the Work, You may not impose any effective technological
measures on the Work that restrict the ability of a recipient of the
Work from You to exercise the rights granted to that recipient under
the terms of the License. This Section 4(a) applies to the Work as
incorporated in a Collection, but this does not require the Collection
apart from the Work itself to be made subject to the terms of this
License. If You create a Collection, upon notice from any Licensor You
must, to the extent practicable, remove from the Collection any credit
as required by Section 4(b), as requested. If You create an
Adaptation, upon notice from any Licensor You must, to the extent
practicable, remove from the Adaptation any credit as required by
Section 4(b), as requested.
b. If You Distribute, or Publicly Perform the Work or any Adaptations or
Collections, You must, unless a request has been made pursuant to
Section 4(a), keep intact all copyright notices for the Work and
provide, reasonable to the medium or means You are utilizing: (i) the
name of the Original Author (or pseudonym, if applicable) if supplied,
and/or if the Original Author and/or Licensor designate another party
or parties (e.g., a sponsor institute, publishing entity, journal) for
attribution ("Attribution Parties") in Licensor's copyright notice,
terms of service or by other reasonable means, the name of such party
or parties; (ii) the title of the Work if supplied; (iii) to the
extent reasonably practicable, the URI, if any, that Licensor
specifies to be associated with the Work, unless such URI does not
refer to the copyright notice or licensing information for the Work;
and (iv) , consistent with Section 3(b), in the case of an Adaptation,
a credit identifying the use of the Work in the Adaptation (e.g.,
"French translation of the Work by Original Author," or "Screenplay
based on original Work by Original Author"). The credit required by
this Section 4 (b) may be implemented in any reasonable manner;
provided, however, that in the case of a Adaptation or Collection, at
a minimum such credit will appear, if a credit for all contributing
authors of the Adaptation or Collection appears, then as part of these
credits and in a manner at least as prominent as the credits for the
other contributing authors. For the avoidance of doubt, You may only
use the credit required by this Section for the purpose of attribution
in the manner set out above and, by exercising Your rights under this
License, You may not implicitly or explicitly assert or imply any
connection with, sponsorship or endorsement by the Original Author,
Licensor and/or Attribution Parties, as appropriate, of You or Your
use of the Work, without the separate, express prior written
permission of the Original Author, Licensor and/or Attribution
Parties.
c. Except as otherwise agreed in writing by the Licensor or as may be
otherwise permitted by applicable law, if You Reproduce, Distribute or
Publicly Perform the Work either by itself or as part of any
Adaptations or Collections, You must not distort, mutilate, modify or
take other derogatory action in relation to the Work which would be
prejudicial to the Original Author's honor or reputation. Licensor
agrees that in those jurisdictions (e.g. Japan), in which any exercise
of the right granted in Section 3(b) of this License (the right to
make Adaptations) would be deemed to be a distortion, mutilation,
modification or other derogatory action prejudicial to the Original
Author's honor and reputation, the Licensor will waive or not assert,
as appropriate, this Section, to the fullest extent permitted by the
applicable national law, to enable You to reasonably exercise Your
right under Section 3(b) of this License (right to make Adaptations)
but not otherwise.
5. Representations, Warranties and Disclaimer
UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, LICENSOR
OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY
KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE,
INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY,
FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF
LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS,
WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION
OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU.
6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE
LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR
ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES
ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS
BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
7. Termination
a. This License and the rights granted hereunder will terminate
automatically upon any breach by You of the terms of this License.
Individuals or entities who have received Adaptations or Collections
from You under this License, however, will not have their licenses
terminated provided such individuals or entities remain in full
compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will
survive any termination of this License.
b. Subject to the above terms and conditions, the license granted here is
perpetual (for the duration of the applicable copyright in the Work).
Notwithstanding the above, Licensor reserves the right to release the
Work under different license terms or to stop distributing the Work at
any time; provided, however that any such election will not serve to
withdraw this License (or any other license that has been, or is
required to be, granted under the terms of this License), and this
License will continue in full force and effect unless terminated as
stated above.
8. Miscellaneous
a. Each time You Distribute or Publicly Perform the Work or a Collection,
the Licensor offers to the recipient a license to the Work on the same
terms and conditions as the license granted to You under this License.
b. Each time You Distribute or Publicly Perform an Adaptation, Licensor
offers to the recipient a license to the original Work on the same
terms and conditions as the license granted to You under this License.
c. If any provision of this License is invalid or unenforceable under
applicable law, it shall not affect the validity or enforceability of
the remainder of the terms of this License, and without further action
by the parties to this agreement, such provision shall be reformed to
the minimum extent necessary to make such provision valid and
enforceable.
d. No term or provision of this License shall be deemed waived and no
breach consented to unless such waiver or consent shall be in writing
and signed by the party to be charged with such waiver or consent.
e. This License constitutes the entire agreement between the parties with
respect to the Work licensed here. There are no understandings,
agreements or representations with respect to the Work not specified
here. Licensor shall not be bound by any additional provisions that
may appear in any communication from You. This License may not be
modified without the mutual written agreement of the Licensor and You.
f. The rights granted under, and the subject matter referenced, in this
License were drafted utilizing the terminology of the Berne Convention
for the Protection of Literary and Artistic Works (as amended on
September 28, 1979), the Rome Convention of 1961, the WIPO Copyright
Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996
and the Universal Copyright Convention (as revised on July 24, 1971).
These rights and subject matter take effect in the relevant
jurisdiction in which the License terms are sought to be enforced
according to the corresponding provisions of the implementation of
those treaty provisions in the applicable national law. If the
standard suite of rights granted under applicable copyright law
includes additional rights not granted under this License, such
additional rights are deemed to be included in the License; this
License is not intended to restrict the license of any rights under
applicable law.
Creative Commons Notice
Creative Commons is not a party to this License, and makes no warranty
whatsoever in connection with the Work. Creative Commons will not be
liable to You or any party on any legal theory for any damages
whatsoever, including without limitation any general, special,
incidental or consequential damages arising in connection to this
license. Notwithstanding the foregoing two (2) sentences, if Creative
Commons has expressly identified itself as the Licensor hereunder, it
shall have all rights and obligations of Licensor.
Except for the limited purpose of indicating to the public that the
Work is licensed under the CCPL, Creative Commons does not authorize
the use by either party of the trademark "Creative Commons" or any
related trademark or logo of Creative Commons without the prior
written consent of Creative Commons. Any permitted use will be in
compliance with Creative Commons' then-current trademark usage
guidelines, as may be published on its website or otherwise made
available upon request from time to time. For the avoidance of doubt,
this trademark restriction does not form part of this License.
Creative Commons may be contacted at http://creativecommons.org/.

40
node_modules/btoa/README.md generated vendored Normal file
View File

@ -0,0 +1,40 @@
btoa
===
| [atob](https://git.coolaj86.com/coolaj86/atob.js)
| **btoa**
| [unibabel.js](https://git.coolaj86.com/coolaj86/unibabel.js)
| Sponsored by [ppl](https://ppl.family)
A port of the browser's `btoa` function.
Uses `Buffer` to emulate the exact functionality of the browser's btoa
(except that it supports some unicode that the browser may not).
It turns <strong>b</strong>inary data __to__ base64-encoded <strong>a</strong>scii.
```js
(function () {
"use strict";
var btoa = require('btoa');
var bin = "Hello, 世界";
var b64 = btoa(bin);
console.log(b64); // "SGVsbG8sIBZM"
}());
```
**Note**: Unicode may or may not be handled incorrectly.
This module is intended to provide exact compatibility with the browser.
Copyright and License
===
Code copyright 2012-2018 AJ ONeal
Dual-licensed MIT and Apache-2.0
Docs copyright 2012-2018 AJ ONeal
Docs released under [Creative Commons](https://git.coolaj86.com/coolaj86/btoa.js/blob/master/LICENSE.DOCS).

8
node_modules/btoa/bin/btoa.js generated vendored Normal file
View File

@ -0,0 +1,8 @@
#!/usr/bin/env node
(function () {
"use strict";
var btoa = require('../index');
console.log(btoa(process.argv[2]));
}());

17
node_modules/btoa/index.js generated vendored Normal file
View File

@ -0,0 +1,17 @@
(function () {
"use strict";
function btoa(str) {
var buffer;
if (str instanceof Buffer) {
buffer = str;
} else {
buffer = Buffer.from(str.toString(), 'binary');
}
return buffer.toString('base64');
}
module.exports = btoa;
}());

84
node_modules/btoa/package.json generated vendored Normal file
View File

@ -0,0 +1,84 @@
{
"_args": [
[
"btoa",
"/mnt/c/Users/Josua/Desktop/data/nodejs/electron/chat-project/chat-client"
]
],
"_from": "btoa@latest",
"_id": "btoa@1.2.1",
"_inCache": true,
"_installable": true,
"_location": "/btoa",
"_nodeVersion": "8.9.4",
"_npmOperationalInternal": {
"host": "s3://npm-registry-packages",
"tmp": "tmp/btoa_1.2.1_1522212847456_0.8367382855709491"
},
"_npmUser": {
"email": "coolaj86@gmail.com",
"name": "coolaj86"
},
"_npmVersion": "5.6.0",
"_phantomChildren": {},
"_requested": {
"name": "btoa",
"raw": "btoa",
"rawSpec": "",
"scope": null,
"spec": "latest",
"type": "tag"
},
"_requiredBy": [
"#USER"
],
"_resolved": "https://registry.npmjs.org/btoa/-/btoa-1.2.1.tgz",
"_shasum": "01a9909f8b2c93f6bf680ba26131eb30f7fa3d73",
"_shrinkwrap": null,
"_spec": "btoa",
"_where": "/mnt/c/Users/Josua/Desktop/data/nodejs/electron/chat-project/chat-client",
"author": {
"email": "coolaj86@gmail.com",
"name": "AJ ONeal",
"url": "https://coolaj86.com"
},
"bin": {
"btoa": "bin/btoa.js"
},
"dependencies": {},
"description": "btoa for Node.JS (it's a one-liner)",
"devDependencies": {},
"directories": {},
"dist": {
"fileCount": 7,
"integrity": "sha512-SB4/MIGlsiVkMcHmT+pSmIPoNDoHg+7cMzmt3Uxt628MTz2487DKSqK/fuhFBrkuqrYv5UCEnACpF4dTFNKc/g==",
"shasum": "01a9909f8b2c93f6bf680ba26131eb30f7fa3d73",
"tarball": "https://registry.npmjs.org/btoa/-/btoa-1.2.1.tgz",
"unpackedSize": 32050
},
"engines": {
"node": ">= 0.4.0"
},
"gitHead": "19e0da65686fc1d726f1b5210930a47fe9fbd3a3",
"homepage": "https://git.coolaj86.com/coolaj86/btoa.js.git",
"keywords": [
"browser",
"btoa"
],
"license": "(MIT OR Apache-2.0)",
"main": "index",
"maintainers": [
{
"name": "coolaj86",
"email": "coolaj86@gmail.com"
}
],
"name": "btoa",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git://git.coolaj86.com/coolaj86/btoa.js.git"
},
"version": "1.2.1"
}

16
node_modules/btoa/test.js generated vendored Normal file
View File

@ -0,0 +1,16 @@
/*jshint strict:true node:true es5:true onevar:true laxcomma:true laxbreak:true eqeqeq:true immed:true latedef:true*/
(function () {
"use strict";
var btoa = require('./index')
, encoded = "SGVsbG8sIBZM"
, unencoded = "Hello, 世界"
;
if (encoded !== btoa(unencoded)) {
console.error('[FAIL]', encoded, btoa(unencoded));
return;
}
console.log('[PASS] all tests pass');
}());

9
node_modules/child_process/README.md generated vendored Normal file
View File

@ -0,0 +1,9 @@
# Security holding package
This package name is not currently in use, but was formerly occupied
by another package. To avoid malicious use, npm is hanging on to the
package name, but loosely, and we'll probably give it to you if you
want it.
You may adopt this package by contacting support@npmjs.com and
requesting the name.

74
node_modules/child_process/package.json generated vendored Normal file
View File

@ -0,0 +1,74 @@
{
"_args": [
[
"child_process",
"/mnt/c/Users/Josua/Desktop/data/nodejs/electron/chat-project/chat-client"
]
],
"_from": "child_process@latest",
"_id": "child_process@1.0.2",
"_inCache": true,
"_installable": true,
"_location": "/child_process",
"_nodeVersion": "4.2.6",
"_npmOperationalInternal": {
"host": "packages-12-west.internal.npmjs.com",
"tmp": "tmp/child_process-1.0.2.tgz_1472177094795_0.5847098815720528"
},
"_npmUser": {
"email": "npm@npmjs.com",
"name": "npm"
},
"_npmVersion": "3.9.2",
"_phantomChildren": {},
"_requested": {
"name": "child_process",
"raw": "child_process",
"rawSpec": "",
"scope": null,
"spec": "latest",
"type": "tag"
},
"_requiredBy": [
"#USER"
],
"_resolved": "https://registry.npmjs.org/child_process/-/child_process-1.0.2.tgz",
"_shasum": "b1f7e7fc73d25e7fd1d455adc94e143830182b5a",
"_shrinkwrap": null,
"_spec": "child_process",
"_where": "/mnt/c/Users/Josua/Desktop/data/nodejs/electron/chat-project/chat-client",
"author": "",
"bugs": {
"url": "https://github.com/npm/security-holder/issues"
},
"dependencies": {},
"description": "This package name is not currently in use, but was formerly occupied by another package. To avoid malicious use, npm is hanging on to the package name, but loosely, and we'll probably give it to you if you want it.",
"devDependencies": {},
"directories": {},
"dist": {
"shasum": "b1f7e7fc73d25e7fd1d455adc94e143830182b5a",
"tarball": "https://registry.npmjs.org/child_process/-/child_process-1.0.2.tgz"
},
"gitHead": "9ef10011153183d323ed420df5bb17eaf08ab730",
"homepage": "https://github.com/npm/security-holder#readme",
"keywords": [],
"license": "ISC",
"main": "index.js",
"maintainers": [
{
"name": "npm",
"email": "npm@npmjs.com"
}
],
"name": "child_process",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git+https://github.com/npm/security-holder.git"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"version": "1.0.2"
}

19
node_modules/circular-json/LICENSE.txt generated vendored Normal file
View File

@ -0,0 +1,19 @@
Copyright (C) 2013-2017 by Andrea Giammarchi - @WebReflection
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.

146
node_modules/circular-json/README.md generated vendored Normal file
View File

@ -0,0 +1,146 @@
CircularJSON
============
[![donate](https://img.shields.io/badge/$-donate-ff69b4.svg?maxAge=2592000&style=flat)](https://github.com/WebReflection/donate) ![Downloads](https://img.shields.io/npm/dm/circular-json.svg) [![Build Status](https://travis-ci.org/WebReflection/circular-json.svg?branch=master)](https://travis-ci.org/WebReflection/circular-json) [![Coverage Status](https://coveralls.io/repos/github/WebReflection/circular-json/badge.svg?branch=master)](https://coveralls.io/github/WebReflection/circular-json?branch=master)
Serializes and deserializes otherwise valid JSON objects containing circular references into and from a specialized JSON format.
- - -
## The future of this module is called [flatted](https://github.com/WebReflection/flatted#flatted)
Smaller, faster, and able to produce on average a reduced output too, [flatted](https://github.com/WebReflection/flatted#flatted) is the new, bloatless, ESM and CJS compatible, circular JSON parser.
It has now reached V1 and it implements the exact same JSON API.
Please note **CircularJSON is in maintenance only** and **[flatted](https://github.com/WebReflection/flatted#flatted) is its successor**.
- - -
### A Working Solution To A Common Problem
A usage example:
```JavaScript
var object = {};
object.arr = [
object, object
];
object.arr.push(object.arr);
object.obj = object;
var serialized = CircularJSON.stringify(object);
// '{"arr":["~","~","~arr"],"obj":"~"}'
// NOTE: CircularJSON DOES NOT parse JS
// it handles receiver and reviver callbacks
var unserialized = CircularJSON.parse(serialized);
// { arr: [ [Circular], [Circular] ],
// obj: [Circular] }
unserialized.obj === unserialized;
unserialized.arr[0] === unserialized;
unserialized.arr.pop() === unserialized.arr;
```
A quick summary:
* **new** in version `0.5`, you can specify a JSON parser different from JSON itself. `CircularJSON.parser = ABetterJSON;` is all you need.
* uses `~` as a special prefix symbol to denote which parent the reference belongs to (i.e. `~root~child1~child2`)
* reasonably fast in both serialization and deserialization
* compact serialization for easier and slimmer transportation across environments
* [tested and covered](test/circular-json.js) over nasty structures too
* compatible with all JavaScript engines
Node Installation & Usage
============
```bash
npm install --save circular-json
```
```javascript
'use strict';
var
CircularJSON = require('circular-json'),
obj = { foo: 'bar' },
str
;
obj.self = obj;
str = CircularJSON.stringify(obj);
```
There are no dependencies.
Browser Installation & Usage
================
* Global: <build/circular-json.js>
* AMD: <build/circular-json.amd.js>
* CommonJS: <build/circular-json.node.js>
(generated via [gitstrap](https://github.com/WebReflection/gitstrap))
```html
<script src="build/circular-json.js"></script>
```
```javascript
'use strict';
var CircularJSON = window.CircularJSON
, obj = { foo: 'bar' }
, str
;
obj.self = obj;
str = CircularJSON.stringify(obj);
```
NOTE: Platforms without native JSON (i.e. MSIE <= 8) requires `json3.js` or similar.
It is also *a bad idea* to `CircularJSON.parse(JSON.stringify(object))` because of those manipulation used in `CircularJSON.stringify()` able to make parsing safe and secure.
As summary: `CircularJSON.parse(CircularJSON.stringify(object))` is the way to go, same is for `JSON.parse(JSON.stringify(object))`.
API
===
It's the same as native JSON, except the fourth parameter `placeholder`, which circular references to be replaced with `"[Circular]"` (i.e. for logging).
* CircularJSON.stringify(object, replacer, spacer, placeholder)
* CircularJSON.parse(string, reviver)
Bear in mind `JSON.parse(CircularJSON.stringify(object))` will work but not produce the expected output.
Similar Libraries
=======
### Why Not the [@izs](https://twitter.com/izs) One
The module [json-stringify-safe](https://github.com/isaacs/json-stringify-safe) seems to be for `console.log()` but it's completely pointless for `JSON.parse()`, being latter one unable to retrieve back the initial structure. Here an example:
```JavaScript
// a logged object with circular references
{
"circularRef": "[Circular]",
"list": [
"[Circular]",
"[Circular]"
]
}
// what do we do with above output ?
```
Just type this in your `node` console: `var o = {}; o.a = o; console.log(o);`. The output will be `{ a: [Circular] }` ... good, but that ain't really solving the problem.
However, if that's all you need, the function used to create that kind of output is probably faster than `CircularJSON` and surely fits in less lines of code.
### Why Not {{put random name}} Solution
So here the thing: circular references can be wrong but, if there is a need for them, any attempt to ignore them or remove them can be considered just a failure.
Not because the method is bad or it's not working, simply because the circular info, the one we needed and used in the first place, is lost!
In this case, `CircularJSON` does even more than just solve circular and recursions: it maps all same objects so that less memory is used as well on deserialization as less bandwidth too!
It's able to redefine those references back later on so the way we store is the way we retrieve and in a reasonably performant way, also trusting the snappy and native `JSON` methods to iterate.

2
node_modules/circular-json/build/circular-json.js generated vendored Normal file
View File

@ -0,0 +1,2 @@
/*! (C) WebReflection Mit Style License */
var CircularJSON=function(JSON,RegExp){var specialChar="~",safeSpecialChar="\\x"+("0"+specialChar.charCodeAt(0).toString(16)).slice(-2),escapedSafeSpecialChar="\\"+safeSpecialChar,specialCharRG=new RegExp(safeSpecialChar,"g"),safeSpecialCharRG=new RegExp(escapedSafeSpecialChar,"g"),safeStartWithSpecialCharRG=new RegExp("(?:^|([^\\\\]))"+escapedSafeSpecialChar),indexOf=[].indexOf||function(v){for(var i=this.length;i--&&this[i]!==v;);return i},$String=String;function generateReplacer(value,replacer,resolve){var doNotIgnore=false,inspect=!!replacer,path=[],all=[value],seen=[value],mapp=[resolve?specialChar:"[Circular]"],last=value,lvl=1,i,fn;if(inspect){fn=typeof replacer==="object"?function(key,value){return key!==""&&replacer.indexOf(key)<0?void 0:value}:replacer}return function(key,value){if(inspect)value=fn.call(this,key,value);if(doNotIgnore){if(last!==this){i=lvl-indexOf.call(all,this)-1;lvl-=i;all.splice(lvl,all.length);path.splice(lvl-1,path.length);last=this}if(typeof value==="object"&&value){if(indexOf.call(all,value)<0){all.push(last=value)}lvl=all.length;i=indexOf.call(seen,value);if(i<0){i=seen.push(value)-1;if(resolve){path.push((""+key).replace(specialCharRG,safeSpecialChar));mapp[i]=specialChar+path.join(specialChar)}else{mapp[i]=mapp[0]}}else{value=mapp[i]}}else{if(typeof value==="string"&&resolve){value=value.replace(safeSpecialChar,escapedSafeSpecialChar).replace(specialChar,safeSpecialChar)}}}else{doNotIgnore=true}return value}}function retrieveFromPath(current,keys){for(var i=0,length=keys.length;i<length;current=current[keys[i++].replace(safeSpecialCharRG,specialChar)]);return current}function generateReviver(reviver){return function(key,value){var isString=typeof value==="string";if(isString&&value.charAt(0)===specialChar){return new $String(value.slice(1))}if(key==="")value=regenerate(value,value,{});if(isString)value=value.replace(safeStartWithSpecialCharRG,"$1"+specialChar).replace(escapedSafeSpecialChar,safeSpecialChar);return reviver?reviver.call(this,key,value):value}}function regenerateArray(root,current,retrieve){for(var i=0,length=current.length;i<length;i++){current[i]=regenerate(root,current[i],retrieve)}return current}function regenerateObject(root,current,retrieve){for(var key in current){if(current.hasOwnProperty(key)){current[key]=regenerate(root,current[key],retrieve)}}return current}function regenerate(root,current,retrieve){return current instanceof Array?regenerateArray(root,current,retrieve):current instanceof $String?current.length?retrieve.hasOwnProperty(current)?retrieve[current]:retrieve[current]=retrieveFromPath(root,current.split(specialChar)):root:current instanceof Object?regenerateObject(root,current,retrieve):current}var CircularJSON={stringify:function stringify(value,replacer,space,doNotResolve){return CircularJSON.parser.stringify(value,generateReplacer(value,replacer,!doNotResolve),space)},parse:function parse(text,reviver){return CircularJSON.parser.parse(text,generateReviver(reviver))},parser:JSON};return CircularJSON}(JSON,RegExp);

210
node_modules/circular-json/build/circular-json.max.js generated vendored Normal file
View File

@ -0,0 +1,210 @@
/*!
Copyright (C) 2013-2017 by Andrea Giammarchi - @WebReflection
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 CircularJSON = (function(JSON, RegExp){
var
// should be a not so common char
// possibly one JSON does not encode
// possibly one encodeURIComponent does not encode
// right now this char is '~' but this might change in the future
specialChar = '~',
safeSpecialChar = '\\x' + (
'0' + specialChar.charCodeAt(0).toString(16)
).slice(-2),
escapedSafeSpecialChar = '\\' + safeSpecialChar,
specialCharRG = new RegExp(safeSpecialChar, 'g'),
safeSpecialCharRG = new RegExp(escapedSafeSpecialChar, 'g'),
safeStartWithSpecialCharRG = new RegExp('(?:^|([^\\\\]))' + escapedSafeSpecialChar),
indexOf = [].indexOf || function(v){
for(var i=this.length;i--&&this[i]!==v;);
return i;
},
$String = String // there's no way to drop warnings in JSHint
// about new String ... well, I need that here!
// faked, and happy linter!
;
function generateReplacer(value, replacer, resolve) {
var
doNotIgnore = false,
inspect = !!replacer,
path = [],
all = [value],
seen = [value],
mapp = [resolve ? specialChar : '[Circular]'],
last = value,
lvl = 1,
i, fn
;
if (inspect) {
fn = typeof replacer === 'object' ?
function (key, value) {
return key !== '' && replacer.indexOf(key) < 0 ? void 0 : value;
} :
replacer;
}
return function(key, value) {
// the replacer has rights to decide
// if a new object should be returned
// or if there's some key to drop
// let's call it here rather than "too late"
if (inspect) value = fn.call(this, key, value);
// first pass should be ignored, since it's just the initial object
if (doNotIgnore) {
if (last !== this) {
i = lvl - indexOf.call(all, this) - 1;
lvl -= i;
all.splice(lvl, all.length);
path.splice(lvl - 1, path.length);
last = this;
}
// console.log(lvl, key, path);
if (typeof value === 'object' && value) {
// if object isn't referring to parent object, add to the
// object path stack. Otherwise it is already there.
if (indexOf.call(all, value) < 0) {
all.push(last = value);
}
lvl = all.length;
i = indexOf.call(seen, value);
if (i < 0) {
i = seen.push(value) - 1;
if (resolve) {
// key cannot contain specialChar but could be not a string
path.push(('' + key).replace(specialCharRG, safeSpecialChar));
mapp[i] = specialChar + path.join(specialChar);
} else {
mapp[i] = mapp[0];
}
} else {
value = mapp[i];
}
} else {
if (typeof value === 'string' && resolve) {
// ensure no special char involved on deserialization
// in this case only first char is important
// no need to replace all value (better performance)
value = value .replace(safeSpecialChar, escapedSafeSpecialChar)
.replace(specialChar, safeSpecialChar);
}
}
} else {
doNotIgnore = true;
}
return value;
};
}
function retrieveFromPath(current, keys) {
for(var i = 0, length = keys.length; i < length; current = current[
// keys should be normalized back here
keys[i++].replace(safeSpecialCharRG, specialChar)
]);
return current;
}
function generateReviver(reviver) {
return function(key, value) {
var isString = typeof value === 'string';
if (isString && value.charAt(0) === specialChar) {
return new $String(value.slice(1));
}
if (key === '') value = regenerate(value, value, {});
// again, only one needed, do not use the RegExp for this replacement
// only keys need the RegExp
if (isString) value = value .replace(safeStartWithSpecialCharRG, '$1' + specialChar)
.replace(escapedSafeSpecialChar, safeSpecialChar);
return reviver ? reviver.call(this, key, value) : value;
};
}
function regenerateArray(root, current, retrieve) {
for (var i = 0, length = current.length; i < length; i++) {
current[i] = regenerate(root, current[i], retrieve);
}
return current;
}
function regenerateObject(root, current, retrieve) {
for (var key in current) {
if (current.hasOwnProperty(key)) {
current[key] = regenerate(root, current[key], retrieve);
}
}
return current;
}
function regenerate(root, current, retrieve) {
return current instanceof Array ?
// fast Array reconstruction
regenerateArray(root, current, retrieve) :
(
current instanceof $String ?
(
// root is an empty string
current.length ?
(
retrieve.hasOwnProperty(current) ?
retrieve[current] :
retrieve[current] = retrieveFromPath(
root, current.split(specialChar)
)
) :
root
) :
(
current instanceof Object ?
// dedicated Object parser
regenerateObject(root, current, retrieve) :
// value as it is
current
)
)
;
}
var CircularJSON = {
stringify: function stringify(value, replacer, space, doNotResolve) {
return CircularJSON.parser.stringify(
value,
generateReplacer(value, replacer, !doNotResolve),
space
);
},
parse: function parse(text, reviver) {
return CircularJSON.parser.parse(
text,
generateReviver(reviver)
);
},
// A parser should be an API 1:1 compatible with JSON
// it should expose stringify and parse methods.
// The default parser is the native JSON.
parser: JSON
};
return CircularJSON;
}(JSON, RegExp));

207
node_modules/circular-json/build/circular-json.node.js generated vendored Normal file
View File

@ -0,0 +1,207 @@
/*!
Copyright (C) 2013-2017 by Andrea Giammarchi - @WebReflection
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
// should be a not so common char
// possibly one JSON does not encode
// possibly one encodeURIComponent does not encode
// right now this char is '~' but this might change in the future
specialChar = '~',
safeSpecialChar = '\\x' + (
'0' + specialChar.charCodeAt(0).toString(16)
).slice(-2),
escapedSafeSpecialChar = '\\' + safeSpecialChar,
specialCharRG = new RegExp(safeSpecialChar, 'g'),
safeSpecialCharRG = new RegExp(escapedSafeSpecialChar, 'g'),
safeStartWithSpecialCharRG = new RegExp('(?:^|([^\\\\]))' + escapedSafeSpecialChar),
indexOf = [].indexOf || function(v){
for(var i=this.length;i--&&this[i]!==v;);
return i;
},
$String = String // there's no way to drop warnings in JSHint
// about new String ... well, I need that here!
// faked, and happy linter!
;
function generateReplacer(value, replacer, resolve) {
var
doNotIgnore = false,
inspect = !!replacer,
path = [],
all = [value],
seen = [value],
mapp = [resolve ? specialChar : '[Circular]'],
last = value,
lvl = 1,
i, fn
;
if (inspect) {
fn = typeof replacer === 'object' ?
function (key, value) {
return key !== '' && replacer.indexOf(key) < 0 ? void 0 : value;
} :
replacer;
}
return function(key, value) {
// the replacer has rights to decide
// if a new object should be returned
// or if there's some key to drop
// let's call it here rather than "too late"
if (inspect) value = fn.call(this, key, value);
// first pass should be ignored, since it's just the initial object
if (doNotIgnore) {
if (last !== this) {
i = lvl - indexOf.call(all, this) - 1;
lvl -= i;
all.splice(lvl, all.length);
path.splice(lvl - 1, path.length);
last = this;
}
// console.log(lvl, key, path);
if (typeof value === 'object' && value) {
// if object isn't referring to parent object, add to the
// object path stack. Otherwise it is already there.
if (indexOf.call(all, value) < 0) {
all.push(last = value);
}
lvl = all.length;
i = indexOf.call(seen, value);
if (i < 0) {
i = seen.push(value) - 1;
if (resolve) {
// key cannot contain specialChar but could be not a string
path.push(('' + key).replace(specialCharRG, safeSpecialChar));
mapp[i] = specialChar + path.join(specialChar);
} else {
mapp[i] = mapp[0];
}
} else {
value = mapp[i];
}
} else {
if (typeof value === 'string' && resolve) {
// ensure no special char involved on deserialization
// in this case only first char is important
// no need to replace all value (better performance)
value = value .replace(safeSpecialChar, escapedSafeSpecialChar)
.replace(specialChar, safeSpecialChar);
}
}
} else {
doNotIgnore = true;
}
return value;
};
}
function retrieveFromPath(current, keys) {
for(var i = 0, length = keys.length; i < length; current = current[
// keys should be normalized back here
keys[i++].replace(safeSpecialCharRG, specialChar)
]);
return current;
}
function generateReviver(reviver) {
return function(key, value) {
var isString = typeof value === 'string';
if (isString && value.charAt(0) === specialChar) {
return new $String(value.slice(1));
}
if (key === '') value = regenerate(value, value, {});
// again, only one needed, do not use the RegExp for this replacement
// only keys need the RegExp
if (isString) value = value .replace(safeStartWithSpecialCharRG, '$1' + specialChar)
.replace(escapedSafeSpecialChar, safeSpecialChar);
return reviver ? reviver.call(this, key, value) : value;
};
}
function regenerateArray(root, current, retrieve) {
for (var i = 0, length = current.length; i < length; i++) {
current[i] = regenerate(root, current[i], retrieve);
}
return current;
}
function regenerateObject(root, current, retrieve) {
for (var key in current) {
if (current.hasOwnProperty(key)) {
current[key] = regenerate(root, current[key], retrieve);
}
}
return current;
}
function regenerate(root, current, retrieve) {
return current instanceof Array ?
// fast Array reconstruction
regenerateArray(root, current, retrieve) :
(
current instanceof $String ?
(
// root is an empty string
current.length ?
(
retrieve.hasOwnProperty(current) ?
retrieve[current] :
retrieve[current] = retrieveFromPath(
root, current.split(specialChar)
)
) :
root
) :
(
current instanceof Object ?
// dedicated Object parser
regenerateObject(root, current, retrieve) :
// value as it is
current
)
)
;
}
var CircularJSON = {
stringify: function stringify(value, replacer, space, doNotResolve) {
return CircularJSON.parser.stringify(
value,
generateReplacer(value, replacer, !doNotResolve),
space
);
},
parse: function parse(text, reviver) {
return CircularJSON.parser.parse(
text,
generateReviver(reviver)
);
},
// A parser should be an API 1:1 compatible with JSON
// it should expose stringify and parse methods.
// The default parser is the native JSON.
parser: JSON
};
module.exports = CircularJSON;

100
node_modules/circular-json/package.json generated vendored Normal file
View File

@ -0,0 +1,100 @@
{
"_args": [
[
"circular-json",
"/mnt/c/Users/Josua/Desktop/data/nodejs/electron/chat-project/chat-client"
]
],
"_from": "circular-json@latest",
"_hasShrinkwrap": false,
"_id": "circular-json@0.5.9",
"_inCache": true,
"_installable": true,
"_location": "/circular-json",
"_nodeVersion": "9.11.1",
"_npmOperationalInternal": {
"host": "s3://npm-registry-packages",
"tmp": "tmp/circular-json_0.5.9_1540325095720_0.16760917845332957"
},
"_npmUser": {
"email": "andrea.giammarchi@gmail.com",
"name": "webreflection"
},
"_npmVersion": "6.0.0",
"_phantomChildren": {},
"_requested": {
"name": "circular-json",
"raw": "circular-json",
"rawSpec": "",
"scope": null,
"spec": "latest",
"type": "tag"
},
"_requiredBy": [
"#USER"
],
"_resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.5.9.tgz",
"_shasum": "932763ae88f4f7dead7a0d09c8a51a4743a53b1d",
"_shrinkwrap": null,
"_spec": "circular-json",
"_where": "/mnt/c/Users/Josua/Desktop/data/nodejs/electron/chat-project/chat-client",
"author": {
"name": "Andrea Giammarchi",
"url": "http://webreflection.blogspot.com/"
},
"bugs": {
"url": "https://github.com/WebReflection/circular-json/issues"
},
"dependencies": {},
"deprecated": "CircularJSON is in maintenance only, flatted is its successor.",
"description": "JSON does not handle circular references. This version does",
"devDependencies": {
"coveralls": "^2.13.0",
"istanbul": "^0.4.5",
"tiny-cdn": "^0.7.0",
"tressa": "^0.3.1"
},
"directories": {},
"dist": {
"fileCount": 8,
"integrity": "sha512-4ivwqHpIFJZBuhN3g/pEcdbnGUywkBblloGbkglyloVjjR3uT6tieI89MVOfbP2tHX5sgb01FuLgAOzebNlJNQ==",
"npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbz37oCRA9TVsSAnZWagAAsSYP/RjvSGPXrxP6ptjmghAa\nEN0y2yee4izsGxkqFQWBu0ENXJVGbClT1LtIu6WH2RGrJslYLWMViw/g7h6o\nDYbExQ4jGVksRKVUtWVQMlv0QsoONa6F5zXC0+JdxeblxjHf/j2sAL3OpU+j\nR/RBpr9jupANRqbkuxauz7Bz+3xFoRSm092m6nzo6Nn+iud52lpOwCf9HMzm\npTAx/OUbTJH4l8O3M769+gok7NN2l5CUqx5Xam09FygLkqSwpkuov9Ge5Aku\nx9pDcGkdKSCjb0bA7ShsQQYObXpanim3RAEeSnEYwhKaZP2QfzElvLurmcV3\nAJSCaid30hAUAZ8RqLUSuf0yURC/73hR5Kw29F6rENAxw9utW7uXNDw1qTxC\nvctbMh3yE/jmebx9VUmKyjbFYDCFk2wVPiWIwOrH7j+u3Xg4AnS9I+JcI3aD\nlt0owFEhx9oe7SR9e4WiNzgGeCKciJDV4CSe36CPeK9ENoSRhGB4el9iKLIG\n3wvPtH/Z3DV6eV0cSG50UfmZnYgMLnyXSBZyP+dhj0TQVSbHokCno1/iu619\nNtQ3JlD+v6Mj64F9bECEOPAOdvDgxqwmlhHCc4IfLLHnznX+7OrlOrdDx7uz\nIR0cLSB2l52yQ6Xlqwaz2xTF6YhSSlRezCh/wAjzQkIZyT4jdzl9GuzVeLzC\npEkP\r\n=VAF5\r\n-----END PGP SIGNATURE-----\r\n",
"shasum": "932763ae88f4f7dead7a0d09c8a51a4743a53b1d",
"tarball": "https://registry.npmjs.org/circular-json/-/circular-json-0.5.9.tgz",
"unpackedSize": 24233
},
"generator": "https://github.com/WebReflection/gitstrap",
"gitHead": "ceab9c16070d3fc63f193bc10124eccb20424990",
"homepage": "https://github.com/WebReflection/circular-json",
"keywords": [
"JSON",
"circular",
"parse",
"recursion",
"recursive",
"reference",
"stringify"
],
"license": "MIT",
"main": "./build/circular-json.node.js",
"maintainers": [
{
"name": "webreflection",
"email": "andrea.giammarchi@gmail.com"
}
],
"name": "circular-json",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git://github.com/WebReflection/circular-json.git"
},
"scripts": {
"coveralls": "cat ./coverage/lcov.info | coveralls",
"test": "istanbul cover test/circular-json.js",
"web": "$(sleep 2 && open http://0.0.0.0:7151/) & tiny-cdn run ./"
},
"unpkg": "build/circular-json.js",
"version": "0.5.9"
}

2
node_modules/circular-json/template/license.after generated vendored Normal file
View File

@ -0,0 +1,2 @@
*/

1
node_modules/circular-json/template/license.before generated vendored Normal file
View File

@ -0,0 +1 @@
/*!

59
node_modules/errno/.jshintrc generated vendored Normal file
View File

@ -0,0 +1,59 @@
{
"predef": [ ]
, "bitwise": false
, "camelcase": false
, "curly": false
, "eqeqeq": false
, "forin": false
, "immed": false
, "latedef": false
, "noarg": true
, "noempty": true
, "nonew": true
, "plusplus": false
, "quotmark": true
, "regexp": false
, "undef": true
, "unused": true
, "strict": false
, "trailing": true
, "maxlen": 120
, "asi": true
, "boss": true
, "debug": true
, "eqnull": true
, "esnext": true
, "evil": true
, "expr": true
, "funcscope": false
, "globalstrict": false
, "iterator": false
, "lastsemic": true
, "laxbreak": true
, "laxcomma": true
, "loopfunc": true
, "multistr": false
, "onecase": false
, "proto": false
, "regexdash": false
, "scripturl": true
, "smarttabs": false
, "shadow": false
, "sub": true
, "supernew": false
, "validthis": true
, "browser": true
, "couch": false
, "devel": false
, "dojo": false
, "mootools": false
, "node": true
, "nonstandard": true
, "prototypejs": false
, "rhino": false
, "worker": true
, "wsh": false
, "nomen": false
, "onevar": false
, "passfail": false
}

11
node_modules/errno/.travis.yml generated vendored Normal file
View File

@ -0,0 +1,11 @@
sudo: false
language: node_js
node_js:
- 9
- 8
- 7
- 6
- 5
- 4

145
node_modules/errno/README.md generated vendored Normal file
View File

@ -0,0 +1,145 @@
# node-errno
> Better [libuv](https://github.com/libuv/libuv)/[Node.js](https://nodejs.org)/[io.js](https://iojs.org) error handling & reporting. Available in npm as *errno*.
[![npm](https://img.shields.io/npm/v/errno.svg)](https://www.npmjs.com/package/errno)
[![Build Status](https://secure.travis-ci.org/rvagg/node-errno.png)](http://travis-ci.org/rvagg/node-errno)
[![npm](https://img.shields.io/npm/dm/errno.svg)](https://www.npmjs.com/package/errno)
* [errno exposed](#errnoexposed)
* [Custom errors](#customerrors)
<a name="errnoexposed"></a>
## errno exposed
Ever find yourself needing more details about Node.js errors? Me too, so *node-errno* contains the errno mappings direct from libuv so you can use them in your code.
**By errno:**
```js
require('errno').errno[3]
// → {
// "errno": 3,
// "code": "EACCES",
// "description": "permission denied"
// }
```
**By code:**
```js
require('errno').code.ENOTEMPTY
// → {
// "errno": 53,
// "code": "ENOTEMPTY",
// "description": "directory not empty"
// }
```
**Make your errors more descriptive:**
```js
var errno = require('errno')
function errmsg(err) {
var str = 'Error: '
// if it's a libuv error then get the description from errno
if (errno.errno[err.errno])
str += errno.errno[err.errno].description
else
str += err.message
// if it's a `fs` error then it'll have a 'path' property
if (err.path)
str += ' [' + err.path + ']'
return str
}
var fs = require('fs')
fs.readFile('thisisnotarealfile.txt', function (err, data) {
if (err)
console.log(errmsg(err))
})
```
**Use as a command line tool:**
```
~ $ errno 53
{
"errno": 53,
"code": "ENOTEMPTY",
"description": "directory not empty"
}
~ $ errno EROFS
{
"errno": 56,
"code": "EROFS",
"description": "read-only file system"
}
~ $ errno foo
No such errno/code: "foo"
```
Supply no arguments for the full list. Error codes are processed case-insensitive.
You will need to install with `npm install errno -g` if you want the `errno` command to be available without supplying a full path to the node_modules installation.
<a name="customerrors"></a>
## Custom errors
Use `errno.custom.createError()` to create custom `Error` objects to throw around in your Node.js library. Create error hierarchies so `instanceof` becomes a useful tool in tracking errors. Call-stack is correctly captured at the time you create an instance of the error object, plus a `cause` property will make available the original error object if you pass one in to the constructor.
```js
var create = require('errno').custom.createError
var MyError = create('MyError') // inherits from Error
var SpecificError = create('SpecificError', MyError) // inherits from MyError
var OtherError = create('OtherError', MyError)
// use them!
if (condition) throw new SpecificError('Eeek! Something bad happened')
if (err) return callback(new OtherError(err))
```
Also available is a `errno.custom.FilesystemError` with in-built access to errno properties:
```js
fs.readFile('foo', function (err, data) {
if (err) return callback(new errno.custom.FilesystemError(err))
// do something else
})
```
The resulting error object passed through the callback will have the following properties: `code`, `errno`, `path` and `message` will contain a descriptive human-readable message.
## Contributors
* [bahamas10](https://github.com/bahamas10) (Dave Eddy) - Added CLI
* [ralphtheninja](https://github.com/ralphtheninja) (Lars-Magnus Skog)
## Copyright & Licence
*Copyright (c) 2012-2015 [Rod Vagg](https://github.com/rvagg) ([@rvagg](https://twitter.com/rvagg))*
Made available under the MIT licence:
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.

43
node_modules/errno/build.js generated vendored Normal file
View File

@ -0,0 +1,43 @@
#!/usr/bin/env node
var request = require('request')
, fs = require('fs')
, uvheadloc = 'https://raw.github.com/joyent/libuv/master/include/uv.h'
, defreg = /^\s*XX\(\s*([\-\d]+),\s*([A-Z]+),\s*"([^"]*)"\s*\)\s*\\?$/
request(uvheadloc, function (err, response) {
if (err)
throw err
var data, out
data = response.body
.split('\n')
.map(function (line) { return line.match(defreg) })
.filter(function (match) { return match })
.map(function (match) { return {
errno: parseInt(match[1], 10)
, code: match[2]
, description: match[3]
}})
out = 'var all = module.exports.all = ' + JSON.stringify(data, 0, 1) + '\n\n'
out += '\nmodule.exports.errno = {\n '
+ data.map(function (e, i) {
return '\'' + e.errno + '\': all[' + i + ']'
}).join('\n , ')
+ '\n}\n\n'
out += '\nmodule.exports.code = {\n '
+ data.map(function (e, i) {
return '\'' + e.code + '\': all[' + i + ']'
}).join('\n , ')
+ '\n}\n\n'
out += '\nmodule.exports.custom = require("./custom")(module.exports)\n'
fs.writeFile('errno.js', out)
})

22
node_modules/errno/cli.js generated vendored Normal file
View File

@ -0,0 +1,22 @@
#!/usr/bin/env node
var errno = require('./')
, arg = process.argv[2]
, data, code
if (arg === undefined) {
console.log(JSON.stringify(errno.code, null, 2))
process.exit(0)
}
if ((code = +arg) == arg)
data = errno.errno[code]
else
data = errno.code[arg] || errno.code[arg.toUpperCase()]
if (data)
console.log(JSON.stringify(data, null, 2))
else {
console.error('No such errno/code: "' + arg + '"')
process.exit(1)
}

57
node_modules/errno/custom.js generated vendored Normal file
View File

@ -0,0 +1,57 @@
var prr = require('prr')
function init (type, message, cause) {
if (!!message && typeof message != 'string') {
message = message.message || message.name
}
prr(this, {
type : type
, name : type
// can be passed just a 'cause'
, cause : typeof message != 'string' ? message : cause
, message : message
}, 'ewr')
}
// generic prototype, not intended to be actually used - helpful for `instanceof`
function CustomError (message, cause) {
Error.call(this)
if (Error.captureStackTrace)
Error.captureStackTrace(this, this.constructor)
init.call(this, 'CustomError', message, cause)
}
CustomError.prototype = new Error()
function createError (errno, type, proto) {
var err = function (message, cause) {
init.call(this, type, message, cause)
//TODO: the specificity here is stupid, errno should be available everywhere
if (type == 'FilesystemError') {
this.code = this.cause.code
this.path = this.cause.path
this.errno = this.cause.errno
this.message =
(errno.errno[this.cause.errno]
? errno.errno[this.cause.errno].description
: this.cause.message)
+ (this.cause.path ? ' [' + this.cause.path + ']' : '')
}
Error.call(this)
if (Error.captureStackTrace)
Error.captureStackTrace(this, err)
}
err.prototype = !!proto ? new proto() : new CustomError()
return err
}
module.exports = function (errno) {
var ce = function (type, proto) {
return createError(errno, type, proto)
}
return {
CustomError : CustomError
, FilesystemError : ce('FilesystemError')
, createError : ce
}
}

313
node_modules/errno/errno.js generated vendored Normal file
View File

@ -0,0 +1,313 @@
var all = module.exports.all = [
{
errno: -2,
code: 'ENOENT',
description: 'no such file or directory'
},
{
errno: -1,
code: 'UNKNOWN',
description: 'unknown error'
},
{
errno: 0,
code: 'OK',
description: 'success'
},
{
errno: 1,
code: 'EOF',
description: 'end of file'
},
{
errno: 2,
code: 'EADDRINFO',
description: 'getaddrinfo error'
},
{
errno: 3,
code: 'EACCES',
description: 'permission denied'
},
{
errno: 4,
code: 'EAGAIN',
description: 'resource temporarily unavailable'
},
{
errno: 5,
code: 'EADDRINUSE',
description: 'address already in use'
},
{
errno: 6,
code: 'EADDRNOTAVAIL',
description: 'address not available'
},
{
errno: 7,
code: 'EAFNOSUPPORT',
description: 'address family not supported'
},
{
errno: 8,
code: 'EALREADY',
description: 'connection already in progress'
},
{
errno: 9,
code: 'EBADF',
description: 'bad file descriptor'
},
{
errno: 10,
code: 'EBUSY',
description: 'resource busy or locked'
},
{
errno: 11,
code: 'ECONNABORTED',
description: 'software caused connection abort'
},
{
errno: 12,
code: 'ECONNREFUSED',
description: 'connection refused'
},
{
errno: 13,
code: 'ECONNRESET',
description: 'connection reset by peer'
},
{
errno: 14,
code: 'EDESTADDRREQ',
description: 'destination address required'
},
{
errno: 15,
code: 'EFAULT',
description: 'bad address in system call argument'
},
{
errno: 16,
code: 'EHOSTUNREACH',
description: 'host is unreachable'
},
{
errno: 17,
code: 'EINTR',
description: 'interrupted system call'
},
{
errno: 18,
code: 'EINVAL',
description: 'invalid argument'
},
{
errno: 19,
code: 'EISCONN',
description: 'socket is already connected'
},
{
errno: 20,
code: 'EMFILE',
description: 'too many open files'
},
{
errno: 21,
code: 'EMSGSIZE',
description: 'message too long'
},
{
errno: 22,
code: 'ENETDOWN',
description: 'network is down'
},
{
errno: 23,
code: 'ENETUNREACH',
description: 'network is unreachable'
},
{
errno: 24,
code: 'ENFILE',
description: 'file table overflow'
},
{
errno: 25,
code: 'ENOBUFS',
description: 'no buffer space available'
},
{
errno: 26,
code: 'ENOMEM',
description: 'not enough memory'
},
{
errno: 27,
code: 'ENOTDIR',
description: 'not a directory'
},
{
errno: 28,
code: 'EISDIR',
description: 'illegal operation on a directory'
},
{
errno: 29,
code: 'ENONET',
description: 'machine is not on the network'
},
{
errno: 31,
code: 'ENOTCONN',
description: 'socket is not connected'
},
{
errno: 32,
code: 'ENOTSOCK',
description: 'socket operation on non-socket'
},
{
errno: 33,
code: 'ENOTSUP',
description: 'operation not supported on socket'
},
{
errno: 34,
code: 'ENOENT',
description: 'no such file or directory'
},
{
errno: 35,
code: 'ENOSYS',
description: 'function not implemented'
},
{
errno: 36,
code: 'EPIPE',
description: 'broken pipe'
},
{
errno: 37,
code: 'EPROTO',
description: 'protocol error'
},
{
errno: 38,
code: 'EPROTONOSUPPORT',
description: 'protocol not supported'
},
{
errno: 39,
code: 'EPROTOTYPE',
description: 'protocol wrong type for socket'
},
{
errno: 40,
code: 'ETIMEDOUT',
description: 'connection timed out'
},
{
errno: 41,
code: 'ECHARSET',
description: 'invalid Unicode character'
},
{
errno: 42,
code: 'EAIFAMNOSUPPORT',
description: 'address family for hostname not supported'
},
{
errno: 44,
code: 'EAISERVICE',
description: 'servname not supported for ai_socktype'
},
{
errno: 45,
code: 'EAISOCKTYPE',
description: 'ai_socktype not supported'
},
{
errno: 46,
code: 'ESHUTDOWN',
description: 'cannot send after transport endpoint shutdown'
},
{
errno: 47,
code: 'EEXIST',
description: 'file already exists'
},
{
errno: 48,
code: 'ESRCH',
description: 'no such process'
},
{
errno: 49,
code: 'ENAMETOOLONG',
description: 'name too long'
},
{
errno: 50,
code: 'EPERM',
description: 'operation not permitted'
},
{
errno: 51,
code: 'ELOOP',
description: 'too many symbolic links encountered'
},
{
errno: 52,
code: 'EXDEV',
description: 'cross-device link not permitted'
},
{
errno: 53,
code: 'ENOTEMPTY',
description: 'directory not empty'
},
{
errno: 54,
code: 'ENOSPC',
description: 'no space left on device'
},
{
errno: 55,
code: 'EIO',
description: 'i/o error'
},
{
errno: 56,
code: 'EROFS',
description: 'read-only file system'
},
{
errno: 57,
code: 'ENODEV',
description: 'no such device'
},
{
errno: 58,
code: 'ESPIPE',
description: 'invalid seek'
},
{
errno: 59,
code: 'ECANCELED',
description: 'operation canceled'
}
]
module.exports.errno = {}
module.exports.code = {}
all.forEach(function (error) {
module.exports.errno[error.errno] = error
module.exports.code[error.code] = error
})
module.exports.custom = require('./custom')(module.exports)
module.exports.create = module.exports.custom.createError

96
node_modules/errno/package.json generated vendored Normal file
View File

@ -0,0 +1,96 @@
{
"_args": [
[
"errno@~0.1.7",
"/mnt/c/Users/Josua/Desktop/data/nodejs/electron/chat-project/chat-client/node_modules/worker-farm"
]
],
"_from": "errno@>=0.1.7 <0.2.0",
"_id": "errno@0.1.7",
"_inCache": true,
"_installable": true,
"_location": "/errno",
"_nodeVersion": "9.4.0",
"_npmOperationalInternal": {
"host": "s3://npm-registry-packages",
"tmp": "tmp/errno_0.1.7_1518663517573_0.2402603718742864"
},
"_npmUser": {
"email": "ralphtheninja@riseup.net",
"name": "ralphtheninja"
},
"_npmVersion": "5.6.0",
"_phantomChildren": {},
"_requested": {
"name": "errno",
"raw": "errno@~0.1.7",
"rawSpec": "~0.1.7",
"scope": null,
"spec": ">=0.1.7 <0.2.0",
"type": "range"
},
"_requiredBy": [
"/worker-farm"
],
"_resolved": "https://registry.npmjs.org/errno/-/errno-0.1.7.tgz",
"_shasum": "4684d71779ad39af177e3f007996f7c67c852618",
"_shrinkwrap": null,
"_spec": "errno@~0.1.7",
"_where": "/mnt/c/Users/Josua/Desktop/data/nodejs/electron/chat-project/chat-client/node_modules/worker-farm",
"authors": [
"Rod Vagg @rvagg <rod@vagg.org> (https://github.com/rvagg)"
],
"bin": {
"errno": "./cli.js"
},
"bugs": {
"url": "https://github.com/rvagg/node-errno/issues"
},
"dependencies": {
"prr": "~1.0.1"
},
"description": "libuv errno details exposed",
"devDependencies": {
"error-stack-parser": "^2.0.1",
"inherits": "^2.0.3",
"tape": "~4.8.0"
},
"directories": {},
"dist": {
"fileCount": 9,
"integrity": "sha512-MfrRBDWzIWifgq6tJj60gkAwtLNb6sQPlcFrSOflcP1aFmmruKQ2wRnze/8V6kgyz7H3FF8Npzv78mZ7XLLflg==",
"shasum": "4684d71779ad39af177e3f007996f7c67c852618",
"tarball": "https://registry.npmjs.org/errno/-/errno-0.1.7.tgz",
"unpackedSize": 18048
},
"gitHead": "ffb10fcb9459bcef9dcf5cb5f4fa6c68bbab8f4e",
"homepage": "https://github.com/rvagg/node-errno#readme",
"keywords": [
"errno",
"errors",
"libuv"
],
"license": "MIT",
"main": "errno.js",
"maintainers": [
{
"name": "ralphtheninja",
"email": "ralphtheninja@riseup.net"
},
{
"name": "rvagg",
"email": "r@va.gg"
}
],
"name": "errno",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git+https://github.com/rvagg/node-errno.git"
},
"scripts": {
"test": "node --use_strict test.js"
},
"version": "0.1.7"
}

88
node_modules/errno/test.js generated vendored Normal file
View File

@ -0,0 +1,88 @@
var test = require('tape')
, inherits = require('inherits')
, ErrorStackParser = require('error-stack-parser')
, errno = require('./')
test('sanity checks', function (t) {
t.ok(errno.all, 'errno.all not found')
t.ok(errno.errno, 'errno.errno not found')
t.ok(errno.code, 'errno.code not found')
t.equal(errno.all.length, 60, 'found ' + errno.all.length + ', expected 60')
t.equal(errno.errno['-1'], errno.all[1], 'errno -1 not second element')
t.equal(errno.code['UNKNOWN'], errno.all[1], 'code UNKNOWN not second element')
t.equal(errno.errno[1], errno.all[3], 'errno 1 not fourth element')
t.equal(errno.code['EOF'], errno.all[3], 'code EOF not fourth element')
t.end()
})
test('custom errors', function (t) {
const Cust = errno.create('FooNotBarError')
const cust = new Cust('foo is not bar')
t.equal(cust.name, 'FooNotBarError', 'correct custom name')
t.equal(cust.type, 'FooNotBarError', 'correct custom type')
t.equal(cust.message, 'foo is not bar', 'correct custom message')
t.notOk(cust.cause, 'no cause')
t.end()
})
test('callstack', function (t) {
const MyError = errno.create('MyError')
function lastFunction (ErrorType, cb) {
process.nextTick(cb, new ErrorType('oh noes!'))
}
function secondLastFunction (ErrorType, cb) {
lastFunction(ErrorType, cb)
}
function testFrames (t) {
return function (err) {
const stack = ErrorStackParser.parse(err)
t.same(stack[0].functionName, 'lastFunction', 'last stack frame ok')
t.same(stack[1].functionName, 'secondLastFunction', 'second last stack frame ok')
t.end()
}
}
t.test('custom error, default prototype', function (t) {
secondLastFunction(MyError, testFrames(t))
})
t.test('custom error, custom prototype', function (t) {
const MyError2 = errno.create('MyError2', MyError)
secondLastFunction(MyError2, testFrames(t))
})
t.test('custom error, using inheritance', function (t) {
const CustomError = errno.custom.CustomError
function MyError3 (message, cause) {
CustomError.call(this, message, cause)
}
inherits(MyError3, CustomError)
secondLastFunction(MyError3, testFrames(t))
})
})
test('error without message', function (t) {
const Cust = errno.create('WriteError')
const cust = new Cust({
code: 22,
message: '',
name: 'QuotaExceededError'
})
t.equal(cust.name, 'WriteError', 'correct custom name')
t.equal(cust.type, 'WriteError', 'correct custom type')
t.equal(cust.message, 'QuotaExceededError', 'message is the name')
t.notOk(cust.cause, 'no cause')
t.end()
})

61
node_modules/prr/.jshintrc generated vendored Normal file
View File

@ -0,0 +1,61 @@
{
"predef": [ ]
, "bitwise": false
, "camelcase": false
, "curly": false
, "eqeqeq": false
, "forin": false
, "immed": false
, "latedef": false
, "newcap": true
, "noarg": true
, "noempty": true
, "nonew": true
, "plusplus": false
, "quotmark": true
, "regexp": false
, "undef": true
, "unused": true
, "strict": false
, "trailing": true
, "maxlen": 120
, "asi": true
, "boss": true
, "debug": true
, "eqnull": true
, "es5": true
, "esnext": true
, "evil": true
, "expr": true
, "funcscope": false
, "globalstrict": false
, "iterator": false
, "lastsemic": true
, "laxbreak": true
, "laxcomma": true
, "loopfunc": true
, "multistr": false
, "onecase": false
, "proto": false
, "regexdash": false
, "scripturl": true
, "smarttabs": false
, "shadow": false
, "sub": true
, "supernew": false
, "validthis": true
, "browser": true
, "couch": false
, "devel": false
, "dojo": false
, "mootools": false
, "node": true
, "nonstandard": true
, "prototypejs": false
, "rhino": false
, "worker": true
, "wsh": false
, "nomen": false
, "onevar": true
, "passfail": false
}

1
node_modules/prr/.npmignore generated vendored Normal file
View File

@ -0,0 +1 @@
node_modules

10
node_modules/prr/.travis.yml generated vendored Normal file
View File

@ -0,0 +1,10 @@
language: node_js
node_js:
- 0.8
- "0.10"
branches:
only:
- master
notifications:
email:
- rod@vagg.org

11
node_modules/prr/LICENSE.md generated vendored Normal file
View File

@ -0,0 +1,11 @@
The MIT License (MIT)
=====================
Copyright (c) 2014 Rod Vagg
---------------------------
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.

47
node_modules/prr/README.md generated vendored Normal file
View File

@ -0,0 +1,47 @@
# prr [![Build Status](https://secure.travis-ci.org/rvagg/prr.png)](http://travis-ci.org/rvagg/prr)
An sensible alternative to `Object.defineProperty()`. Available in npm and Ender as **prr**.
## Usage
Set the property `'foo'` (`obj.foo`) to have the value `'bar'` with default options (`'enumerable'`, `'configurable'` and `'writable'` are all `false`):
```js
prr(obj, 'foo', 'bar')
```
Adjust the default options:
```js
prr(obj, 'foo', 'bar', { enumerable: true, writable: true })
```
Do the same operation for multiple properties:
```js
prr(obj, { one: 'one', two: 'two' })
// or with options:
prr(obj, { one: 'one', two: 'two' }, { enumerable: true, writable: true })
```
### Simplify!
But obviously, having to write out the full options object makes it nearly as bad as the original `Object.defineProperty()` so we can simplify.
As an alternative method we can use an options string where each character represents a option: `'e'=='enumerable'`, `'c'=='configurable'` and `'w'=='writable'`:
```js
prr(obj, 'foo', 'bar', 'ew') // enumerable and writable but not configurable
// muliple properties:
prr(obj, { one: 'one', two: 'two' }, 'ewc') // configurable too
```
## Where can I use it?
Anywhere! For pre-ES5 environments *prr* will simply fall-back to an `object[property] = value` so you can get close to what you want.
*prr* is Ender-compatible so you can include it in your Ender build and `$.prr(...)` or `var prr = require('prr'); prr(...)`.
## Licence
prr is Copyright (c) 2013 Rod Vagg [@rvagg](https://twitter.com/rvagg) and licensed under the MIT licence. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE.md file for more details.

80
node_modules/prr/package.json generated vendored Normal file
View File

@ -0,0 +1,80 @@
{
"_args": [
[
"prr@~1.0.1",
"/mnt/c/Users/Josua/Desktop/data/nodejs/electron/chat-project/chat-client/node_modules/errno"
]
],
"_from": "prr@>=1.0.1 <1.1.0",
"_id": "prr@1.0.1",
"_inCache": true,
"_installable": true,
"_location": "/prr",
"_npmUser": {
"email": "rod@vagg.org",
"name": "rvagg"
},
"_npmVersion": "1.4.14",
"_phantomChildren": {},
"_requested": {
"name": "prr",
"raw": "prr@~1.0.1",
"rawSpec": "~1.0.1",
"scope": null,
"spec": ">=1.0.1 <1.1.0",
"type": "range"
},
"_requiredBy": [
"/errno"
],
"_resolved": "https://registry.npmjs.org/prr/-/prr-1.0.1.tgz",
"_shasum": "d3fc114ba06995a45ec6893f484ceb1d78f5f476",
"_shrinkwrap": null,
"_spec": "prr@~1.0.1",
"_where": "/mnt/c/Users/Josua/Desktop/data/nodejs/electron/chat-project/chat-client/node_modules/errno",
"author": {
"email": "rod@vagg.org",
"name": "Rod Vagg",
"url": "https://github.com/rvagg"
},
"bugs": {
"url": "https://github.com/rvagg/prr/issues"
},
"dependencies": {},
"description": "A better Object.defineProperty()",
"devDependencies": {
"tap": "*"
},
"directories": {},
"dist": {
"shasum": "d3fc114ba06995a45ec6893f484ceb1d78f5f476",
"tarball": "https://registry.npmjs.org/prr/-/prr-1.0.1.tgz"
},
"gitHead": "b69ba0edc7aacbda0c98d550579e452b8597c126",
"homepage": "https://github.com/rvagg/prr",
"keywords": [
"defineProperty",
"ender",
"properties",
"property"
],
"license": "MIT",
"main": "./prr.js",
"maintainers": [
{
"name": "rvagg",
"email": "rod@vagg.org"
}
],
"name": "prr",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git+https://github.com/rvagg/prr.git"
},
"scripts": {
"test": "node ./test.js"
},
"version": "1.0.1"
}

63
node_modules/prr/prr.js generated vendored Normal file
View File

@ -0,0 +1,63 @@
/*!
* prr
* (c) 2013 Rod Vagg <rod@vagg.org>
* https://github.com/rvagg/prr
* License: MIT
*/
(function (name, context, definition) {
if (typeof module != 'undefined' && module.exports)
module.exports = definition()
else
context[name] = definition()
})('prr', this, function() {
var setProperty = typeof Object.defineProperty == 'function'
? function (obj, key, options) {
Object.defineProperty(obj, key, options)
return obj
}
: function (obj, key, options) { // < es5
obj[key] = options.value
return obj
}
, makeOptions = function (value, options) {
var oo = typeof options == 'object'
, os = !oo && typeof options == 'string'
, op = function (p) {
return oo
? !!options[p]
: os
? options.indexOf(p[0]) > -1
: false
}
return {
enumerable : op('enumerable')
, configurable : op('configurable')
, writable : op('writable')
, value : value
}
}
, prr = function (obj, key, value, options) {
var k
options = makeOptions(value, options)
if (typeof key == 'object') {
for (k in key) {
if (Object.hasOwnProperty.call(key, k)) {
options.value = key[k]
setProperty(obj, k, options)
}
}
return obj
}
return setProperty(obj, key, options)
}
return prr
})

169
node_modules/prr/test.js generated vendored Normal file
View File

@ -0,0 +1,169 @@
const test = require('tap').test
, prr = require('./')
test('test prr(o, key, value) form', function (t) {
t.plan(2)
var o = {}
prr(o, 'foo', 'bar')
t.equal(o.foo, 'bar', 'correct value')
t.deepEqual(
Object.getOwnPropertyDescriptor(o, 'foo')
, {
enumerable : false
, configurable : false
, writable : false
, value : 'bar'
}
, 'correct property descriptor'
)
t.end()
})
test('test prr(o, { key: value }) form', function (t) {
t.plan(2)
var o = {}
prr(o, { foo: 'bar' })
t.equal(o.foo, 'bar', 'correct value')
t.deepEqual(
Object.getOwnPropertyDescriptor(o, 'foo')
, {
enumerable : false
, configurable : false
, writable : false
, value : 'bar'
}
, 'correct property descriptor'
)
t.end()
})
test('test multiple key:value pairs', function (t) {
var o = { foo: 'bar' }
prr(o, { one: 'ONE', two: 'TWO', obj: { o: 'o' }})
t.deepEqual(o, { foo: 'bar' }, 'properties are not enumerable')
t.equal(o.one, 'ONE', 'correctly set property')
t.equal(o.two, 'TWO', 'correctly set property')
t.deepEqual(o.obj, { o: 'o' }, 'correctly set property')
;[ 'one', 'two', 'obj' ].forEach(function (p) {
t.deepEqual(
Object.getOwnPropertyDescriptor(o, p)
, {
enumerable : false
, configurable : false
, writable : false
, value : p == 'obj' ? { o: 'o' } : p.toUpperCase()
}
, 'correct property descriptor'
)
})
t.end()
})
test('test descriptor options', function (t) {
var o = {}
prr(o, 'foo', 'bar', {
enumerable : true
, configurable : false
})
t.equal(o.foo, 'bar', 'correct value')
t.deepEqual(
Object.getOwnPropertyDescriptor(o, 'foo')
, {
enumerable : true
, configurable : false
, writable : false
, value : 'bar'
}
, 'correct property descriptor'
)
prr(o, 'foo2', 'bar2', {
enumerable : true
, configurable : true
, writable : false
})
t.equal(o.foo2, 'bar2', 'correct value')
t.deepEqual(
Object.getOwnPropertyDescriptor(o, 'foo2')
, {
enumerable : true
, configurable : true
, writable : false
, value : 'bar2'
}
, 'correct property descriptor'
)
prr(o, 'foo3', 'bar3', {
enumerable : true
, configurable : true
, writable : true
})
t.equal(o.foo3, 'bar3', 'correct value')
t.deepEqual(
Object.getOwnPropertyDescriptor(o, 'foo3')
, {
enumerable : true
, configurable : true
, writable : true
, value : 'bar3'
}
, 'correct property descriptor'
)
t.end()
})
test('test descriptor options, string form', function (t) {
var o = {}
prr(o, 'foo', 'bar', 'e')
t.equal(o.foo, 'bar', 'correct value')
t.deepEqual(
Object.getOwnPropertyDescriptor(o, 'foo')
, {
enumerable : true
, configurable : false
, writable : false
, value : 'bar'
}
, 'correct property descriptor'
)
prr(o, 'foo2', 'bar2', 'ec')
t.equal(o.foo2, 'bar2', 'correct value')
t.deepEqual(
Object.getOwnPropertyDescriptor(o, 'foo2')
, {
enumerable : true
, configurable : true
, writable : false
, value : 'bar2'
}
, 'correct property descriptor'
)
prr(o, 'foo3', 'bar3', 'ecw')
t.equal(o.foo3, 'bar3', 'correct value')
t.deepEqual(
Object.getOwnPropertyDescriptor(o, 'foo3')
, {
enumerable : true
, configurable : true
, writable : true
, value : 'bar3'
}
, 'correct property descriptor'
)
t.end()
})

16
node_modules/worker-farm/.editorconfig generated vendored Normal file
View File

@ -0,0 +1,16 @@
# This file is for unifying the coding style for different editors and IDEs
# editorconfig.org
root = true
[*]
end_of_line = lf
charset = utf-8
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 2
[*.js]
max_line_length = 80
View

12
node_modules/worker-farm/.travis.yml generated vendored Normal file
View File

@ -0,0 +1,12 @@
language: node_js
node_js:
- 4
- 6
- 8
- 9
branches:
only:
- master
notifications:
email:
- rod@vagg.org

13
node_modules/worker-farm/LICENSE.md generated vendored Normal file
View File

@ -0,0 +1,13 @@
The MIT License (MIT)
=====================
Copyright (c) 2014 LevelUP contributors
---------------------------------------
*LevelUP contributors listed at <https://github.com/rvagg/node-levelup#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.

147
node_modules/worker-farm/README.md generated vendored Normal file
View File

@ -0,0 +1,147 @@
# Worker Farm [![Build Status](https://secure.travis-ci.org/rvagg/node-worker-farm.png)](http://travis-ci.org/rvagg/node-worker-farm)
[![NPM](https://nodei.co/npm/worker-farm.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/worker-farm/) [![NPM](https://nodei.co/npm-dl/worker-farm.png?months=6&height=3)](https://nodei.co/npm/worker-farm/)
Distribute processing tasks to child processes with an über-simple API and baked-in durability & custom concurrency options. *Available in npm as <strong>worker-farm</strong>*.
## Example
Given a file, *child.js*:
```js
module.exports = function (inp, callback) {
callback(null, inp + ' BAR (' + process.pid + ')')
}
```
And a main file:
```js
var workerFarm = require('worker-farm')
, workers = workerFarm(require.resolve('./child'))
, ret = 0
for (var i = 0; i < 10; i++) {
workers('#' + i + ' FOO', function (err, outp) {
console.log(outp)
if (++ret == 10)
workerFarm.end(workers)
})
}
```
We'll get an output something like the following:
```
#1 FOO BAR (8546)
#0 FOO BAR (8545)
#8 FOO BAR (8545)
#9 FOO BAR (8546)
#2 FOO BAR (8548)
#4 FOO BAR (8551)
#3 FOO BAR (8549)
#6 FOO BAR (8555)
#5 FOO BAR (8553)
#7 FOO BAR (8557)
```
This example is contained in the *[examples/basic](https://github.com/rvagg/node-worker-farm/tree/master/examples/basic/)* directory.
### Example #1: Estimating π using child workers
You will also find a more complex example in *[examples/pi](https://github.com/rvagg/node-worker-farm/tree/master/examples/pi/)* that estimates the value of **π** by using a Monte Carlo *area-under-the-curve* method and compares the speed of doing it all in-process vs using child workers to complete separate portions.
Running `node examples/pi` will give you something like:
```
Doing it the slow (single-process) way...
π ≈ 3.1416269360000006 (0.0000342824102075312 away from actual!)
took 8341 milliseconds
Doing it the fast (multi-process) way...
π ≈ 3.1416233600000036 (0.00003070641021052367 away from actual!)
took 1985 milliseconds
```
## Durability
An important feature of Worker Farm is **call durability**. If a child process dies for any reason during the execution of call(s), those calls will be re-queued and taken care of by other child processes. In this way, when you ask for something to be done, unless there is something *seriously* wrong with what you're doing, you should get a result on your callback function.
## My use-case
There are other libraries for managing worker processes available but my use-case was fairly specific: I need to make heavy use of the [node-java](https://github.com/nearinfinity/node-java) library to interact with JVM code. Unfortunately, because the JVM garbage collector is so difficult to interact with, it's prone to killing your Node process when the GC kicks under heavy load. For safety I needed a durable way to make calls so that (1) it wouldn't kill my main process and (2) any calls that weren't successful would be resubmitted for processing.
Worker Farm allows me to spin up multiple JVMs to be controlled by Node, and have a single, uncomplicated API that acts the same way as an in-process API and the calls will be taken care of by a child process even if an error kills a child process while it is working as the call will simply be passed to a new child process.
**But**, don't think that Worker Farm is specific to that use-case, it's designed to be very generic and simple to adapt to anything requiring the use of child Node processes.
## API
Worker Farm exports a main function and an `end()` method. The main function sets up a "farm" of coordinated child-process workers and it can be used to instantiate multiple farms, all operating independently.
### workerFarm([options, ]pathToModule[, exportedMethods])
In its most basic form, you call `workerFarm()` with the path to a module file to be invoked by the child process. You should use an **absolute path** to the module file, the best way to obtain the path is with `require.resolve('./path/to/module')`, this function can be used in exactly the same way as `require('./path/to/module')` but it returns an absolute path.
#### `exportedMethods`
If your module exports a single function on `module.exports` then you should omit the final parameter. However, if you are exporting multiple functions on `module.exports` then you should list them in an Array of Strings:
```js
var workers = workerFarm(require.resolve('./mod'), [ 'doSomething', 'doSomethingElse' ])
workers.doSomething(function () {})
workers.doSomethingElse(function () {})
```
Listing the available methods will instruct Worker Farm what API to provide you with on the returned object. If you don't list a `exportedMethods` Array then you'll get a single callable function to use; but if you list the available methods then you'll get an object with callable functions by those names.
**It is assumed that each function you call on your child module will take a `callback` function as the last argument.**
#### `options`
If you don't provide an `options` object then the following defaults will be used:
```js
{
workerOptions : {}
, maxCallsPerWorker : Infinity
, maxConcurrentWorkers : require('os').cpus().length
, maxConcurrentCallsPerWorker : 10
, maxConcurrentCalls : Infinity
, maxCallTime : Infinity
, maxRetries : Infinity
, autoStart : false
}
```
* **<code>workerOptions</code>** allows you to customize all the parameters passed to child nodes. This object supports [all possible options of `child_process.fork`](https://nodejs.org/api/child_process.html#child_process_child_process_fork_modulepath_args_options). The default options passed are the parent `execArgv`, `cwd` and `env`. Any (or all) of them can be overridden, and others can be added as well.
* **<code>maxCallsPerWorker</code>** allows you to control the lifespan of your child processes. A positive number will indicate that you only want each child to accept that many calls before it is terminated. This may be useful if you need to control memory leaks or similar in child processes.
* **<code>maxConcurrentWorkers</code>** will set the number of child processes to maintain concurrently. By default it is set to the number of CPUs available on the current system, but it can be any reasonable number, including `1`.
* **<code>maxConcurrentCallsPerWorker</code>** allows you to control the *concurrency* of individual child processes. Calls are placed into a queue and farmed out to child processes according to the number of calls they are allowed to handle concurrently. It is arbitrarily set to 10 by default so that calls are shared relatively evenly across workers, however if your calls predictably take a similar amount of time then you could set it to `Infinity` and Worker Farm won't queue any calls but spread them evenly across child processes and let them go at it. If your calls aren't I/O bound then it won't matter what value you use here as the individual workers won't be able to execute more than a single call at a time.
* **<code>maxConcurrentCalls</code>** allows you to control the maximum number of calls in the queue&mdash;either actively being processed or waiting for a worker to be processed. `Infinity` indicates no limit but if you have conditions that may endlessly queue jobs and you need to set a limit then provide a `>0` value and any calls that push the limit will return on their callback with a `MaxConcurrentCallsError` error (check `err.type == 'MaxConcurrentCallsError'`).
* **<code>maxCallTime</code>** *(use with caution, understand what this does before you use it!)* when `!== Infinity`, will cap a time, in milliseconds, that *any single call* can take to execute in a worker. If this time limit is exceeded by just a single call then the worker running that call will be killed and any calls running on that worker will have their callbacks returned with a `TimeoutError` (check `err.type == 'TimeoutError'`). If you are running with `maxConcurrentCallsPerWorker` value greater than `1` then **all calls currently executing** will fail and will be automatically resubmitted uless you've changed the `maxRetries` option. Use this if you have jobs that may potentially end in infinite loops that you can't programatically end with your child code. Preferably run this with a `maxConcurrentCallsPerWorker` so you don't interrupt other calls when you have a timeout. This timeout operates on a per-call basis but will interrupt a whole worker.
* **<code>maxRetries</code>** allows you to control the max number of call requeues after worker termination (unexpected or timeout). By default this option is set to `Infinity` which means that each call of each terminated worker will always be auto requeued. When the number of retries exceeds `maxRetries` value, the job callback will be executed with a `ProcessTerminatedError`. Note that if you are running with finite `maxCallTime` and `maxConcurrentCallsPerWorkers` greater than `1` then any `TimeoutError` will increase the retries counter *for each* concurrent call of the terminated worker.
* **<code>autoStart</code>** when set to `true` will start the workers as early as possible. Use this when your workers have to do expensive initialization. That way they'll be ready when the first request comes through.
### workerFarm.end(farm)
Child processes stay alive waiting for jobs indefinitely and your farm manager will stay alive managing its workers, so if you need it to stop then you have to do so explicitly. If you send your farm API to `workerFarm.end()` then it'll cleanly end your worker processes. Note though that it's a *soft* ending so it'll wait for child processes to finish what they are working on before asking them to die.
Any calls that are queued and not yet being handled by a child process will be discarded. `end()` only waits for those currently in progress.
Once you end a farm, it won't handle any more calls, so don't even try!
## Related
* [farm-cli](https://github.com/Kikobeats/farm-cli) Launch a farm of workers from CLI.
## License
Worker Farm is Copyright (c) 2014 Rod Vagg [@rvagg](https://twitter.com/rvagg) and licensed under the MIT license. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE.md file for more details.

5
node_modules/worker-farm/examples/basic/child.js generated vendored Normal file
View File

@ -0,0 +1,5 @@
'use strict'
module.exports = function (inp, callback) {
callback(null, inp + ' BAR (' + process.pid + ')')
}

13
node_modules/worker-farm/examples/basic/index.js generated vendored Normal file
View File

@ -0,0 +1,13 @@
'use strict'
let workerFarm = require('../../')
, workers = workerFarm(require.resolve('./child'))
, ret = 0
for (let i = 0; i < 10; i++) {
workers('#' + i + ' FOO', function (err, outp) {
console.log(outp)
if (++ret == 10)
workerFarm.end(workers)
})
}

22
node_modules/worker-farm/examples/pi/calc.js generated vendored Normal file
View File

@ -0,0 +1,22 @@
'use strict'
/* A simple π estimation function using a Monte Carlo method
* For 0 to `points`, take 2 random numbers < 1, square and add them to
* find the area under that point in a 1x1 square. If that area is <= 1
* then it's *within* a quarter-circle, otherwise it's outside.
* Take the number of points <= 1 and multiply it by 4 and you have an
* estimate!
* Do this across multiple processes and average the results to
* increase accuracy.
*/
module.exports = function (points, callback) {
let inside = 0
, i = points
while (i--)
if (Math.pow(Math.random(), 2) + Math.pow(Math.random(), 2) <= 1)
inside++
callback(null, (inside / points) * 4)
}

41
node_modules/worker-farm/examples/pi/index.js generated vendored Normal file
View File

@ -0,0 +1,41 @@
'use strict'
const CHILDREN = 500
, POINTS_PER_CHILD = 1000000
, FARM_OPTIONS = {
maxConcurrentWorkers : require('os').cpus().length
, maxCallsPerWorker : Infinity
, maxConcurrentCallsPerWorker : 1
}
let workerFarm = require('../../')
, calcDirect = require('./calc')
, calcWorker = workerFarm(FARM_OPTIONS, require.resolve('./calc'))
, ret
, start
, tally = function (finish, err, avg) {
ret.push(avg)
if (ret.length == CHILDREN) {
let pi = ret.reduce(function (a, b) { return a + b }) / ret.length
, end = +new Date()
console.log('π ≈', pi, '\t(' + Math.abs(pi - Math.PI), 'away from actual!)')
console.log('took', end - start, 'milliseconds')
if (finish)
finish()
}
}
, calc = function (method, callback) {
ret = []
start = +new Date()
for (let i = 0; i < CHILDREN; i++)
method(POINTS_PER_CHILD, tally.bind(null, callback))
}
console.log('Doing it the slow (single-process) way...')
calc(calcDirect, function () {
console.log('Doing it the fast (multi-process) way...')
calc(calcWorker, process.exit)
})

44
node_modules/worker-farm/index.d.ts generated vendored Normal file
View File

@ -0,0 +1,44 @@
interface Workers {
(callback: WorkerCallback): void;
(arg1: any, callback: WorkerCallback): void;
(arg1: any, arg2: any, callback: WorkerCallback): void;
(arg1: any, arg2: any, arg3: any, callback: WorkerCallback): void;
(arg1: any, arg2: any, arg3: any, arg4: any, callback: WorkerCallback): void;
}
type WorkerCallback =
| WorkerCallback0
| WorkerCallback1
| WorkerCallback2
| WorkerCallback3
| WorkerCallback4;
type WorkerCallback0 = () => void;
type WorkerCallback1 = (arg1: any) => void;
type WorkerCallback2 = (arg1: any, arg2: any) => void;
type WorkerCallback3 = (arg1: any, arg2: any, arg3: any) => void;
type WorkerCallback4 = (arg1: any, arg2: any, arg3: any, arg4: any) => void;
interface FarmOptions {
maxCallsPerWorker?: number
maxConcurrentWorkers?: number
maxConcurrentCallsPerWorker?: number
maxConcurrentCalls?: number
maxCallTime?: number
maxRetries?: number
autoStart?: boolean
}
interface WorkerFarm {
(name: string): Workers;
(name: string, exportedMethods: string[]): Workers;
(options: FarmOptions, name: string): Workers;
(options: FarmOptions, name: string, exportedMethods: string[]): Workers;
end: (workers: Workers) => void;
}
declare module "worker-farm" {
const workerFarm: WorkerFarm;
export = workerFarm;
}

52
node_modules/worker-farm/lib/child/index.js generated vendored Normal file
View File

@ -0,0 +1,52 @@
'use strict'
let $module
/*
let contextProto = this.context;
while (contextProto = Object.getPrototypeOf(contextProto)) {
completionGroups.push(Object.getOwnPropertyNames(contextProto));
}
*/
function handle (data) {
let idx = data.idx
, child = data.child
, method = data.method
, args = data.args
, callback = function () {
let _args = Array.prototype.slice.call(arguments)
if (_args[0] instanceof Error) {
let e = _args[0]
_args[0] = {
'$error' : '$error'
, 'type' : e.constructor.name
, 'message' : e.message
, 'stack' : e.stack
}
Object.keys(e).forEach(function(key) {
_args[0][key] = e[key]
})
}
process.send({ idx: idx, child: child, args: _args })
}
, exec
if (method == null && typeof $module == 'function')
exec = $module
else if (typeof $module[method] == 'function')
exec = $module[method]
if (!exec)
return console.error('NO SUCH METHOD:', method)
exec.apply(null, args.concat([ callback ]))
}
process.on('message', function (data) {
if (!$module) return $module = require(data.module)
if (data == 'die') return process.exit(0)
handle(data)
})

339
node_modules/worker-farm/lib/farm.js generated vendored Normal file
View File

@ -0,0 +1,339 @@
'use strict'
const DEFAULT_OPTIONS = {
workerOptions : {}
, maxCallsPerWorker : Infinity
, maxConcurrentWorkers : (require('os').cpus() || { length: 1 }).length
, maxConcurrentCallsPerWorker : 10
, maxConcurrentCalls : Infinity
, maxCallTime : Infinity // exceed this and the whole worker is terminated
, maxRetries : Infinity
, forcedKillTime : 100
, autoStart : false
}
const fork = require('./fork')
, TimeoutError = require('errno').create('TimeoutError')
, ProcessTerminatedError = require('errno').create('ProcessTerminatedError')
, MaxConcurrentCallsError = require('errno').create('MaxConcurrentCallsError')
function Farm (options, path) {
this.options = Object.assign({}, DEFAULT_OPTIONS, options)
this.path = path
this.activeCalls = 0
}
// make a handle to pass back in the form of an external API
Farm.prototype.mkhandle = function (method) {
return function () {
let args = Array.prototype.slice.call(arguments)
if (this.activeCalls >= this.options.maxConcurrentCalls) {
let err = new MaxConcurrentCallsError('Too many concurrent calls (' + this.activeCalls + ')')
if (typeof args[args.length - 1] == 'function')
return process.nextTick(args[args.length - 1].bind(null, err))
throw err
}
this.addCall({
method : method
, callback : args.pop()
, args : args
, retries : 0
})
}.bind(this)
}
// a constructor of sorts
Farm.prototype.setup = function (methods) {
let iface
if (!methods) { // single-function export
iface = this.mkhandle()
} else { // multiple functions on the export
iface = {}
methods.forEach(function (m) {
iface[m] = this.mkhandle(m)
}.bind(this))
}
this.searchStart = -1
this.childId = -1
this.children = {}
this.activeChildren = 0
this.callQueue = []
if (this.options.autoStart) {
while (this.activeChildren < this.options.maxConcurrentWorkers)
this.startChild()
}
return iface
}
// when a child exits, check if there are any outstanding jobs and requeue them
Farm.prototype.onExit = function (childId) {
// delay this to give any sends a chance to finish
setTimeout(function () {
let doQueue = false
if (this.children[childId] && this.children[childId].activeCalls) {
this.children[childId].calls.forEach(function (call, i) {
if (!call) return
else if (call.retries >= this.options.maxRetries) {
this.receive({
idx : i
, child : childId
, args : [ new ProcessTerminatedError('cancel after ' + call.retries + ' retries!') ]
})
} else {
call.retries++
this.callQueue.unshift(call)
doQueue = true
}
}.bind(this))
}
this.stopChild(childId)
doQueue && this.processQueue()
}.bind(this), 10)
}
// start a new worker
Farm.prototype.startChild = function () {
this.childId++
let forked = fork(this.path, this.options.workerOptions)
, id = this.childId
, c = {
send : forked.send
, child : forked.child
, calls : []
, activeCalls : 0
, exitCode : null
}
forked.child.on('message', this.receive.bind(this))
forked.child.once('exit', function (code) {
c.exitCode = code
this.onExit(id)
}.bind(this))
this.activeChildren++
this.children[id] = c
}
// stop a worker, identified by id
Farm.prototype.stopChild = function (childId) {
let child = this.children[childId]
if (child) {
child.send('die')
setTimeout(function () {
if (child.exitCode === null)
child.child.kill('SIGKILL')
}, this.options.forcedKillTime).unref()
;delete this.children[childId]
this.activeChildren--
}
}
// called from a child process, the data contains information needed to
// look up the child and the original call so we can invoke the callback
Farm.prototype.receive = function (data) {
let idx = data.idx
, childId = data.child
, args = data.args
, child = this.children[childId]
, call
if (!child) {
return console.error(
'Worker Farm: Received message for unknown child. '
+ 'This is likely as a result of premature child death, '
+ 'the operation will have been re-queued.'
)
}
call = child.calls[idx]
if (!call) {
return console.error(
'Worker Farm: Received message for unknown index for existing child. '
+ 'This should not happen!'
)
}
if (this.options.maxCallTime !== Infinity)
clearTimeout(call.timer)
if (args[0] && args[0].$error == '$error') {
let e = args[0]
switch (e.type) {
case 'TypeError': args[0] = new TypeError(e.message); break
case 'RangeError': args[0] = new RangeError(e.message); break
case 'EvalError': args[0] = new EvalError(e.message); break
case 'ReferenceError': args[0] = new ReferenceError(e.message); break
case 'SyntaxError': args[0] = new SyntaxError(e.message); break
case 'URIError': args[0] = new URIError(e.message); break
default: args[0] = new Error(e.message)
}
args[0].type = e.type
args[0].stack = e.stack
// Copy any custom properties to pass it on.
Object.keys(e).forEach(function(key) {
args[0][key] = e[key];
});
}
process.nextTick(function () {
call.callback.apply(null, args)
})
;delete child.calls[idx]
child.activeCalls--
this.activeCalls--
if (child.calls.length >= this.options.maxCallsPerWorker
&& !Object.keys(child.calls).length) {
// this child has finished its run, kill it
this.stopChild(childId)
}
// allow any outstanding calls to be processed
this.processQueue()
}
Farm.prototype.childTimeout = function (childId) {
let child = this.children[childId]
, i
if (!child)
return
for (i in child.calls) {
this.receive({
idx : i
, child : childId
, args : [ new TimeoutError('worker call timed out!') ]
})
}
this.stopChild(childId)
}
// send a call to a worker, identified by id
Farm.prototype.send = function (childId, call) {
let child = this.children[childId]
, idx = child.calls.length
child.calls.push(call)
child.activeCalls++
this.activeCalls++
child.send({
idx : idx
, child : childId
, method : call.method
, args : call.args
})
if (this.options.maxCallTime !== Infinity) {
call.timer =
setTimeout(this.childTimeout.bind(this, childId), this.options.maxCallTime)
}
}
// a list of active worker ids, in order, but the starting offset is
// shifted each time this method is called, so we work our way through
// all workers when handing out jobs
Farm.prototype.childKeys = function () {
let cka = Object.keys(this.children)
, cks
if (this.searchStart >= cka.length - 1)
this.searchStart = 0
else
this.searchStart++
cks = cka.splice(0, this.searchStart)
return cka.concat(cks)
}
// Calls are added to a queue, this processes the queue and is called
// whenever there might be a chance to send more calls to the workers.
// The various options all impact on when we're able to send calls,
// they may need to be kept in a queue until a worker is ready.
Farm.prototype.processQueue = function () {
let cka, i = 0, childId
if (!this.callQueue.length)
return this.ending && this.end()
if (this.activeChildren < this.options.maxConcurrentWorkers)
this.startChild()
for (cka = this.childKeys(); i < cka.length; i++) {
childId = +cka[i]
if (this.children[childId].activeCalls < this.options.maxConcurrentCallsPerWorker
&& this.children[childId].calls.length < this.options.maxCallsPerWorker) {
this.send(childId, this.callQueue.shift())
if (!this.callQueue.length)
return this.ending && this.end()
} /*else {
console.log(
, this.children[childId].activeCalls < this.options.maxConcurrentCallsPerWorker
, this.children[childId].calls.length < this.options.maxCallsPerWorker
, this.children[childId].calls.length , this.options.maxCallsPerWorker)
}*/
}
if (this.ending)
this.end()
}
// add a new call to the call queue, then trigger a process of the queue
Farm.prototype.addCall = function (call) {
if (this.ending)
return this.end() // don't add anything new to the queue
this.callQueue.push(call)
this.processQueue()
}
// kills child workers when they're all done
Farm.prototype.end = function (callback) {
let complete = true
if (this.ending === false)
return
if (callback)
this.ending = callback
else if (this.ending == null)
this.ending = true
Object.keys(this.children).forEach(function (child) {
if (!this.children[child])
return
if (!this.children[child].activeCalls)
this.stopChild(child)
else
complete = false
}.bind(this))
if (complete && typeof this.ending == 'function') {
process.nextTick(function () {
this.ending()
this.ending = false
}.bind(this))
}
}
module.exports = Farm
module.exports.TimeoutError = TimeoutError

33
node_modules/worker-farm/lib/fork.js generated vendored Normal file
View File

@ -0,0 +1,33 @@
'use strict'
const childProcess = require('child_process')
, childModule = require.resolve('./child/index')
function fork (forkModule, workerOptions) {
// suppress --debug / --inspect flags while preserving others (like --harmony)
let filteredArgs = process.execArgv.filter(function (v) {
return !(/^--(debug|inspect)/).test(v)
})
, options = Object.assign({
execArgv : filteredArgs
, env : process.env
, cwd : process.cwd()
}, workerOptions)
, child = childProcess.fork(childModule, process.argv, options)
child.on('error', function() {
// this *should* be picked up by onExit and the operation requeued
})
child.send({ module: forkModule })
// return a send() function for this child
return {
send : child.send.bind(child)
, child : child
}
}
module.exports = fork

34
node_modules/worker-farm/lib/index.js generated vendored Normal file
View File

@ -0,0 +1,34 @@
'use strict'
const Farm = require('./farm')
let farms = [] // keep record of farms so we can end() them if required
function farm (options, path, methods) {
if (typeof options == 'string') {
methods = path
path = options
options = {}
}
let f = new Farm(options, path)
, api = f.setup(methods)
farms.push({ farm: f, api: api })
// return the public API
return api
}
function end (api, callback) {
for (let i = 0; i < farms.length; i++)
if (farms[i] && farms[i].api === api)
return farms[i].farm.end(callback)
process.nextTick(callback.bind(null, 'Worker farm not found!'))
}
module.exports = farm
module.exports.end = end

93
node_modules/worker-farm/package.json generated vendored Normal file
View File

@ -0,0 +1,93 @@
{
"_args": [
[
"worker-farm",
"/mnt/c/Users/Josua/Desktop/data/nodejs/electron/chat-project/chat-client"
]
],
"_from": "worker-farm@latest",
"_id": "worker-farm@1.6.0",
"_inCache": true,
"_installable": true,
"_location": "/worker-farm",
"_nodeVersion": "8.10.0",
"_npmOperationalInternal": {
"host": "s3://npm-registry-packages",
"tmp": "tmp/worker-farm_1.6.0_1520565271783_0.5530085286716173"
},
"_npmUser": {
"email": "r@va.gg",
"name": "rvagg"
},
"_npmVersion": "5.6.0",
"_phantomChildren": {},
"_requested": {
"name": "worker-farm",
"raw": "worker-farm",
"rawSpec": "",
"scope": null,
"spec": "latest",
"type": "tag"
},
"_requiredBy": [
"#USER"
],
"_resolved": "https://registry.npmjs.org/worker-farm/-/worker-farm-1.6.0.tgz",
"_shasum": "aecc405976fab5a95526180846f0dba288f3a4a0",
"_shrinkwrap": null,
"_spec": "worker-farm",
"_where": "/mnt/c/Users/Josua/Desktop/data/nodejs/electron/chat-project/chat-client",
"authors": [
"Rod Vagg @rvagg <rod@vagg.org> (https://github.com/rvagg)"
],
"bugs": {
"url": "https://github.com/rvagg/node-worker-farm/issues"
},
"dependencies": {
"errno": "~0.1.7"
},
"description": "Distribute processing tasks to child processes with an über-simple API and baked-in durability & custom concurrency options.",
"devDependencies": {
"tape": "~4.9.0"
},
"directories": {},
"dist": {
"fileCount": 17,
"integrity": "sha512-6w+3tHbM87WnSWnENBUvA2pxJPLhQUg5LKwUQHq3r+XPhIM+Gh2R5ycbwPCyuGbNg+lPgdcnQUhuC02kJCvffQ==",
"shasum": "aecc405976fab5a95526180846f0dba288f3a4a0",
"tarball": "https://registry.npmjs.org/worker-farm/-/worker-farm-1.6.0.tgz",
"unpackedSize": 47168
},
"gitHead": "f61372e0ad99338d472b8fd09b4900a4cbff5166",
"homepage": "https://github.com/rvagg/node-worker-farm",
"keywords": [
"child",
"farm",
"processing",
"worker"
],
"license": "MIT",
"main": "./lib/index.js",
"maintainers": [
{
"name": "amasad",
"email": "amjad.masad@gmail.com"
},
{
"name": "rvagg",
"email": "rod@vagg.org"
}
],
"name": "worker-farm",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git+https://github.com/rvagg/node-worker-farm.git"
},
"scripts": {
"test": "node ./tests/"
},
"types": "./index.d.ts",
"version": "1.6.0"
}

87
node_modules/worker-farm/tests/child.js generated vendored Normal file
View File

@ -0,0 +1,87 @@
'use strict'
const fs = require('fs')
const started = Date.now()
module.exports = function (timeout, callback) {
callback = callback.bind(null, null, process.pid, Math.random(), timeout)
if (timeout)
return setTimeout(callback, timeout)
callback()
}
module.exports.args = function (callback) {
callback(null, {
argv : process.argv
, cwd : process.cwd()
, execArgv : process.execArgv
})
}
module.exports.run0 = function (callback) {
module.exports(0, callback)
}
module.exports.killable = function (id, callback) {
if (Math.random() < 0.5)
return process.exit(-1)
callback(null, id, process.pid)
}
module.exports.err = function (type, message, data, callback) {
if (typeof data == 'function') {
callback = data
data = null
} else {
let err = new Error(message)
Object.keys(data).forEach(function(key) {
err[key] = data[key]
})
callback(err)
return
}
if (type == 'TypeError')
return callback(new TypeError(message))
callback(new Error(message))
}
module.exports.block = function () {
while (true);
}
// use provided file path to save retries count among terminated workers
module.exports.stubborn = function (path, callback) {
function isOutdated(path) {
return ((new Date).getTime() - fs.statSync(path).mtime.getTime()) > 2000
}
// file may not be properly deleted, check if modified no earler than two seconds ago
if (!fs.existsSync(path) || isOutdated(path)) {
fs.writeFileSync(path, '1')
process.exit(-1)
}
let retry = parseInt(fs.readFileSync(path, 'utf8'))
if (Number.isNaN(retry))
return callback(new Error('file contents is not a number'))
if (retry > 4) {
callback(null, 12)
} else {
fs.writeFileSync(path, String(retry + 1))
process.exit(-1)
}
}
module.exports.uptime = function (callback) {
callback(null, Date.now() - started)
}

12
node_modules/worker-farm/tests/debug.js generated vendored Normal file
View File

@ -0,0 +1,12 @@
'use strict'
const workerFarm = require('../')
, workers = workerFarm(require.resolve('./child'), ['args'])
workers.args(function(err, result) {
console.log(result);
workerFarm.end(workers)
console.log('FINISHED')
process.exit(0)
})

564
node_modules/worker-farm/tests/index.js generated vendored Normal file
View File

@ -0,0 +1,564 @@
'use strict'
const tape = require('tape')
, child_process = require('child_process')
, workerFarm = require('../')
, childPath = require.resolve('./child')
, fs = require('fs')
, os = require('os')
function uniq (ar) {
let a = [], i, j
o: for (i = 0; i < ar.length; ++i) {
for (j = 0; j < a.length; ++j) if (a[j] == ar[i]) continue o
a[a.length] = ar[i]
}
return a
}
// a child where module.exports = function ...
tape('simple, exports=function test', function (t) {
t.plan(4)
let child = workerFarm(childPath)
child(0, function (err, pid, rnd) {
t.ok(pid > process.pid, 'pid makes sense')
t.ok(pid < process.pid + 750, 'pid makes sense')
t.ok(rnd >= 0 && rnd < 1, 'rnd result makes sense')
})
workerFarm.end(child, function () {
t.ok(true, 'workerFarm ended')
})
})
// a child where we have module.exports.fn = function ...
tape('simple, exports.fn test', function (t) {
t.plan(4)
let child = workerFarm(childPath, [ 'run0' ])
child.run0(function (err, pid, rnd) {
t.ok(pid > process.pid, 'pid makes sense')
t.ok(pid < process.pid + 750, 'pid makes sense')
t.ok(rnd >= 0 && rnd < 1, 'rnd result makes sense')
})
workerFarm.end(child, function () {
t.ok(true, 'workerFarm ended')
})
})
// use the returned pids to check that we're using a single child process
// when maxConcurrentWorkers = 1
tape('single worker', function (t) {
t.plan(2)
let child = workerFarm({ maxConcurrentWorkers: 1 }, childPath)
, pids = []
, i = 10
while (i--) {
child(0, function (err, pid) {
pids.push(pid)
if (pids.length == 10) {
t.equal(1, uniq(pids).length, 'only a single process (by pid)')
} else if (pids.length > 10)
t.fail('too many callbacks!')
})
}
workerFarm.end(child, function () {
t.ok(true, 'workerFarm ended')
})
})
// use the returned pids to check that we're using two child processes
// when maxConcurrentWorkers = 2
tape('two workers', function (t) {
t.plan(2)
let child = workerFarm({ maxConcurrentWorkers: 2 }, childPath)
, pids = []
, i = 10
while (i--) {
child(0, function (err, pid) {
pids.push(pid)
if (pids.length == 10) {
t.equal(2, uniq(pids).length, 'only two child processes (by pid)')
} else if (pids.length > 10)
t.fail('too many callbacks!')
})
}
workerFarm.end(child, function () {
t.ok(true, 'workerFarm ended')
})
})
// use the returned pids to check that we're using a child process per
// call when maxConcurrentWorkers = 10
tape('many workers', function (t) {
t.plan(2)
let child = workerFarm({ maxConcurrentWorkers: 10 }, childPath)
, pids = []
, i = 10
while (i--) {
child(1, function (err, pid) {
pids.push(pid)
if (pids.length == 10) {
t.equal(10, uniq(pids).length, 'pids are all the same (by pid)')
} else if (pids.length > 10)
t.fail('too many callbacks!')
})
}
workerFarm.end(child, function () {
t.ok(true, 'workerFarm ended')
})
})
tape('auto start workers', function (t) {
let child = workerFarm({ maxConcurrentWorkers: 3, autoStart: true }, childPath, ['uptime'])
, pids = []
, count = 5
, i = count
, delay = 250
t.plan(count + 1)
setTimeout(function() {
while (i--)
child.uptime(function (err, uptime) {
t.ok(uptime > 10, 'child has been up before the request (' + uptime + 'ms)')
})
workerFarm.end(child, function () {
t.ok(true, 'workerFarm ended')
})
}, delay)
})
// use the returned pids to check that we're using a child process per
// call when we set maxCallsPerWorker = 1 even when we have maxConcurrentWorkers = 1
tape('single call per worker', function (t) {
t.plan(2)
let child = workerFarm({
maxConcurrentWorkers: 1
, maxConcurrentCallsPerWorker: Infinity
, maxCallsPerWorker: 1
, autoStart: true
}, childPath)
, pids = []
, count = 25
, i = count
while (i--) {
child(0, function (err, pid) {
pids.push(pid)
if (pids.length == count) {
t.equal(count, uniq(pids).length, 'one process for each call (by pid)')
workerFarm.end(child, function () {
t.ok(true, 'workerFarm ended')
})
} else if (pids.length > count)
t.fail('too many callbacks!')
})
}
})
// use the returned pids to check that we're using a child process per
// two-calls when we set maxCallsPerWorker = 2 even when we have maxConcurrentWorkers = 1
tape('two calls per worker', function (t) {
t.plan(2)
let child = workerFarm({
maxConcurrentWorkers: 1
, maxConcurrentCallsPerWorker: Infinity
, maxCallsPerWorker: 2
, autoStart: true
}, childPath)
, pids = []
, count = 20
, i = count
while (i--) {
child(0, function (err, pid) {
pids.push(pid)
if (pids.length == count) {
t.equal(count / 2, uniq(pids).length, 'one process for each call (by pid)')
workerFarm.end(child, function () {
t.ok(true, 'workerFarm ended')
})
} else if (pids.length > count)
t.fail('too many callbacks!')
})
}
})
// use timing to confirm that one worker will process calls sequentially
tape('many concurrent calls', function (t) {
t.plan(2)
let child = workerFarm({
maxConcurrentWorkers: 1
, maxConcurrentCallsPerWorker: Infinity
, maxCallsPerWorker: Infinity
, autoStart: true
}, childPath)
, defer = 200
, count = 200
, i = count
, cbc = 0
setTimeout(function () {
let start = Date.now()
while (i--) {
child(defer, function () {
if (++cbc == count) {
let time = Date.now() - start
// upper-limit not tied to `count` at all
t.ok(time > defer && time < (defer * 2.5), 'processed tasks concurrently (' + time + 'ms)')
workerFarm.end(child, function () {
t.ok(true, 'workerFarm ended')
})
} else if (cbc > count)
t.fail('too many callbacks!')
})
}
}, 250)
})
// use timing to confirm that one child processes calls sequentially with
// maxConcurrentCallsPerWorker = 1
tape('single concurrent call', function (t) {
t.plan(2)
let child = workerFarm({
maxConcurrentWorkers: 1
, maxConcurrentCallsPerWorker: 1
, maxCallsPerWorker: Infinity
, autoStart: true
}, childPath)
, defer = 20
, count = 100
, i = count
, cbc = 0
setTimeout(function () {
let start = Date.now()
while (i--) {
child(defer, function () {
if (++cbc == count) {
let time = Date.now() - start
// upper-limit tied closely to `count`, 1.3 is generous but accounts for all the timers
// coming back at the same time and the IPC overhead
t.ok(time > (defer * count) && time < (defer * count * 1.3), 'processed tasks sequentially (' + time + ')')
workerFarm.end(child, function () {
t.ok(true, 'workerFarm ended')
})
} else if (cbc > count)
t.fail('too many callbacks!')
})
}
}, 250)
})
// use timing to confirm that one child processes *only* 5 calls concurrently
tape('multiple concurrent calls', function (t) {
t.plan(2)
let callsPerWorker = 5
, child = workerFarm({
maxConcurrentWorkers: 1
, maxConcurrentCallsPerWorker: callsPerWorker
, maxCallsPerWorker: Infinity
, autoStart: true
}, childPath)
, defer = 100
, count = 100
, i = count
, cbc = 0
setTimeout(function () {
let start = Date.now()
while (i--) {
child(defer, function () {
if (++cbc == count) {
let time = Date.now() - start
// (defer * (count / callsPerWorker + 1)) - if precise it'd be count/callsPerWorker
// but accounting for IPC and other overhead, we need to give it a bit of extra time,
// hence the +1
t.ok(time > (defer * 1.5) && time < (defer * (count / callsPerWorker + 1)), 'processed tasks concurrently (' + time + 'ms)')
workerFarm.end(child, function () {
t.ok(true, 'workerFarm ended')
})
} else if (cbc > count)
t.fail('too many callbacks!')
})
}
}, 250)
})
// call a method that will die with a probability of 0.5 but expect that
// we'll get results for each of our calls anyway
tape('durability', function (t) {
t.plan(3)
let child = workerFarm({ maxConcurrentWorkers: 2 }, childPath, [ 'killable' ])
, ids = []
, pids = []
, count = 20
, i = count
while (i--) {
child.killable(i, function (err, id, pid) {
ids.push(id)
pids.push(pid)
if (ids.length == count) {
t.ok(uniq(pids).length > 2, 'processed by many (' + uniq(pids).length + ') workers, but got there in the end!')
t.ok(uniq(ids).length == count, 'received a single result for each unique call')
workerFarm.end(child, function () {
t.ok(true, 'workerFarm ended')
})
} else if (ids.length > count)
t.fail('too many callbacks!')
})
}
})
// a callback provided to .end() can and will be called (uses "simple, exports=function test" to create a child)
tape('simple, end callback', function (t) {
t.plan(4)
let child = workerFarm(childPath)
child(0, function (err, pid, rnd) {
t.ok(pid > process.pid, 'pid makes sense ' + pid + ' vs ' + process.pid)
t.ok(pid < process.pid + 750, 'pid makes sense ' + pid + ' vs ' + process.pid)
t.ok(rnd >= 0 && rnd < 1, 'rnd result makes sense')
})
workerFarm.end(child, function() {
t.pass('an .end() callback was successfully called')
})
})
tape('call timeout test', function (t) {
t.plan(3 + 3 + 4 + 4 + 4 + 3 + 1)
let child = workerFarm({ maxCallTime: 250, maxConcurrentWorkers: 1 }, childPath)
// should come back ok
child(50, function (err, pid, rnd) {
t.ok(pid > process.pid, 'pid makes sense ' + pid + ' vs ' + process.pid)
t.ok(pid < process.pid + 750, 'pid makes sense ' + pid + ' vs ' + process.pid)
t.ok(rnd > 0 && rnd < 1, 'rnd result makes sense ' + rnd)
})
// should come back ok
child(50, function (err, pid, rnd) {
t.ok(pid > process.pid, 'pid makes sense ' + pid + ' vs ' + process.pid)
t.ok(pid < process.pid + 750, 'pid makes sense ' + pid + ' vs ' + process.pid)
t.ok(rnd > 0 && rnd < 1, 'rnd result makes sense ' + rnd)
})
// should die
child(500, function (err, pid, rnd) {
t.ok(err, 'got an error')
t.equal(err.type, 'TimeoutError', 'correct error type')
t.ok(pid === undefined, 'no pid')
t.ok(rnd === undefined, 'no rnd')
})
// should die
child(1000, function (err, pid, rnd) {
t.ok(err, 'got an error')
t.equal(err.type, 'TimeoutError', 'correct error type')
t.ok(pid === undefined, 'no pid')
t.ok(rnd === undefined, 'no rnd')
})
// should die even though it is only a 100ms task, it'll get caught up
// in a dying worker
setTimeout(function () {
child(100, function (err, pid, rnd) {
t.ok(err, 'got an error')
t.equal(err.type, 'TimeoutError', 'correct error type')
t.ok(pid === undefined, 'no pid')
t.ok(rnd === undefined, 'no rnd')
})
}, 200)
// should be ok, new worker
setTimeout(function () {
child(50, function (err, pid, rnd) {
t.ok(pid > process.pid, 'pid makes sense ' + pid + ' vs ' + process.pid)
t.ok(pid < process.pid + 750, 'pid makes sense ' + pid + ' vs ' + process.pid)
t.ok(rnd > 0 && rnd < 1, 'rnd result makes sense ' + rnd)
})
workerFarm.end(child, function () {
t.ok(true, 'workerFarm ended')
})
}, 400)
})
tape('test error passing', function (t) {
t.plan(10)
let child = workerFarm(childPath, [ 'err' ])
child.err('Error', 'this is an Error', function (err) {
t.ok(err instanceof Error, 'is an Error object')
t.equal('Error', err.type, 'correct type')
t.equal('this is an Error', err.message, 'correct message')
})
child.err('TypeError', 'this is a TypeError', function (err) {
t.ok(err instanceof Error, 'is a TypeError object')
t.equal('TypeError', err.type, 'correct type')
t.equal('this is a TypeError', err.message, 'correct message')
})
child.err('Error', 'this is an Error with custom props', {foo: 'bar', 'baz': 1}, function (err) {
t.ok(err instanceof Error, 'is an Error object')
t.equal(err.foo, 'bar', 'passes data')
t.equal(err.baz, 1, 'passes data')
})
workerFarm.end(child, function () {
t.ok(true, 'workerFarm ended')
})
})
tape('test maxConcurrentCalls', function (t) {
t.plan(10)
let child = workerFarm({ maxConcurrentCalls: 5 }, childPath)
child(50, function (err) { t.notOk(err, 'no error') })
child(50, function (err) { t.notOk(err, 'no error') })
child(50, function (err) { t.notOk(err, 'no error') })
child(50, function (err) { t.notOk(err, 'no error') })
child(50, function (err) { t.notOk(err, 'no error') })
child(50, function (err) {
t.ok(err)
t.equal(err.type, 'MaxConcurrentCallsError', 'correct error type')
})
child(50, function (err) {
t.ok(err)
t.equal(err.type, 'MaxConcurrentCallsError', 'correct error type')
})
workerFarm.end(child, function () {
t.ok(true, 'workerFarm ended')
})
})
// this test should not keep the process running! if the test process
// doesn't die then the problem is here
tape('test timeout kill', function (t) {
t.plan(3)
let child = workerFarm({ maxCallTime: 250, maxConcurrentWorkers: 1 }, childPath, [ 'block' ])
child.block(function (err) {
t.ok(err, 'got an error')
t.equal(err.type, 'TimeoutError', 'correct error type')
})
workerFarm.end(child, function () {
t.ok(true, 'workerFarm ended')
})
})
tape('test max retries after process terminate', function (t) {
t.plan(7)
// temporary file is used to store the number of retries among terminating workers
let filepath1 = '.retries1'
let child1 = workerFarm({ maxConcurrentWorkers: 1, maxRetries: 5}, childPath, [ 'stubborn' ])
child1.stubborn(filepath1, function (err, result) {
t.notOk(err, 'no error')
t.equal(result, 12, 'correct result')
})
workerFarm.end(child1, function () {
fs.unlinkSync(filepath1)
t.ok(true, 'workerFarm ended')
})
let filepath2 = '.retries2'
let child2 = workerFarm({ maxConcurrentWorkers: 1, maxRetries: 3}, childPath, [ 'stubborn' ])
child2.stubborn(filepath2, function (err, result) {
t.ok(err, 'got an error')
t.equal(err.type, 'ProcessTerminatedError', 'correct error type')
t.equal(err.message, 'cancel after 3 retries!', 'correct message and number of retries')
})
workerFarm.end(child2, function () {
fs.unlinkSync(filepath2)
t.ok(true, 'workerFarm ended')
})
})
tape('custom arguments can be passed to "fork"', function (t) {
t.plan(3)
// allocate a real, valid path, in any OS
let cwd = fs.realpathSync(os.tmpdir())
, workerOptions = {
cwd : cwd
, execArgv : ['--no-warnings']
}
, child = workerFarm({ maxConcurrentWorkers: 1, maxRetries: 5, workerOptions: workerOptions}, childPath, ['args'])
child.args(function (err, result) {
t.equal(result.execArgv[0], '--no-warnings', 'flags passed (overridden default)')
t.equal(result.cwd, cwd, 'correct cwd folder')
})
workerFarm.end(child, function () {
t.ok(true, 'workerFarm ended')
})
})
tape('ensure --debug/--inspect not propagated to children', function (t) {
t.plan(3)
let script = __dirname + '/debug.js'
, debugArg = process.version.replace(/^v(\d+)\..*$/, '$1') >= 8 ? '--inspect' : '--debug=8881'
, child = child_process.spawn(process.execPath, [ debugArg, script ])
, stdout = ''
child.stdout.on('data', function (data) {
stdout += data.toString()
})
child.on('close', function (code) {
t.equal(code, 0, 'exited without error (' + code + ')')
t.ok(stdout.indexOf('FINISHED') > -1, 'process finished')
t.ok(stdout.indexOf('--debug') === -1, 'child does not receive debug flag')
})
})

109
rsa.js Normal file
View File

@ -0,0 +1,109 @@
if (process.send) {
process.send(JSON.stringify({mode:"hello"}));
}
// Include some libraries
const atob = require("atob");
const btoa = require("btoa");
const node_rsa = require("node-rsa");
const fs = require("fs");
// Load the settings
var settings = require("./settings");
// Some varibles
var rsa_key;
function load_rsa_key()
{
// Is the rsa key not loaded
if(!rsa_key)
{
// Is the rsa key in memory only
if(settings.rsa.in_memory)
{
// Make a new key
rsa_key = new node_rsa({b:settings.rsa.size});
}
else
{
try
{
// Try reading the keys from a file
rsa_key.importKey(fs.readFileSync(settings.rsa.file.public, "utf-8"), "public");
rsa_key.importKey(fs.readFileSync(settings.rsa.file.private, "utf-8"), "private");
}
catch(e)
{
// Load the new rsa key
rsa_key = new node_rsa({b:settings.rsa.size});
// Export the files
fs.writeFileSync(settings.rsa.file.public, rsa_key.exportKey("public"));
fs.writeFileSync(settings.rsa.file.private, rsa_key.exportKey("private"));
}
}
}
}
function callback(data)
{
// Stringify the data
var string = JSON.stringify(data);
// Send it to the parent
process.send(string);
}
process.on('message', function(message)
{
// Decode the message from json
var args = JSON.parse(message);
// Does the parent want to decrypt some data
if(args['mode'] == 'decrypt')
{
// Decrypt the data with the RSA key
console.log(args['data']);
var data = rsa_key.decrypt(args['data'], 'utf-8');
// Send the data back
callback({
mode: "decrypt",
out: btoa(data)
})
}
// Does the parent want the rsa keys
if(args['mode'] == 'get')
{
// Send back the public/private keys
callback({
mode: "get",
public: rsa_key.exportKey("public"),
private: rsa_key.exportKey("private")
});
}
// Does the parent want the rsa key loaded
if(args['mode'] == 'load')
{
// Load the rsa key
load_rsa_key();
// Send confirmation callback
callback({
mode: "load"
})
}
// Does the parent want to kill the task
/*if(args['mode'] == 'kill')
{
// Kill the task
process.exit();
}*/
});

6
scripts.js Normal file
View File

@ -0,0 +1,6 @@
function connect_direct()
{
var hostname = document.getElementById("hostname").value;
var port = document.getElementById("port").value;
connect(hostname, parseInt(port));
}

View File

@ -1,3 +1,10 @@
{
"rsa_size": 2048
"rsa": {
"file": {
"public": "key.pub",
"private": "key"
},
"size": 2048,
"in_memory": true
}
}

47
tasks.js Normal file
View File

@ -0,0 +1,47 @@
// Include some libraries
const node_rsa = require("node-rsa");
module.exports = function(args, callback)
{
// Does the main task want an rsa key
if(args["mode"] == "make_rsa_key")
{
// Make an rsa key with the specified size
var key = new node_rsa({b:args['size']});
// Get the public and private keys
var data = {
public: key.exportKey("public"),
private: key.exportKey("private")
}
// Send it back to the main task
callback(data);
}
// Does the main task want to decode something
else if(args["mode"] == "decrypt_rsa")
{
// Load the key
var key = new node_rsa();
key.importKey(args["public"], "public");
key.importKey(args["private"], "private");
// Decode the data
var data = key.decrypt(args["string"]);
// Send it back to the main task
callback({
out: data.toString(),
public: key.exportKey("public"),
private: key.exportKey("private")
});
}
else
{
// Call back nothing
callback(undefined);
}
}