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
| "★★★★★☆☆☆☆☆".slice(5 - CUSTOMER_SATISFACTION, 10 - CUSTOMER_SATISFACTION) |
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
| // Create HTTP error | |
| function createError(status, message) { | |
| var err = new Error(message); | |
| err.status = status; | |
| return err; | |
| } |
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
| // Here’s a 100% deterministic alternative to `Math.random`. Google’s V8 and | |
| // Octane benchmark suites use this to ensure predictable results. | |
| Math.random = (function() { | |
| var seed = 0x2F6E2B1; | |
| return function() { | |
| // Robert Jenkins’ 32 bit integer hash function | |
| seed = ((seed + 0x7ED55D16) + (seed << 12)) & 0xFFFFFFFF; | |
| seed = ((seed ^ 0xC761C23C) ^ (seed >>> 19)) & 0xFFFFFFFF; | |
| seed = ((seed + 0x165667B1) + (seed << 5)) & 0xFFFFFFFF; |
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
| /** | |
| * Convert From/To Binary/Decimal/Hexadecimal in JavaScript | |
| * https://gist.github.com/faisalman | |
| * | |
| * Copyright 2012-2015, Faisalman <fyzlman@gmail.com> | |
| * Licensed under The MIT License | |
| * http://www.opensource.org/licenses/mit-license | |
| */ | |
| (function(){ |
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
| // Determine if an element is in the visible viewport | |
| function isInViewport(element) { | |
| var rect = element.getBoundingClientRect(); | |
| var html = document.documentElement; | |
| return ( | |
| rect.top >= 0 && | |
| rect.left >= 0 && | |
| rect.bottom <= (window.innerHeight || html.clientHeight) && | |
| rect.right <= (window.innerWidth || html.clientWidth) | |
| ); |
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
| `use this for which condition` | |
| {}.hasOwnProperty.call(pathParts, part)) | |
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
| vertifyId(id) { | |
| if(id){ | |
| var a = id; | |
| var b = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2]; | |
| var c = 0; | |
| a = a.split(''); | |
| var d = a.pop().toLowerCase(); | |
| a.forEach(function(one, index) { | |
| c += one * b[index] | |
| }); |
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 debounce(func, wait, immediate) { | |
| var timeout; | |
| return function() { | |
| var context = this, args = arguments; | |
| var later = function() { | |
| timeout = null; | |
| if (!immediate) func.apply(context, args); | |
| }; | |
| var callNow = immediate && !timeout; | |
| clearTimeout(timeout); |
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
| curry = f => a => b => f(a, b) | |
| uncurry = f => (a, b) => f(a)(b) | |
| papply = (f, a) => b => f(a, b) |
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
| curryedMultiply = (n) => (m) => n * m | |
| curryedMultiply(3)(4) === 12 // true | |
| multiply = (n, m) => curryedMultiply(n)(m) | |
| multiply(3, 4) === 12 // true |