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 Benchmark = require( 'benchmark' ); | |
var len = process.argv[2] || 3; | |
var obj = {}; | |
for ( var i = 0; i < len; i++ ) { | |
obj[i] = "value" + i; | |
} |
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 grabIt (thing) { | |
var frame = document.createElement('iframe'); | |
document.body.appendChild(frame); | |
var thing = frame.contentWindow[thing]; | |
document.body.removeChild(frame); | |
return thing; | |
} | |
var Collection = grabIt("Array"); |
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
/** | |
* Enable route to __noSuchMethod__ when unknown method calling. | |
* | |
* @param {Object} obj Target object. | |
* @return {Object} | |
*/ | |
function enableMethodMissing(obj) { | |
var functionHandler = createBaseHandler({}); | |
functionHandler.get = function(receiver, name) { |
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 helloProto = { | |
toString: function () { | |
return "Hello!"; | |
} | |
} | |
function helloFactory () { | |
return Object.create(helloProto); | |
} |
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 Bluebird = require("bluebird"); | |
var nba = require("nba"); | |
Object.keys(nba.api).forEach(function (method) { | |
var original = nba.api[method]; | |
nba.api[method] = Promise.promisify(original); | |
}); |
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
[..., last] = arr |
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
let curry = (fn, ...args) => args.length >= fn.length ? fn(...args) : (...more) => curry(fn, ...args, ...more) | |
// just to make the gist longer. |
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
let promisify = fn => (...args) => | |
new Promise((resolve, reject) => { | |
fn(...args, (err, result) => { | |
if (err) return reject(err); | |
resolve(result); | |
}); | |
}); |
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
let promisify = func => (...args) => new Promise((resolve, reject) => func(...args, (err, result) => err ? reject(err) : resolve(result))); | |
// |
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
// targets this file: https://github.com/seemethere/nba_py/wiki/stats.nba.com-Endpoint-Documentation | |
var fs = require("fs"); | |
var markdown = fs.readFileSync("./stats.nba.com-Endpoint-Documentation.md", "utf8"); | |
function createDescription (block) { | |
var name = block[0].slice(3, -1); | |
var params = block.slice(2).map(line => line.slice(4)).filter(Boolean); | |
return {name, params}; | |
} |