0.0.4 • Published 8 months ago
json-csv-files v0.0.4
JSON CSV Files Utility
This npm package provides utility functions to work with JSON and CSV files.
Installation
To install the package, run:
npm install json-csv-files-utility
Usage
Import the functions from the package and use them in your project.
appendToArrayJsonFile
Appends new data to an array in a JSON file.
Parameters:
filePath
(string): The path to the JSON file.newData
(any): The new data to append to the array.
Example
import { appendToArrayJsonFile } from 'json-csv-files-utility';
const filePath = './data.json';
const newData = { id: 2, name: 'Jane Doe' };
appendToArrayJsonFile(filePath, newData)
.then(() => {
console.log('Data appended successfully');
})
.catch((error) => {
console.error('Error appending data:', error);
});
sleep
Pauses execution for a specified number of milliseconds.
Parameters:
ms
(number): The number of milliseconds to pause.
Example
import { sleep } from 'json-csv-files-utility';
async function example() {
console.log('Waiting...');
await sleep(2000);
console.log('Done waiting');
}
example();
License
This project is licensed under the MIT License.