joyent-portal/packages/unitcalc/src/index.js
2017-06-16 21:46:36 +01:00

13 lines
345 B
JavaScript

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;