improving module structure and naming

This commit is contained in:
Gavin McDonald
2016-02-19 14:28:15 -05:00
parent 42ca0b6e4b
commit a2479f2d2f
3 changed files with 35 additions and 33 deletions

View File

@@ -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;