View rand31.js
export default createFromSeed(randomSeed());
export function createFromSeed(seed) {
if (!Number.isInteger(seed) || seed <= 0) {
throw new TypeError('seed must be an int > 0');
}
let value = seed;
const next = () => {
const hi = 16807 * (value >> 16);
View url-safe-base64.js
const encode_regex = /[\+=\/]/g;
const decode_regex = /[\._\-]/g;
// Buffer -> Base64 String -> Url Safe Base64 String
export function encode(buffer) {
return buffer.toString('base64').replace(encode_regex, encodeChar);
}
// Url Safe Base64 String -> Base64 String -> Buffer
export function decode(string) {
View axial-coordinates.js
/**
Axial coordinates
# convert cube to axial
q = x
r = z
# convert axial to cube
x = q
z = r
View function-proxy.js
exports.proxy = function(length, fn) {
return createProxyFactory(length)(fn);
}
function createProxyFactory(length) {
return Function(
'var fn = arguments[0];' +
'return function(' + argNames(length) + '){' +
' return fn.apply(this, arguments);' +
'}'
View deprecate-property.js
function deprecate(obj, prop) {
Object.defineProperty(obj, prop, {
enumerable: true,
get: function() {
throw new Error('Property ' + prop + ' is deprecated!');
}
});
}
View StringBuilder.js
/* @flow */
export class StringBuilder {
encoding: string;
byte_length: number;
list: Array<Buffer>;
constructor(encoding?: string = 'utf8') {
this.encoding = encoding;
this.byte_length = 0;
View modulo.js
function modulo(a, b) {
var r = a % b;
return (r * b < 0) ? r + b : r;
}
function nthArrayItem(array, n) {
return array[modulo(n, array.length)];
}
View index.js
var joi = require('joi');
var joi_to_markdown = require('joi-to-markdown');
var event_util = require('dom-events');
var insertCSS = require('insert-css');
var container = document.createElement('div');
var input_textarea = document.createElement('textarea');
var convert_button = document.createElement('button');
var output = document.createElement('pre');
View async-dust-helper.js
dust.helpers.getValueAsync = function(chunk, context, bodies, params) {
return chunk.map(function(inner_chunk) {
// Simulate an async op with setImmediate
setImmediate(function() {
inner_chunk.write('It works!').end();
});
});
};
View node-test-alias.sh
alias t='NODE_ENV=test ./node_modules/.bin/istanbul cover --report lcov ./node_modules/.bin/_mocha -- --ui bdd --check-leaks --recursive --slow 200 --reporter dot test'
alias tm='NODE_ENV=test ./node_modules/.bin/mocha --bail --ui bdd --check-leaks --recursive --slow 200 --reporter dot test'
alias tc='NODE_ENV=test ./node_modules/.bin/mocha --bail --ui bdd --check-leaks --reporter dot $(git diff --name-only test | grep -E "(\.js)$")'