goods-exporter
A versatile JavaScript library for exporting goods data to various formats such as YML, CSV, and Excel. Simplify data
export tasks with ease.
Features
- Export goods data to YML, CSV, and Excel formats.
- Easily integrate into your JavaScript projects.
- Compatible with Node.js version 16 and above.
- Comprehensive TypeScript type definitions included.
Supported formats
- YML (Yandex Market Language)
- CSV
- Excel
- TgShop
- Insales
- Tilda
Installation
To use goods-exporter
in your project, simply add it to your dependencies using npm or yarn:
npm install goods-exporter --save
yarn add goods-exporter
Quick start
import { GoodsExporter, Product, Category, YMLFormatter } from '../src'
const exporter = new GoodsExporter()
const products: Product[] = []
const categories: Category[] = [{ id: 1, name: 'Обувь' }]
exporter.export(products, categories)
Example
import fs from "fs";
const exporter = new GoodsExporter()
const transformers: Transformer[] = [
(product) => ({
...product,
price: product.price + 10000
}),
(product) => ({
...product,
images: product.images?.map(image => image.replace("image", "pic"))
})
]
exporter.setFormatter(new YMLFormatter())
exporter.setTransformers(transformers);
exporter.setExporter((data: Buffer) => {
fs.writeFileSync("output.yml", data);
return data;
});
exporter.export<Buffer>(products, categories)
.then(data => {
});