npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

z-file

v0.5.22

Published

Tools for file streams

Downloads

32

Readme

z-file

npm version Build Status Installs Gitter

Zguillez | Guillermo de la Iglesia

Nodejs tools for file streams

Getting Started

Install

npm i z-file

Usage

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

Read file

zfile.read('./src/data.csv').then((data) => {
  console.log(data);
});

Write file

Will create the path folders if not exits.

zfile.write('./src/data.csv', data).then((data) => {
  console.log(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');
f1.data = 'Hello world!;
f1.save();

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

Creating new file and load content from existing file

let f = zfile.create('./src/newfile.csv');
f.load('./src/oldfile.csv').then(() => {
  f.save().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(() => {
  f.save('./src/newfile.csv').then(() => {
    console.log(f.path); //file is saved on './src/newfile.csv'
  });
});

Tools

Read files on folder

zfile.files('./data').forEach((file) => {
    console.log(file);
  });

Read folders on folder

zfile.folders('./data').forEach((folder) => {
    console.log(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.

License

©2018 Zguillez.io

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

Changelog

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