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
const wrap = require('./wrapper').wrap; | |
function sleep(ms) { | |
return new Promise((resolve, reject) => { | |
setTimeout(resolve, ms); | |
}) | |
} | |
async function f1() { | |
await wrap(sleep(1), __filename, 9); | |
throw new Error('error1'); |
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
const fs = require('fs'); | |
const fsp = require('path'); | |
function scan(dir, results, mod) { | |
fs.readdirSync(dir).forEach(name => { | |
const path = fsp.join(dir, name); | |
let m; | |
if (fs.statSync(path).isDirectory()) { | |
scan(path, results, name === 'node_modules' ? null : mod === null ? name : mod); | |
} else if (mod && (m = /(.*)\.[jt]s$/.exec(name)) && !/\.(d|min|debug)$/.test(m[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
"use strict"; | |
// experimental value | |
// nsyms is size of alphabet (62 for letters + digits) | |
// len is password length | |
// maxReapeat is the max number of repeats we allow | |
// returns the probability of a password reject. | |
function expe(nsyms, len, maxRepeat) { | |
// generate random array of len symbols | |
const gen = len => { |
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 Fiber = require('fibers'); | |
function sleep(millis, id) { | |
var fiber = Fiber.current; | |
console.log(id + ": sleep begin"); | |
setTimeout(function() { | |
console.log("wake up"); | |
fiber.run(); | |
}, millis) | |
Fiber.yield(); |
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 Fiber = require('fibers'); | |
function sleep(millis, id) { | |
var fiber = Fiber.current; | |
console.log(id + ": sleep begin"); | |
setTimeout(function() { | |
console.log("wake up"); | |
fiber.run(); | |
}, millis) | |
Fiber.yield(); |
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
console.log("script begin"); | |
var Fiber = require('fibers'); | |
Fiber(function() { | |
var fiber = Fiber.current; | |
setTimeout(function() { | |
console.log("setTimeout callback begin"); | |
fiber.run(); | |
console.log("setTimeout callback end"); | |
}, 10000) |
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
"use strict"; | |
class Complex { | |
constructor(a, b) { | |
this.re = a; | |
this.im = b; | |
} | |
add(c) { | |
return new Complex(this.re + c.re, this.im + c.im); | |
} |
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
"use strict"; | |
function assert(i, j) { | |
if (i !== j) throw new Error("expected " + i + ", got " + j) | |
} | |
function callbackIter(fn, n, cb) { | |
var t0 = Date.now(); | |
(function doIt(i) { | |
if (i < n) fn(i, function(err, 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
var oracledb = require('oracledb'); | |
var ez = require('ez-streams'); | |
var cnx = oracledb.getConnection({ | |
user: "scott", | |
password: "oracle", | |
connectString: "localhost/ORCL", | |
}, _); | |
try { |
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
"use strict"; | |
exports.queryAll = function(conn, sql, args, cb) { | |
var allRows = []; | |
conn.execute(sql, args, { | |
resultSet: true | |
}, function(err, result) { | |
if (err) return cb(err); | |
function fetch() { |
NewerOlder