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
/** | |
* Uses map syntax to retrieve the given object, or return null if any | |
* portion of the chain is null or undefined. The chain should be given with one | |
* field or method per argument. Methods will be called with the previous step as | |
* `this` and no arguments; this can be used for many string and array methods, as | |
* well as getters from various libraries. | |
* | |
* For example, given the object `foo = {bar: function (x) { return x+3; }};`, then | |
* `objectDig(foo, "bar.toExponential", [[2], [1]])` would return "5.0e+0". | |
* |
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
snake_case | |
lisp-case (or kebab-case) | |
Train-Case | |
TitleCase | |
camelCase | |
nocase | |
VBCASE (OR UPPERCASE) | |
UPPER_SNAKE | |
$E$XC$E$L_$CA$S$E | |
mYsPaCeCaSe |
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
{ | |
init: function(elevators, floors) { | |
var reqs = {}; | |
function requestFloor(num) { | |
reqs[num] = (reqs[num] || 0) + 1; | |
} | |
function getIdealFloor() { | |
var floor = 0, count = 0; | |
for (var next in reqs) { | |
if (reqs.hasOwnProperty(next) && reqs[next] > count) { |
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 strips = 2; | |
var counter = 0; | |
var reserve = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; | |
function getPool() { | |
return [strips, strips, strips, strips, strips, strips, strips, strips, strips, strips]; | |
} | |
function discardPool(pool) { | |
for (var i = 0; i < 10; ++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
var gulp = require("gulp"); | |
var browserify = require("browserify"); | |
var to5browserify = require("6to5-browserify"); | |
var source = require("vinyl-source-stream"); | |
var BUNDLES = [ | |
"build.js", | |
"export.js", | |
"main.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
class Numberator { | |
max = 0; | |
state = 0; | |
constructor(max, state = 0) { | |
this.max = max; | |
this.state = state; | |
} | |
[Symbol.iterator]() { |
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
class MyError extends Error { | |
constructor() { | |
super(); | |
} | |
} | |
class YourError extends MyError { | |
constructor() { | |
super(); | |
} |
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 gulp = require('gulp'); | |
var ts = require('gulp-typescript'); | |
var less = require('gulp-less'); | |
var karma = require('karma').server; | |
var del = require('del'); | |
var overrideConfig = {}; | |
try { | |
overrideConfig = require('./overrides.json'); | |
console.log('Loading override settings.'); |
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
class MachineNode { | |
static create(node) { | |
switch (node.type) { | |
case 'group': | |
return new GroupNode(node.g); | |
case 'char': | |
return new CharacterNode(node.c); | |
case 'alt': | |
return new AlternativeNode(node.l, node.r); | |
case 'list': |
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 group(list) { | |
let l = undefined, r = [], w = []; | |
for (let f of list) { | |
if (l === undefined || f === l) { | |
w.push(f); | |
} else { | |
r.push(w); | |
w = [f]; | |
} | |
l = f; |