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
// Timeout Promise wrapper | |
export default function timeoutPromise(timeout, err, promise) { | |
return new Promise(function(resolve,reject) { | |
promise.then(resolve,reject); | |
setTimeout(reject.bind(null,err), 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
/** | |
* | |
* @param items An array of items. | |
* @param fn A function that accepts an item from the array and returns a promise. | |
* @returns {Promise} | |
*/ | |
export default function forEachPromise(items = [], fn = Promise.resolve) { | |
return items.reduce( | |
(promise, item) => promise.then(() => fn(item)), | |
Promise.resolve() |
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
import styled from 'styled-components'; | |
const Toggle = styled.input` | |
-moz-appearance: none; | |
-webkit-appearance: none; | |
-o-appearance: none; | |
position: relative; | |
height: 20px; | |
width: 40px; | |
border-radius: 10px; |
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
import indexedDB from './indexedDB' | |
if (!indexedDB) { | |
// console.log("Your browser does not support a stable version of IndexedDB. Some features will not be available.") | |
} | |
const DATABASE_NAME = 'db_name'; | |
const READ_WRITE_PERMISSION = 'readwrite'; | |
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://stackoverflow.com/a/26227662 | |
const singleton = Symbol(); | |
const singletonEnforcer = Symbol() | |
class SingletonClass { | |
constructor(enforcer) { | |
if(enforcer != singletonEnforcer) throw "Cannot construct singleton"; | |
} |
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
const elements = [ | |
'animate', | |
'circle', | |
'defs', | |
'ellipse', | |
'g', | |
'line', | |
'linearGradient', | |
'mask', | |
'path', |
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
import { css } from 'styled-components'; | |
const sizes = { | |
big: 1600, | |
desktop: 1024, | |
laptop: 768, | |
tablet: 430, | |
}; | |
// taken from: https://github.com/styled-components/styled-components/blob/master/docs/tips-and-tricks.md#media-templates |
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
/** | |
* Checks if the passed element is dom object or not | |
* @param element | |
* @returns {boolean} | |
*/ | |
function isDomElement(element) { | |
return element && typeof element === 'object' && 'nodeType' in element; | |
}; |
OlderNewer