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
(() => { | |
const delay = (time=1000) => { | |
return new Promise((resolve, reject) => { | |
if(typeof time !== 'number') return reject(new Error('wrong type')); | |
setTimeout(() => { | |
return resolve(`waited ${time}ms`); | |
}, time); | |
}); | |
}; |
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 Todos extends Component { | |
componentDidMount() { | |
const {getTodos} = this.props; | |
getTodos(); | |
} | |
/* ... */ | |
} |
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
import ReactDOM from 'react-dom'; | |
import React from 'react'; | |
const toCamelCase = data => { | |
let str = ''; | |
data.split('-').forEach((part, i) => { | |
if(i > 0) str += (part.charAt(0).toUpperCase() + part.substr(1, part.length)); | |
else str += part; |
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
export const buildFormData = (form, data={}) => { | |
let fd = form ? new FormData(form) : new FormData(); | |
for(let key in data){ | |
fd.append(key, data[key]); | |
} | |
return fd; | |
}; |
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
export const fetchAndMerge = arr => { | |
return Promise.all(arr) | |
.then(data => Object.assign({}, ...data)); | |
}; |
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
const stringToHTML = (string, ...values) => { | |
var str = ''; | |
for(let i = 0; i < string.length; i++){ | |
if(string[i]) str += string[i]; | |
if(values[i]) str += values[i]; | |
} | |
let doc = new DOMParser().parseFromString(str.trim(), 'text/html'); |
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
var elements = [...document.getElementsByTagName("*")].filter((el) => { | |
for(var key in el.dataset){ | |
if(key.startsWith('col-')){ | |
return true | |
} | |
} | |
return 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
var elements = [].filter.call( | |
document.getElementsByTagName("*"), function(el){ | |
for(var key in el.dataset){ | |
if(key.indexOf('col-') === 0){ | |
console.log(el); | |
return true | |
} | |
} |
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
//abusing templating strings part 1. | |
function _checkStatus(response){ | |
if(response.status >= 200 && response.status < 300){ | |
return response; | |
}else{ | |
var error = new Error(response.statusText); | |
throw error; | |
} | |
} |
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
@define-mixin border-box-default{ | |
html { | |
box-sizing: border-box; | |
} | |
*, *:before, *:after { | |
box-sizing: inherit; | |
} | |
} |