fssf
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

fssf

provides a simple api for common file based operations

NPM Version License: ISC Node.js Version Build

Promise based wrapper for node:fs

handles .csv files

handles .json files

no external dependencies

contains opinionated conveniences

Installation

npm install fssf

Usage

// commonJS
const { ff } = require('fssf');
// es6 module
import { ff } from 'fssf'
const data = { arrayList: [[1, 1], [2, 2]] };
// JSON
await ff.writeJson(data, __dirname, 'file.json');
const obj = await ff.readJson(__dirname, 'file.json');

// CSV
await ff.writeCsv(obj.arrayList, ['header1', 'header2'], __dirname, 'file.csv');
const doubleArray = await ff.readCsv(__dirname, 'file.csv');

const objList = [
  {
    header1: 'value1',
    header2: 'value2',
  },
  {
    header2: 'value4',
  }
]

await ff.objToCsv(objList, __dirname, 'file.tsv', '\t');

// GENERAL
const stringValue = 'class is called ff, but library is called fssf';
await ff.write(stringValue, __dirname, 'file.txt');

API

path return formatted path as string

touch create empty file at path

mv moves all files and directories from one dir to another and deletes src directory

rename renames a single file

rmrf deletes dir with subdirs and files

cp copies dir contents recursively to another dir

read gets file contents as string

write creates and saves file at expected location

readdir recursively read directory and return array of names

mkdir creates directory at given path

append adds data to existing file

stat returns stat object in promise

readJson returns Object from file containing json

writeJson writes json to a file from an object

readCsv returns double array from csv file

writeCsv takes double array and writes to csv file

appendCsv adds lines to existing csv file

csvToObj returns Array of Objects representing csv file data

objToCsv takes object and writes to csv file

Readme

Keywords

Package Sidebar

Install

npm i fssf

Weekly Downloads

0

Version

1.1.0

License

ISC

Unpacked Size

50.5 kB

Total Files

11

Last publish

Collaborators

  • adotland