Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

goods-exporter

Package Overview
Dependencies
Maintainers
2
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

goods-exporter - npm Package Compare versions

Comparing version 0.2.6 to 0.2.7

2

package.json

@@ -14,3 +14,3 @@ {

"name": "goods-exporter",
"version": "0.2.6",
"version": "0.2.7",
"description": "A versatile JavaScript library for exporting goods data to various formats such as YML, CSV, and Excel. Simplify data export tasks with ease.",

@@ -17,0 +17,0 @@ "main": "./dist/cjs/index.cjs",

@@ -23,2 +23,5 @@ # goods-exporter

- Excel
- TgShop
- Insales
- Tilda

@@ -35,31 +38,42 @@ ## Installation

## Usage
## Quick start
```typescript
import {GoodsExporter, Formatters, Transformer, Category, Currency, Product, Vat} from "goods-exporter";
import { GoodsExporter, Product, Category, YMLFormatter } from '../src'
// Create an instance of the GoodsExporter class.
const exporter = new GoodsExporter()
const products: Product[] = [] // Put your products;
const categories: Category[] = [{ id: 1, name: 'Обувь' }]
// Call the data export method.
exporter.export(products, categories)
```
## Example
```typescript
import fs from "fs"; // Import the 'fs' module for file writing.
// Create an instance of the GoodsExporter class.
const exporter = new GoodsExporter();
const exporter = new GoodsExporter()
// Define an object 'transformers' that contains data transformation functions.
const transformers: Record<string, Transformer> = {
PRICE: (product) => ({
const transformers: Transformer[] = [
(product) => ({
...product,
price: product.price + 10000
}),
IMAGE: (product) => ({
(product) => ({
...product,
images: product.images?.map(image => image.replace("image", "pic"))
})
}
]
// Define an array 'keys' that contains the transformation keys you want to apply.
const keys = ["PRICE"];
// Set the formatter for exporting data to YML.
exporter.setFormatter(Formatters.YML);
exporter.setFormatter(new YMLFormatter()) // or your own Formatter;
// Set transformers based on the specified keys.
exporter.setTransformers(keys.map(key => transformers[key]));
exporter.setTransformers(transformers);

@@ -66,0 +80,0 @@ // Set an exporter that saves the data to the "output.yml" file.

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc