1
0
mirror of https://github.com/yldio/copilot.git synced 2024-11-15 07:40:07 +02:00
copilot/packages/unitcalc/src/index.js

13 lines
345 B
JavaScript
Raw Normal View History

2017-06-16 23:46:36 +03:00
const flatten = require('lodash.flatten');
const remcalc = require('remcalc');
const BASE = 6;
const calc = (base, ...values) =>
flatten(values.map(value => String(value).split(/\s/gim)))
.map(value => remcalc(Number(value) * base))
.join(' ');
module.exports = (...values) => calc(BASE, ...values);
module.exports.withBase = calc;