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
//------------------------------------------------------------------------------ | |
// Create a function `collection.fnName`. | |
// The function applies `_.lodashFn` on `collection` and calls `fnName` on | |
// each item. | |
// @param collection Any collection lodash can process | |
// @param fnName Name of function generated. | |
// @param lodashFn Name of the lodash collection function to apply. | |
// Defaults to 'each'. | |
function createCollectionProxyFn(collection, fnName, lodashFn) { | |
lodashFn = lodashFn || 'each'; |
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
//------------------------------------------------------------------------------ | |
// DependencyManager | |
// The DependencyManager handles asynchronous module initialization with | |
// dependencies. | |
// | |
// Example: | |
// ======= | |
// Modules A and B load asynchronously. | |
// Module C requires A and B and loads synchronously. | |
// Module D requires C and loads asynchronously. |
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
//============================================================================== | |
//============================================================================== | |
window.MessageLoop = (function(){ | |
//============================================================================ | |
var _Set; | |
if ('undefined' !== typeof Set) { | |
_Set = Set; | |
} | |
else { |
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(){ | |
var _currentIndex = 0; | |
var _history = [{ | |
url: location.hash.substr(1) || '/', | |
index: _currentIndex | |
}]; | |
var _currentState = _history[_currentIndex]; | |
var _ignorePopstate = false; |
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
/**************************************************************************//** | |
* @file | |
* @brief SemVer.js: Semantic version implementation. | |
* @author Arne Seib <[email protected]> | |
* @copyright 2015 Arne Seib (http://www.seiberspace.de). | |
*****************************************************************************/ | |
SemVer = (function() { | |
//------------------------------------------------------------------------------ | |
// private function: validate `from[name]` with validator `type`. |
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 createScale(vals, iterations) { | |
var m = vals.length * iterations; | |
for (var n = 0; n < m; n++) { | |
var x = vals[n % vals.length] * Math.pow(10, Math.floor(n / vals.length)); | |
console.log(x); | |
} | |
} | |
createScale([1,2,5], 3); |
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
// Sugar. | |
// Instead of | |
// | |
// Promise.all([2, calculateValB(3), calculateValC(4)]).then((result) => { | |
// var res = calculateResult(result[0], result[1], result[2]); | |
// /* process result */ | |
// }); | |
// | |
// write | |
// |
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 step1(result) { | |
console.log('call step1'); | |
return new Promise(function(resolve, reject) { | |
console.log('resolve step1'); | |
result['step1'] = 'Step 1'; | |
return resolve(result); | |
}); | |
} | |
function step2(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
class MPromise extends Promise { | |
constructor(executor) { | |
super((resolve, reject) => | |
executor((...args) => resolve(args), (...args) => reject(args)) | |
); | |
} | |
then(onFulfilled, onRejected) { | |
return super.then( | |
onFulfilled ? (args) => onFulfilled(...args) : undefined, |
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
(() => { | |
['white', 'silver', 'gray', 'black', 'red', 'maroon', 'yellow', 'olive', 'lime', | |
'green', 'aqua', 'teal', 'blue', 'navy', 'fuchsia', 'purple' | |
].forEach(color => { | |
console[color] = (...args) => { | |
console.log(`%c${args.join(' ')}`, `color:${color}`) | |
} | |
console[`${color}B`] = (...args) => { | |
console.log(`%c${args.join(' ')}`, `color:${color};font-weight:bold`) | |
} |