improving module structure and naming
This commit is contained in:
24
src/utils.js
24
src/utils.js
@@ -1,6 +1,13 @@
|
||||
|
||||
export function noop() {};
|
||||
|
||||
// hypotenuse factor of isoscelese right triangle
|
||||
export const sqrt2 = Math.sqrt(2);
|
||||
|
||||
// short width factor given the lenght of a hexagon's side
|
||||
// (2*S gives long width)
|
||||
export const sqrt3 = Math.sqrt(3);
|
||||
|
||||
export function throttleEvent(type, name, obj) {
|
||||
obj = obj || window;
|
||||
let running = false;
|
||||
@@ -25,21 +32,16 @@ export function clone(obj) {
|
||||
return JSON.parse(JSON.stringify(obj));
|
||||
}
|
||||
|
||||
export function extend(obj, src) {
|
||||
for (let key in src) {
|
||||
if (src.hasOwnProperty(key)) obj[key] = src[key];
|
||||
}
|
||||
export function extend(obj, ...sources) {
|
||||
sources.forEach(src => {
|
||||
for (let key in src) {
|
||||
if (src.hasOwnProperty(key)) obj[key] = src[key];
|
||||
}
|
||||
});
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
// hypotenuse factor of isoscelese right triangle
|
||||
export let sqrt2 = Math.sqrt(2);
|
||||
|
||||
// short width factor given the lenght of a hexagon's side
|
||||
// (2*S gives long width)
|
||||
export let sqrt3 = Math.sqrt(3);
|
||||
|
||||
export function hypotenuse(a, b) {
|
||||
if (b == null) b = a;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user