This is a simply file utils lib.
npm install file-utils-easy
WARNING: this package has been deprecated, upgrade your Node.js version and use default fs
module instead.
const fue = require('file-utils-easy');
fue.readDirectoryFiles('path/')
.then(files => doSomething(files))
.catch(err => doSomethingElse())
- file-utils-easy
- ~writeToFile(fileContent, filePath) ⇒
Promise.<string>
- ~writeToFileStream(fileStream, filePath) ⇒
Promise
- ~appendToFile(fileContent, filePath) ⇒
Promise.<string>
- ~readFileStats(filePath) ⇒
Promise.<fs.Stats>
- ~readDirectoryFiles(directory) ⇒
Promise.<array>
- ~readFile(filePath, [encoding]) ⇒
Promise.<string>
- ~readJsonFile(filePath) ⇒
Promise.<object>
- ~saveUrlToFile(url, filePath) ⇒
Promise.<string>
- ~deleteFile(filePath) ⇒
Promise.<string>
- ~deleteDirectoryFiles(directory) ⇒
Promise.<array>
- ~renameFile(from, to) ⇒
Promise.<string>
- ~copyFile(from, to) ⇒
Promise.<string>
- ~existFile(filePath) ⇒
Promise.<string>
- ~writeToFile(fileContent, filePath) ⇒
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
For run the tests simply execute:
npm test
Copyright Manuel Spigolon, Licensed under MIT.