-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* var => const/let + other modernizations * replaced var with const in examples * code modernization * code modernization, removed obsolete require of Binary, ByteArray and ByteString (these are globally defined) * code modernization, added tests for net module * code modernization * code modernization * code modernization, added test for help() method * code modernization * code modernization * use require instead of include in code example to make things explicit * avoid redeclaration of consts binary module uses defineClass to modify the global scope, so we can't (re)declare ie. const Binary * modernized/simplified code, added test for Semaphore * code modernization * code modernization (ie. var -> const/let) * code modernization (ie. var -> const/let) * code modernization (ie. var -> const/let) * code modernization (ie. var -> const/let) * code modernization * code modernization (ie. var -> const/let) * bugfix: arrow functions have no arguments object * code modernization disentangled Frame and Profiler constructors: moved Frame constructor out of Profiler constructor, and pass the stack it needs as argument * code modernization (ie. var -> const/let) * code modernization (ie. var -> const/let) * code modernization (ie. var -> const/let) * replaced include() in code example with more explicit require * code modernization (ie. var -> const/let), ZipIterator is now a Generator function * added missing tests * code modernization (ie. var -> const/let) * code modernization (ie. var -> const/let) * code modernization (ie. var -> const/let) * code modernization (ie. var -> const/let) removed partition() method - this method was obviously broken and not covered by tests, so i assume it's obsolete * code modernization (ie. var -> const/let) * use strict comparisons and 0o1234 for octals, minor code formatting * code modernization (ie. var -> const/let), fixed an error in parseFileUpload() - unfolding multiline headers couldn't have worked * code modernization (ie. var -> const/let) * code modernization (ie. var -> const/let) * code modernization (ie. var -> const/let) * stack traces now exclude the test module too, code modernization * code modernization * #409 implemented binary.toByteString() as replacement of the (now deprecated) String.prototype.toByteString() method * minor: simplified named exports * regression fix: short option can be null/undefined * modified prototype construction of AssertionError and ArgumentsError (jsdoc rendered the constructor property) * regression fix: printResult and printError must be declared as local const variables, otherwise RingoShell class is unable to invoke them. * regression fix: objects.merge() must handle null/undefined arguments removed hasOwnProperty() check since Object.keys() returns only own enumerable property names * fixed variable declaration * added worker test * fixed write/writeln method binding * reverted change to arrow functions to maintain correct scope * fixed & modernized examples * #409 binary module no longer modifies the String prototype also fixes toByteString to return a ByteString, not a ByteArray Co-authored-by: Robert Gaggl <[email protected]>
- Loading branch information
Showing
82 changed files
with
3,126 additions
and
3,378 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
var fs = require('fs'); | ||
var {GREEN, BLUE, writeln} = require('ringo/term'); | ||
const fs = require('fs'); | ||
const {GREEN, BLUE, writeln, RESET} = require('ringo/term'); | ||
|
||
var filename = module.path; | ||
const filename = module.path; | ||
|
||
// text streams have an iterator that reads the next line | ||
var file = fs.open(filename); // text mode | ||
let file = fs.open(filename); // text mode | ||
file.forEach(function(line) { | ||
writeln(GREEN, line); | ||
writeln(GREEN, line, RESET); | ||
}); | ||
|
||
// binary streams read into ByteArrays/ByteStrings | ||
file = fs.open(filename, {binary: true}); | ||
writeln(BLUE, file.read()) | ||
writeln(BLUE, file.read(), RESET) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
var response = require("ringo/jsgi/response"); | ||
const response = require("ringo/jsgi/response"); | ||
|
||
module.exports = function(req) { | ||
module.exports = (req) => { | ||
return response.html("Hello World!"); | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
var httpServer = require("../lib/main"); | ||
var builder = httpServer.build("config/jetty.xml") | ||
const httpServer = require("ringo/httpserver"); | ||
const builder = httpServer.build("config/jetty.xml") | ||
// serve application | ||
.serveApplication("/", module.resolve("./app")) | ||
.serveApplication("/", module.resolve("./httpserver-app")) | ||
// static file serving | ||
.serveStatic("/static", module.resolve("./"), { | ||
"allowDirectoryListing": true | ||
}) | ||
// start up the server | ||
.start(); | ||
.start(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,45 @@ | ||
// Simple websocket server demo | ||
var response = require("ringo/jsgi/response"); | ||
var arrays = require("ringo/utils/arrays"); | ||
const response = require("ringo/jsgi/response"); | ||
const arrays = require("ringo/utils/arrays"); | ||
const httpServer = require("ringo/httpserver"); | ||
|
||
var connections = []; | ||
const connections = []; | ||
|
||
// Schedule an interval function that periodically broadcasts the number of open connections | ||
setInterval(function() { | ||
connections.forEach(function(conn) { | ||
setInterval(() => { | ||
connections.forEach((conn) => { | ||
conn.send((connections.length - 1) + " other connection(s) open"); | ||
}); | ||
}, 5000) | ||
|
||
exports.app = function(req) { | ||
const app = (req) => { | ||
return response.static(module.resolve("html/websocket.html"), "text/html"); | ||
}; | ||
|
||
function onconnect(conn) { | ||
const onConnect = (conn) => { | ||
connections.push(conn); | ||
console.info("Opening connection, " + connections.length + " open"); | ||
conn.addListener("text", function(message) { | ||
connections.forEach(function(conn) { | ||
conn.send(message); | ||
}); | ||
conn.addListener("text", message => { | ||
connections.forEach(conn => conn.send(message)); | ||
console.info("Sending message"); | ||
}); | ||
conn.addListener("close", function() { | ||
conn.addListener("close", () => { | ||
arrays.remove(connections, conn); | ||
console.info("Closing connection, " + connections.length + " remaining"); | ||
}) | ||
} | ||
}); | ||
}; | ||
|
||
if (require.main == module) { | ||
var server = require("ringo/httpserver").main(module.id); | ||
server.getDefaultContext().addWebSocket("/websocket", onconnect); | ||
} | ||
httpServer.build() | ||
// enable sessions with a custom node name | ||
// serve application | ||
.serveApplication("/", app) | ||
// add websocket - this must be called after serveApplication | ||
// as it operates on the current context of the builder | ||
.addWebSocket("/websocket", onConnect) | ||
.http({ | ||
"port": 8080 | ||
}) | ||
// start up the server | ||
.start(); | ||
} |
Oops, something went wrong.