Nodejs tools for file streams
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


npm version Build Status Installs Gitter

Zguillez | Guillermo de la Iglesia

Nodejs tools for file streams

Getting Started


npm i z-file


const zfile = require('z-file');

Read file'./src/data.csv').then((data) => {

Write file

Will create the path folders if not exits.

zfile.write('./src/data.csv', data).then((data) => {

Replace string in file

Will create the path folders if not exits.

file.replace('./package.json', '0.4.2', '0.4.3');

Check if folder exists

console.log( zfile.folder('./src/data') ); //true or false

Create folder if not exists

console.log( zfile.folder('./src/data', true) ); //true

Check if file exists

console.log( zfile.file('./src/data.txt') ); //true or false

Create file if not exists

console.log( zfile.file('./src/data.txt', true) ); //true

Remove all files in a folder

console.log( zfile.clean('./src/data') );
console.log( zfile.clean(['./src/data', './src/assets']) );

Remove a folder

console.log( zfile.remove('./src/data') );
console.log( zfile.remove(['./src/data', './src/assets']) );

Use as object

let f1 = zfile.create('./data/file.txt'); = 'Hello world!;;

let f2 = zfile.create();
f2.load(f1.path).then(() => { = 'Bye wold!';

Creating new file and load content from existing file

let f = zfile.create('./src/newfile.csv');
f.load('./src/oldfile.csv').then(() => { => {
    console.log(f.path); //file is saved on './src/newfile.csv'

Saving as a new file

let f = zfile.create();
f.load('./src/file.csv').then(() => {'./src/newfile.csv').then(() => {
    console.log(f.path); //file is saved on './src/newfile.csv'


Read files on folder

zfile.files('./data').forEach((file) => {

Read folders on folder

zfile.folders('./data').forEach((folder) => {

Create a PNG image from a PSD file

zfile.psdToPng('300x250.psd', '300x250.png')
  .then(() => console.log('Done!'))
  .catch((err) => console.log(err));

Create a JPEG image from a PSD file

zfile.psdToJpg('300x250.psd', '300x250.jpg', 80)
  .then(() => console.log('Done!'))
  .catch((err) => console.log(err));

Create a dummy JPEG or GIF image

zfile.dummy(300, 250, '#FF2200', 'dummy.jpg');
zfile.dummy(300, 250, '#FF2200', 'dummy.gif');

Contributing and issues

Contributors are welcome, please fork and send pull requests! If you have any ideas on how to make this project better then please submit an issue or send me an email.



Original code licensed under MIT Open Source projects used within this project retain their original licenses.


v0.5.0 (November 25, 2018)

  • Create PNG and JPEG images from PSD file
  • Create dummy JPEG and GIF images

v0.4.0 (November 20, 2018)

  • Replace string on files function

v0.3.0 (January 27, 2017)

  • Read files and folders functions

v0.2.0 (January 21, 2017)

  • Core update with ES6 classes

v0.1.0 (January 12, 2017)

  • Basic implementation for file