ml-xy-convert
v1.0.0
Published
Convert between different xy formats
Downloads
17
Keywords
Readme
xy-convert
Convert between different xy formats.
Installation
$ npm install --save ml-xy-convert
Usage
import xyConvert from 'ml-xy-convert';
const xxyyArray = [[1, 1, 1], [2, 2, 2]];
const xxyyObject = { x: [1, 1, 1], y: [2, 2, 2] };
const xyxyArray = [[1, 2], [1, 2], [1, 2]];
const xyxyObject = [{ x: 1, y: 2 }, { x: 1, y: 2 }, { x: 1, y: 2 }];
xyConvert(xxyyArray) === xxyyObject;
xyConvert(xxyyArray, { inputFormat: 'xxyyArray' }) === xxyyObject;
xyConvert(xxyyArray, { outputFormat: 'xyxyObject' }) === xyxyObject;
API Documentation
Structure convention
- xyxyArray:
[[x1, y1], [x2, y2], ... ]
- xxyyArray:
[[x1, x2, ...], [y1, y2, ...]]
- xyxyObject:
[{x: x1, y: y1}, {x: x2, y: y2}, ...]
- xxyyObject:
{x:[x1, x2, ...], y:[y1, y2, ...]}