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
/* | |
plural rules | |
regular | |
if -s, -x, -ch or -sh then add -es | |
if -{consonant}y then remove -y and add -ies | |
else add -s | |
irregular | |
if -f then remove -f and add -ves | |
if -fe then remove -fe and add -ves |
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 hyphenToCamel (text) { | |
var hyphen = text.split(''); | |
var camel = []; | |
var i = 0, j = 0, l = hyphen.length; | |
while (i < l) { | |
camel[j] = hyphen[i] === '-' ? hyphen[++i].toUpperCase() : hyphen[i]; | |
i++; j++; | |
} |
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 camelToHyphen (text) { | |
var camel = text.split(''); | |
var hyphen = []; | |
var i = 0, l = camel.length; | |
for (var i = -1, l = camel.length; ++i < l;) { | |
hyphen[i] = camel[i] === camel[i].toUpperCase() ? '-' + camel[i].toLowerCase() : camel[i]; | |
} | |
return hyphen.join(''); |
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
module.exports = Vector; | |
function Vector (x, y, z) { | |
this.x = x || 0; | |
this.y = y || 0; | |
this.z = z || 0; | |
} | |
Vector.prototype.clone = function clone () { | |
return new Vector(this.x, this.y, this.z); |
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
module.exports = Pool; | |
function Pool (create, reset) { | |
this.pool = []; | |
this.create = create; | |
this.reset = reset; | |
} | |
Pool.prototype.acquire = function acquire () { |
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
module.exports = Something; | |
function Something () {} | |
Something.prototype.toJSON = function () { | |
var clone = {}; | |
var firstChar; | |
var that = this; | |
Object.keys(this).forEach(function (key) { | |
var firstChar = key[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
var inherit = require('inherit'); | |
module.exports = AbstractError; | |
inherit(AbstractError, Error) | |
function AbstractError (message) { | |
this.message = message; | |
this.stack = (new Error()).stack; | |
} |
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
import workify from 'workify.js' | |
function log (error, it) { | |
if (error) throw error; | |
console.log(it); | |
} | |
toLowerCase = workify(function (it) { return it.toLowerCase(); }); | |
toLowerCase('HELLO', log); |
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 short = 'hello'; | |
var long = 'hello world'; | |
var result = ''; | |
for (var i = -1, l = long.length; ++i < l;) { | |
console.log(i % short.length); | |
result += short[i % short.length]; | |
} | |
console.log(result); |
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
let (delete) = macro { | |
rule { $path:ident } => { } | |
} | |
macro (delete!) { | |
rule { | |
$path:ident | |
} => { | |
} |
OlderNewer