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
| // Stack operations will always have a time complexity of O(1) regardless the size of the stack | |
| var Stack = function() { | |
| this.count = 0; | |
| this.storage = {}; | |
| } | |
| Stack.prototype = (function() { | |
| return { |
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
| nge.js | |
| const NumRange = (function CreateRangeObject() { | |
| return { | |
| from: from | |
| } | |
| function from(num1) { | |
| var arr = []; | |
| return { |
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 memoizer(func) { | |
| var cache = []; | |
| return function(n) { | |
| var idx = n.toString(); | |
| if (cache[idx] === undefined) { | |
| cache[idx] = func(x); | |
| } | |
| return cache[idx]; | |
| } |
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 node = mockNode(); | |
| mapTree(node, upCase); | |
| function upCase(string) { | |
| return string.toUpperCase(); | |
| } | |
| function mapTree(node, mapper) { | |
| return { |
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
| // $log.log will call $log.debug instead which is globally configurable from the debugEnabled call | |
| (function() { | |
| 'use strict'; | |
| angular.module('app') | |
| .config(AppLogConfig); | |
| AppLogConfig.$inject = ['$logProvider', 'IS_DEV_MODE', '$provide']; | |
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 el = document.getElementById('hplogo'); | |
| var tearItDown = setClickListener(el, function() { | |
| console.log('2222222'); | |
| }); | |
| tearItDown(); | |
| function setClickListener(element, fn) { | |
| element.addEventListener('click', fn); |
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 getType(elem) { | |
| return Object.prototype.toString.call(elem).slice(8, -1); | |
| }; |
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 IE_Wrapper(fn) { | |
| return function(...params) { | |
| if (window.ActiveXObject || 'ActiveXObject' in window) { | |
| fn(...params); | |
| } | |
| } | |
| } |
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
| // https://gist.github.com/JamieMason/172460a36a0eaef24233e6edb2706f83#file-es6-compose-md | |
| // By: Jamie Mason | |
| // https://gist.github.com/JamieMason | |
| const compose = (...fns) => | |
| fns.reverse().reduce((prevFn, nextFn) => | |
| value => nextFn(prevFn(value)), | |
| value => value | |
| ); |
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
| Array.prototype.shuffle = function() { | |
| return this.sort(function() { | |
| return 0.5 > Math.random(); | |
| }); | |
| } |
OlderNewer