2016-05-02 08:51:47 +03:00
|
|
|
let lastId = 0;
|
|
|
|
export function uniqueId(prefix = 'id') {
|
|
|
|
return `${prefix}${++lastId}`;
|
|
|
|
}
|
2016-07-29 20:14:52 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {object} obj
|
|
|
|
* @param {array} keys
|
|
|
|
*
|
|
|
|
* @return {object}
|
|
|
|
*/
|
|
|
|
export function omit(obj, keys) {
|
|
|
|
const newObj = {...obj};
|
|
|
|
|
|
|
|
keys.forEach((key) => {
|
|
|
|
Reflect.deleteProperty(newObj, key);
|
|
|
|
});
|
|
|
|
|
|
|
|
return newObj;
|
|
|
|
}
|
2016-07-31 16:53:16 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Asynchronously loads script
|
|
|
|
*
|
|
|
|
* @param {string} src
|
|
|
|
*
|
|
|
|
* @return {Promise}
|
|
|
|
*/
|
|
|
|
export function loadScript(src) {
|
|
|
|
const script = document.createElement('script');
|
|
|
|
|
|
|
|
script.async = true;
|
|
|
|
script.defer = true;
|
|
|
|
script.src = src;
|
|
|
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
script.onlaod = resolve;
|
|
|
|
script.onerror = reject;
|
|
|
|
|
|
|
|
document.body.appendChild(script);
|
|
|
|
});
|
|
|
|
}
|
2016-08-14 12:01:04 +03:00
|
|
|
|
|
|
|
export const rAF = window.requestAnimationFrame || window.mozRequestAnimationFrame
|
|
|
|
|| window.webkitRequestAnimationFrame || window.msRequestAnimationFrame;
|