View file-syntax.js
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])) {
View stupid-password-rule.js
"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 => {
View fibers-sleep-parallel.js
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();
View fibers-sleep-sequential.js
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();
View fibers-does-not-block.js
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)
View zeta.js
"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);
}
View async-call-bench.js
"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) {
View lob-bug._js
var oracledb = require('oracledb');
var ez = require('ez-streams');
var cnx = oracledb.getConnection({
user: "scott",
password: "oracle",
connectString: "localhost/ORCL",
}, _);
try {
View query-all.js
"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() {
View fibug.js
var Fiber = require("./build/Release/fibers").Fiber;
function wrap(fn, idx) {
function F() {
var cb = arguments[idx];
var that = this,
args = arguments;
Fiber(function () {
var val, err = null;