2.0.2 • Published 2 years ago

ptm-fs v2.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Node fs-module some usages


node-js


About

Native Node.js file system module learning outcomes , esm only.


Install

npm i ptm-fs

Usage

watch

dir : An array of directories to watch

    import nodefs from 'ptm-fs';

    nodefs.watch({
    dir: ['app']
    });

lastUpdate

path : Path to file - Return Formated date string for last update of a file.

    import nodefs from 'ptm-fs';

   const date = nodefs.lastUpdate(path);

getFile

path : Array - Path to directory - ext : Array - File extension - Return: array of files

getParent

path : Path to a file - Return : parent path of file

    import nodefs from 'ptm-fs';

    // Return array of files
    const files = await nodefs.getFile({
        path: ['app'],
        ext: ['md']
    });

    const parent =  nodefs.getParent('path_to_file');

mkdir - mkdirSync - remove - removeSync - unlink

path : Path to directory - Return : Make directory . Remove/Delete directory or file.

    import nodefs from 'ptm-fs';

    // Make Directory
    await nodefs.mkdir(path);
    nodefs.mkdirSync(path);

    // Remove  - directory or file
    await nodefs.remove(path);
    nodefs.removeSync(path);
    await nodefs.unlink(path);

readFile - readFileSync

path : Path to file - Return : Content of file

    import nodefs from 'ptm-fs';

    const fileContent = await nodefs.readFile(path);
    const fileContent = nodefs.readFileSync(path);

writeFile - writeFileSync

filePath : Path to file - data : Content to write - Return : Content of file

    import nodefs from 'ptm-fs';

    await nodefs.writeFile(filePath, data);
    nodefs.writeFileSync(filePath, data);

copy - copySync

src : path of the source - dest : path of the destination

    import nodefs from 'ptm-fs';

    await nodefs.copy(src, dest);
    nodefs.copySync(src, dest);

isDir - isFile

path : Path to file - Return : Boolean

    import nodefs from 'ptm-fs';

    nodefs.isDir(path)
    nodefs.isFile(path)

2.0.2

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.0.0

2 years ago