util.js 291 字节
Newer Older
J
Jason Park 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
const classes = (...arr) => arr.filter(v => v).join(' ');

const serialize = object => JSON.parse(JSON.stringify(object));

const distance = (a, b) => {
  const dx = a.x - b.x;
  const dy = a.y - b.y;
  return Math.sqrt(dx * dx + dy * dy);
};

export {
  classes,
  serialize,
  distance,
};