This file contains hidden or 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
/* SOME_MODULE.js */ | |
var masala = require('masala'); | |
// The default arguments have a lot of unbound parameters (something like 12) | |
// They specify a myriad of arguments from invocation-specific parameters | |
// to general options that should be mostly shared between all invocations | |
var defaultArguments = { ... }; | |
function genericFunction (options, callback) { ... } |
This file contains hidden or 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
>> BEFORE: | |
ReferenceError: _notDefined is not defined | |
at throwingFunction (J:\my_node_libs\masala\examples\exception.js:4:2) | |
at intermediateFunction (J:\my_node_libs\masala\examples\exception.js:8:9) | |
at sauce (J:\my_node_libs\masala\masala.js:126:17) | |
at intermediateFunction (eval at wrapFunctionWithArity (J:\my_node_libs\masala\masala.js:79:11), <anonymous>:2:11) | |
at callingContext (J:\my_node_libs\masala\examples\exception.js:19:7) | |
at Object.<anonymous> (J:\my_node_libs\masala\examples\exception.js:20:2) | |
at Module._compile (module.js:444:26) |
This file contains hidden or 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 a = 'Going down to brown town'; | |
String.prototype.lerp = function(n){ | |
var ai = Math.floor(n); | |
var t = n - ai; | |
var a = this.charCodeAt(ai); | |
var b = this.charCodeAt(ai + 1); | |
return String.fromCharCode(a + (b - a) * t); | |
} |
This file contains hidden or 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 rand (max) { return Math.random() * max; } | |
function *randomSample () { | |
var answer = yield; | |
var totalWeight = answer.w; | |
while (true) { | |
var next = yield answer; | |
var w = next.w; | |
var r = rand(totalWeight + w); |
This file contains hidden or 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 rand (max) { return Math.random() * max; } | |
function randomSample (array) { | |
var answer = array[0]; | |
var totalWeight = array[0].w; | |
var left = array.slice(1); | |
left.forEach(function (element) { | |
var w = element.w; | |
var r = rand(totalWeight + w); |
This file contains hidden or 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 appender (to, el) { to.appendChild(el); return to; } | |
function genElement (type, next) { | |
return next(document.createElement(type)) | |
} | |
var genTextNode = document.createTextNode.bind(document); | |
function genElements (values, generator, parent) { | |
return values.map(generator) |
This file contains hidden or 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
Firefox 33 | |
---------------------------------------------- | |
HDRPNG - Reading and Parsing PNG: 279.62ms | |
HDRPNG - Convert LogLuv to rgb float: 716.98ms | |
HDRPNG - Generate Log2 Luminance: 156.1ms | |
HDRPNG - Generate Histograms: 326.97ms | |
Applying TMO: 159.38ms | |
Applying DMO: 231.71ms | |
----------------------------------------------- | |
Total: 1,870ms |
This file contains hidden or 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
window.addEventListener('load', getRequestForEditor); | |
var events = ['change', 'contextmenu', 'select', 'keypress', 'dblclick', 'click', 'mousedown', 'mouseup', 'mousewheel', 'scroll']; | |
function bindEvent (eventName) { | |
this.addEventListener(eventName, getRequestForEditor); | |
} | |
events.forEach(bindEvent, document.getElementById("selContentType")); | |
events.forEach(bindEvent, document.getElementById("selTheme")); |
This file contains hidden or 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 (root, factory) { | |
if (typeof exports === 'object') { | |
module.exports = factory(require('masala')); | |
} else if (typeof define === 'function' && define.amd) { | |
define(['masala'], factory); | |
} else { | |
root.fitText = factory(root.masala); | |
} | |
}(this, function (masala) { | |
var rectEnum = { |
This file contains hidden or 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
window.requestAnimFrame = (function(global) { | |
var callbackList = [], | |
timer, | |
nextTimeSlot = 0; | |
function processCallbacks () { | |
var localCBList = callbackList, | |
now = +(new Date), cb; | |
callbackList = []; |