ml-xy-convert

1.0.0 • Public • Published

xy-convert

NPM version build status Test coverage npm download

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, ...]}

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i ml-xy-convert

Weekly Downloads

2

Version

1.0.0

License

MIT

Unpacked Size

12 kB

Total Files

9

Last publish

Collaborators

  • mljs-bot
  • stropitek
  • targos
  • lpatiny
  • maasencioh