Merge branch 'next-release'
This commit is contained in:
commit
31d634eb72
28 changed files with 652 additions and 509 deletions
28
modules/shared/es6/README.md
Normal file
28
modules/shared/es6/README.md
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
Shared (ES6) Sources
|
||||
====================
|
||||
|
||||
This folder contains a mix of shared code, with some files used only by Node (server) modules,
|
||||
some used only by Browser (client) modules, and others used by both.
|
||||
|
||||
At the moment, only a few files are completely agnostic; eg: [strlib.js](strlib.js) and [usrlib.js](usrlib.js).
|
||||
One give-away is that neither contain references to any globals (although references to each other
|
||||
would be fine).
|
||||
|
||||
[netlib.js](netlib.js) is appropriate only for Node modules, because it contains code that relies on Node's
|
||||
global *Buffer* object, as indicated by:
|
||||
|
||||
/* global Buffer: false */
|
||||
|
||||
[weblib.js](weblib.js) is appropriate only for client modules, because it contains code that relies on the
|
||||
browser's global *window* object, as indicated by:
|
||||
|
||||
/* global window: true */
|
||||
|
||||
We declare *window* modifiable (true) so that [defines.js](defines.js) can set *global.window* to *false*
|
||||
when running within Node, allowing any other code to test the existence of *window* with a simple:
|
||||
|
||||
if (window) {...}
|
||||
|
||||
instead of:
|
||||
|
||||
if (typeof window !== "undefined") {...}
|
||||
|
|
@ -1027,7 +1027,7 @@ if (!Array.prototype.indexOf) {
|
|||
* See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray
|
||||
*/
|
||||
if (!Array.isArray) {
|
||||
Array.isArray = function (arg) {
|
||||
Array.isArray = function(arg) {
|
||||
return Object.prototype.toString.call(arg) === '[object Array]';
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
"use strict";
|
||||
|
||||
import Str from "../../shared/es6/strlib";
|
||||
import Component from "../..shared/es6/component";
|
||||
import Component from "../../shared/es6/component";
|
||||
|
||||
/**
|
||||
* Debugger Address Object
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@ class Net {
|
|||
var options = url.parse(sURL);
|
||||
options.method = "HEAD";
|
||||
options.path = options.pathname; // TODO: Determine the necessity of aliasing this
|
||||
var req = http.request(options, function (res)
|
||||
var req = http.request(options, function(res)
|
||||
{
|
||||
var err = null;
|
||||
var stat = null;
|
||||
|
|
@ -179,7 +179,7 @@ class Net {
|
|||
}
|
||||
done(err, stat);
|
||||
});
|
||||
req.on('error', function (err)
|
||||
req.on('error', function(err)
|
||||
{
|
||||
done(err, null);
|
||||
});
|
||||
|
|
@ -211,9 +211,9 @@ class Net {
|
|||
*/
|
||||
var sFile = "";
|
||||
var bufFile = null;
|
||||
http.get(sURL, function (res)
|
||||
http.get(sURL, function(res)
|
||||
{
|
||||
res.on('data', function (data)
|
||||
res.on('data', function(data)
|
||||
{
|
||||
if (sEncoding) {
|
||||
sFile += data;
|
||||
|
|
@ -241,7 +241,7 @@ class Net {
|
|||
* bufFile = buf;
|
||||
*/
|
||||
bufFile = Buffer.concat([bufFile, data], bufFile.length + data.length);
|
||||
}).on('end', function ()
|
||||
}).on('end', function()
|
||||
{
|
||||
/*
|
||||
* TODO: Decide what to do when res.statusCode is actually an error code (eg, 404), because
|
||||
|
|
@ -252,7 +252,7 @@ class Net {
|
|||
} else {
|
||||
done(new Error(sEncoding ? sFile : bufFile), res.statusCode, null);
|
||||
}
|
||||
}).on('error', function (err)
|
||||
}).on('error', function(err)
|
||||
{
|
||||
done(err, res.statusCode, null);
|
||||
});
|
||||
|
|
@ -279,12 +279,12 @@ class Net {
|
|||
* Either the documentation isn't quite right for url.parse() or http.request() (the big brother
|
||||
* of http.get), or one of those "options" properties is aliased to the other, or...?
|
||||
*/
|
||||
http.get(sURL, function (res)
|
||||
http.get(sURL, function(res)
|
||||
{
|
||||
res.on('data', function (data)
|
||||
res.on('data', function(data)
|
||||
{
|
||||
file.write(data);
|
||||
}).on('end', function ()
|
||||
}).on('end', function()
|
||||
{
|
||||
file.end();
|
||||
/*
|
||||
|
|
@ -295,7 +295,7 @@ class Net {
|
|||
* in such cases, the file content will likely just be an HTML error page.
|
||||
*/
|
||||
done(null, res.statusCode);
|
||||
}).on('error', function (err)
|
||||
}).on('error', function(err)
|
||||
{
|
||||
done(err, res.statusCode);
|
||||
});
|
||||
|
|
@ -329,7 +329,7 @@ class Net {
|
|||
var sBaseName = Str.getBaseName(sURL);
|
||||
var sFile = path.join(Net.sServerRoot, sURL);
|
||||
if (fAsync) {
|
||||
fs.readFile(sFile, {encoding: "utf8"}, function (err, s)
|
||||
fs.readFile(sFile, {encoding: "utf8"}, function(err, s)
|
||||
{
|
||||
/*
|
||||
* TODO: If err is set, is there an error code we should return (instead of -1)?
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ class Proc {
|
|||
*
|
||||
* @return {{argc:number, argv:{}}}
|
||||
*/
|
||||
static getArgs = function ()
|
||||
static getArgs()
|
||||
{
|
||||
var argc = 0;
|
||||
var argv = {};
|
||||
|
|
|
|||
|
|
@ -450,7 +450,7 @@ class Str {
|
|||
*/
|
||||
static escapeHTML(sHTML)
|
||||
{
|
||||
return sHTML.replace(/[&<>"']/g, function (m)
|
||||
return sHTML.replace(/[&<>"']/g, function(m)
|
||||
{
|
||||
return Str.aHTMLEscapeMap[m];
|
||||
});
|
||||
|
|
@ -494,7 +494,7 @@ class Str {
|
|||
k = k.replace(/([\\[\]*{}().+?])/g, "\\$1");
|
||||
sMatch += (sMatch ? '|' : '') + k;
|
||||
}
|
||||
return s.replace(new RegExp('(' + sMatch + ')', "g"), function (m)
|
||||
return s.replace(new RegExp('(' + sMatch + ')', "g"), function(m)
|
||||
{
|
||||
return a[m];
|
||||
});
|
||||
|
|
@ -553,7 +553,10 @@ class Str {
|
|||
*/
|
||||
static toASCIICode(b)
|
||||
{
|
||||
var s = (b != Str.ASCII.CR && b != Str.ASCII.LF ? Str.aASCIICodes[b] : null);
|
||||
var s;
|
||||
if (b != Str.ASCII.CR && b != Str.ASCII.LF) {
|
||||
s = Str.aASCIICodes[b];
|
||||
}
|
||||
if (s) {
|
||||
s = '<' + s + '>';
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ class Usr {
|
|||
var right = a.length;
|
||||
var found = 0;
|
||||
if (fnCompare === undefined) {
|
||||
fnCompare = function (a, b)
|
||||
fnCompare = function(a, b)
|
||||
{
|
||||
return a > b ? 1 : a < b ? -1 : 0;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -174,7 +174,7 @@ class Web {
|
|||
return [sResource, nErrorCode];
|
||||
}
|
||||
else if (fAsync && typeof resources == 'function') {
|
||||
resources(sURL, function (sResource, nErrorCode)
|
||||
resources(sURL, function(sResource, nErrorCode)
|
||||
{
|
||||
if (done) done(sURL, sResource, nErrorCode);
|
||||
});
|
||||
|
|
@ -190,7 +190,7 @@ class Web {
|
|||
|
||||
var xmlHTTP = (window.XMLHttpRequest ? new window.XMLHttpRequest() : new window.ActiveXObject("Microsoft.XMLHTTP"));
|
||||
if (fAsync) {
|
||||
xmlHTTP.onreadystatechange = function ()
|
||||
xmlHTTP.onreadystatechange = function()
|
||||
{
|
||||
if (xmlHTTP.readyState === 4) {
|
||||
/*
|
||||
|
|
@ -679,7 +679,7 @@ class Web {
|
|||
var match;
|
||||
var pl = /\+/g; // RegExp for replacing addition symbol with a space
|
||||
var search = /([^&=]+)=?([^&]*)/g;
|
||||
var decode = function (s)
|
||||
var decode = function(s)
|
||||
{
|
||||
return decodeURIComponent(s.replace(pl, " "));
|
||||
};
|
||||
|
|
@ -777,7 +777,7 @@ class Web {
|
|||
ms = msRepeat;
|
||||
}
|
||||
};
|
||||
e.onmousedown = function ()
|
||||
e.onmousedown = function()
|
||||
{
|
||||
// Web.log("onMouseDown()");
|
||||
if (!fIgnoreMouseEvents) {
|
||||
|
|
@ -787,7 +787,7 @@ class Web {
|
|||
}
|
||||
}
|
||||
};
|
||||
e.ontouchstart = function ()
|
||||
e.ontouchstart = function()
|
||||
{
|
||||
// Web.log("onTouchStart()");
|
||||
if (!timer) {
|
||||
|
|
@ -795,7 +795,7 @@ class Web {
|
|||
fnRepeat();
|
||||
}
|
||||
};
|
||||
e.onmouseup = e.onmouseout = function ()
|
||||
e.onmouseup = e.onmouseout = function()
|
||||
{
|
||||
// Web.log("onMouseUp()/onMouseOut()");
|
||||
if (timer) {
|
||||
|
|
@ -803,7 +803,7 @@ class Web {
|
|||
timer = null;
|
||||
}
|
||||
};
|
||||
e.ontouchend = e.ontouchcancel = function ()
|
||||
e.ontouchend = e.ontouchcancel = function()
|
||||
{
|
||||
// Web.log("onTouchEnd()/onTouchCancel()");
|
||||
if (timer) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
Shared Sources
|
||||
===
|
||||
==============
|
||||
|
||||
This folder contains a mix of shared code, with some files used only by Node (server) modules,
|
||||
some used only by Browser (client) modules, and others used by both.
|
||||
|
|
@ -8,7 +8,7 @@ At the moment, only a few files are completely agnostic; eg: [strlib.js](strlib.
|
|||
One give-away is that neither contain references to any globals (although references to each other
|
||||
would be fine).
|
||||
|
||||
**netlib.js** is appropriate only for Node modules, because it contains code that relies on Node's
|
||||
[netlib.js](netlib.js) is appropriate only for Node modules, because it contains code that relies on Node's
|
||||
global *Buffer* object, as indicated by:
|
||||
|
||||
/* global Buffer: false */
|
||||
|
|
|
|||
|
|
@ -1081,7 +1081,7 @@ if (!Array.prototype.indexOf) {
|
|||
* See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray
|
||||
*/
|
||||
if (!Array.isArray) {
|
||||
Array.isArray = function (arg) {
|
||||
Array.isArray = function(arg) {
|
||||
return Object.prototype.toString.call(arg) === '[object Array]';
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,6 @@
|
|||
var socket = io.connect();
|
||||
|
||||
// if we get an "info" emit from the socket server then console.log the data we receive
|
||||
socket.on('info', function (data) {
|
||||
socket.on('info', function(data) {
|
||||
console.log(data);
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue