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
marcel@marcel-2 ~ $ node -v | |
v5.10.1 | |
marcel@marcel-2 ~ $ cat a.js | |
"use strict"; | |
switch (1) { | |
case 2: | |
let foo; | |
} | |
foo.bar; | |
marcel@marcel-2 ~ $ node a.js |
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
[...] | |
// Reverse of parseRoomName | |
renderRoomName(room) { | |
if (room[0] === 255) { | |
return 'sim'; | |
} | |
return ( | |
(room[0] < 0 ? 'W'+ (-room[0] - 1) : 'E'+ room[0])+ | |
(room[1] < 0 ? 'N'+ (-room[1] - 1) : 'S'+ room[1]) | |
); |
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
function addBlockedRoomsToMatrix(theRoom) | |
{ | |
console.log(theRoom) | |
var theMatrix = new PathFinder.CostMatrix | |
{ | |
var exits = Game.map.describeExits(theRoom); | |
for(var ext in exits) | |
{ | |
var room = exits[ext]; |
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
function longPath(from, to) { | |
let rooms = {}; | |
Game.map.findRoute(from.roomName, to.roomName).forEach(function(step, ii, route) { | |
function generateCostMatrix(dir1, dir2) { | |
let cm = new PathFinder.CostMatrix; | |
let dir = 1 << dir1 | 1 << dir2; | |
for (let ii = 0; ii < 49; ++ii) { | |
if (!(dir & 1 << TOP)) { | |
cm.set(ii, 0, 0xff); | |
} |
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
require('fibers'); | |
var fs = require('fs'); | |
function resumer() { | |
var fiber = Fiber.current; | |
return function(err, val) { | |
if (err) { | |
fiber.throwInto(err); | |
} else { | |
fiber.run(val); |
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
#include <iostream> | |
#include <v8.h> | |
using namespace std; | |
using namespace v8; | |
// simple print utility; mostly lifted from shell.cc | |
Handle<Value> Print(const Arguments& args) { | |
bool first = true; | |
for (int i = 0; i < args.Length(); i++) { |
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
Put this at the top of your main.js file. Log `extraCPU` at the end to see how much extra CPU will be spent. | |
If you're using the "loop" architecture you have to move some stuff around. Just reset `extraCPU` and `called` every tick. |
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
diff --git a/binding.gyp b/binding.gyp | |
index 379026f..0413e95 100644 | |
--- a/binding.gyp | |
+++ b/binding.gyp | |
@@ -6,6 +6,7 @@ | |
# Replace gyp platform with node platform, blech | |
['platform == "mac"', {'variables': {'platform': 'darwin'}}], | |
['platform == "win"', {'variables': {'platform': 'win32'}}], | |
+ ['platform == "solaris"', {'variables': {'platform': 'sunos'}}], | |
], |
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
diff --git a/src/fibers.cc b/src/fibers.cc | |
index 49a20f7..c446f9d 100644 | |
--- a/src/fibers.cc | |
+++ b/src/fibers.cc | |
@@ -143,6 +143,42 @@ class Fiber { | |
} | |
/** | |
+ * Build a new fiber and immediately run it. | |
+ */ |
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
var path = require('path'), | |
fs = require('fs'), | |
Future = require('fibers/future'); | |
// Create future-returning fs functions | |
var fs2 = {}; | |
for (var ii in fs) { | |
fs2[ii] = Future.wrap(fs[ii]); | |
} |