You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
777 B
23 lines
777 B
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.roundPath = roundPath;
|
|
/**
|
|
* Rounds the values of a `PathArray` instance to
|
|
* a specified amount of decimals and returns it.
|
|
*/
|
|
function roundPath(path, round) {
|
|
if (round === 'off')
|
|
return [].concat(path);
|
|
// to round values to the power
|
|
// the `round` value must be integer
|
|
var pow = typeof round === 'number' && round >= 1 ? Math.pow(10, round) : 1;
|
|
return path.map(function (pi) {
|
|
var values = pi
|
|
.slice(1)
|
|
.map(Number)
|
|
.map(function (n) { return (round ? Math.round(n * pow) / pow : Math.round(n)); });
|
|
// @ts-ignore
|
|
return [pi[0]].concat(values);
|
|
});
|
|
}
|
|
//# sourceMappingURL=round-path.js.map
|