Coder Social home page Coder Social logo

file-utils-easy's Introduction

file-utils-easy

Coverage Status

This is a simply file utils lib.

Installation

npm install file-utils-easy

WARNING: this package has been deprecated, upgrade your Node.js version and use default fs module instead.

Usage

const fue = require('file-utils-easy');

fue.readDirectoryFiles('path/')
  .then(files => doSomething(files))
  .catch(err => doSomethingElse())

API

file-utils-easy~writeToFile(fileContent, filePath) ⇒ Promise.<string>

Write a string to a file

Kind: inner method of file-utils-easy
Returns: Promise.<string> - resolve with the filePath received in input

Param Type Description
fileContent string the payload of the file
filePath string path and filename: where store the file

file-utils-easy~writeToFileStream(fileStream, filePath) ⇒ Promise

Write a stream to a file

Kind: inner method of file-utils-easy
Returns: Promise - resolve with the filePath when the stream finish

Param Type Description
fileStream stream the stream payload
filePath string path and filename: where store the file

file-utils-easy~appendToFile(fileContent, filePath) ⇒ Promise.<string>

Append a string to a file

Kind: inner method of file-utils-easy
Returns: Promise.<string> - resolve with the filePath received in input

Param Type Description
fileContent string the payload of the file
filePath string path and filename: where store the file

file-utils-easy~readFileStats(filePath) ⇒ Promise.<fs.Stats>

Read the metadata of the file

Kind: inner method of file-utils-easy
Returns: Promise.<fs.Stats> - a node fs.Stats that provides information about a file
See: https://nodejs.org/api/fs.html#fs_class_fs_stats

Param Type Description
filePath string path and filename: the file to read

file-utils-easy~readDirectoryFiles(directory) ⇒ Promise.<array>

List the files names of a directory, ignoring directories

Kind: inner method of file-utils-easy
Returns: Promise.<array> - strings names of the files in the input directory

Param Type Description
directory string path of the directory to read

file-utils-easy~readFile(filePath, [encoding]) ⇒ Promise.<string>

Read the content of a file

Kind: inner method of file-utils-easy
Returns: Promise.<string> - resolve with the string content of the file

Param Type Default Description
filePath string path and filename: the file to read
[encoding] string "'utf8'" the encoding file

file-utils-easy~readJsonFile(filePath) ⇒ Promise.<object>

Read the content of a file as a UTF8 string and then parse it as a JSON

Kind: inner method of file-utils-easy
Returns: Promise.<object> - resolve with the JSON content of the file

Param Type Description
filePath string path and filename: the file to read

file-utils-easy~saveUrlToFile(url, filePath) ⇒ Promise.<string>

Save the content of a url to a file

Kind: inner method of file-utils-easy
Returns: Promise.<string> - resolve with the filePath saved

Param Type Description
url string where will be done an HTTP/GET to get the content
filePath string path and filename where store the output of url

file-utils-easy~deleteFile(filePath) ⇒ Promise.<string>

Delete a file from the file system

Kind: inner method of file-utils-easy
Returns: Promise.<string> - resolve with the filePath deleted

Param Type Description
filePath string path and filename: the file to delete

file-utils-easy~deleteDirectoryFiles(directory) ⇒ Promise.<array>

Delete all the files in a directory, applying an optional filter

Kind: inner method of file-utils-easy
Returns: Promise.<array> - resolve with all the files deleted succesfully

Param Type Description
directory string path of the directory to clean

file-utils-easy~renameFile(from, to) ⇒ Promise.<string>

Rename a file to another path

Kind: inner method of file-utils-easy
Returns: Promise.<string> - resolve with the destination filePath

Param Type Description
from string origin path and filename
to string destination path and filename

file-utils-easy~copyFile(from, to) ⇒ Promise.<string>

Copy a file to another path

Kind: inner method of file-utils-easy
Returns: Promise.<string> - resolve with the destination filePath

Param Type Description
from string origin path and filename
to string destination path and filename

file-utils-easy~existFile(filePath) ⇒ Promise.<string>

Check if a file exists

Kind: inner method of file-utils-easy
Returns: Promise.<string> - resolve with the filePath that exists
Throws:

  • error if the file doesn't exist
Param Type Description
filePath string path and filename: the file to control

Test

For run the tests simply execute:

npm test

License

Copyright Manuel Spigolon, Licensed under MIT.

file-utils-easy's People

Contributors

eomm avatar niccord avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

niccord

file-utils-easy's Issues

Implement `append file` method

Please, implement an appendFile method or change the signature of writeToFile adding a parameter in order to decide if append the new string

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.