https://github.com/mljs/xy-convert
Convert between different xy formats.
https://github.com/mljs/xy-convert
Last synced: 27 days ago
JSON representation
Convert between different xy formats.
- Host: GitHub
- URL: https://github.com/mljs/xy-convert
- Owner: mljs
- License: mit
- Created: 2018-02-09T10:08:27.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-02-11T15:32:24.000Z (over 8 years ago)
- Last Synced: 2025-09-22T21:55:47.720Z (9 months ago)
- Language: JavaScript
- Homepage:
- Size: 1.22 MB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: History.md
- License: LICENSE
Awesome Lists containing this project
README
# xy-convert
[![NPM version][npm-image]][npm-url]
[![build status][travis-image]][travis-url]
[![Test coverage][codecov-image]][codecov-url]
[![npm download][download-image]][download-url]
Convert between different xy formats.
## Installation
`$ npm install --save ml-xy-convert`
## Usage
```js
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](https://mljs.github.io/xy-convert/)
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](./LICENSE)
[npm-image]: https://img.shields.io/npm/v/ml-xy-convert.svg?style=flat-square
[npm-url]: https://www.npmjs.com/package/ml-xy-convert
[travis-image]: https://img.shields.io/travis/mljs/xy-convert/master.svg?style=flat-square
[travis-url]: https://travis-ci.org/mljs/xy-convert
[codecov-image]: https://img.shields.io/codecov/c/github/mljs/xy-convert.svg?style=flat-square
[codecov-url]: https://codecov.io/gh/mljs/xy-convert
[download-image]: https://img.shields.io/npm/dm/ml-xy-convert.svg?style=flat-square
[download-url]: https://www.npmjs.com/package/ml-xy-convert