🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

file-async

Package Overview
Dependencies
Maintainers
5
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

file-async

fs-extra + bluebird promisify

0.2.0
latest
Source
npm
Version published
Weekly downloads
26
44.44%
Maintainers
5
Weekly downloads
 
Created
Source

file-async

NPM

Build Status

  • All functions from fs and fs-extra to use with Promises
  • No more blocking code.
  • bluebird's promisified
  • exists() is fixed

Install with npm

$ npm install --save file-async

Usage

var fsAsync = require('file-async');

var TMP_FILE_PATH = '/tmp/file_content.js';
// "touch" a new empty file
return fsAsync.createFile(TMP_FILE_PATH).then(function () {
  // get stats
  return fsAsync.stat(TMP_FILE_PATH);
})
.then(function(file_stat) {
  // check is it is a file
  console.log(TMP_FILE_PATH, 'is a file?', file_stat.isFile());
})
.then(function() {
  // remove tmp file
  return fsAsync.remove(TMP_FILE_PATH);
})
.then(function() {
  // exists?
  return fsAsync.exists(TMP_FILE_PATH);
})
.then(function(file_exists) {
  // check again
  console.log(TMP_FILE_PATH, 'is a file?', file_exists);
});

Functions

async functions (Promises)

  • access
  • appendFile
  • chmod
  • chown
  • close
  • copy
  • createFile
  • createOutputStream
  • createReadStream
  • createWriteStream
  • delete
  • emptyDir
  • emptydir
  • ensureDir
  • ensureFile
  • exists
  • fchmod
  • fchown
  • fdatasync
  • FileReadStream
  • FileWriteStream
  • fstat
  • fsync
  • ftruncate
  • futimes
  • lchmod
  • lchown
  • link
  • lstat
  • lutimes
  • mkdir
  • mkdirp
  • mkdirs
  • move
  • open
  • outputFile
  • outputJson
  • outputJSON
  • read
  • readdir
  • readFile
  • readJson
  • readJSON
  • readJsonFile
  • readJSONFile
  • readlink
  • ReadStream
  • realpath
  • remove
  • rename
  • rmdir
  • stat
  • Stats
  • symlink
  • truncate
  • unlink
  • unwatchFile
  • utimes
  • watch
  • watchFile
  • write
  • writeFile
  • writeJson
  • writeJSON
  • writeJsonFile
  • writeJSONFile
  • WriteStream

callback node.js old callback way (do use this)

accessCallback, appendFileCallback, chmodCallback, chownCallback, closeCallback, copyCallback, createFileCallback, createOutputStreamCallback, createReadStreamCallback, createWriteStreamCallback, deleteCallback, emptyDirCallback, emptydirCallback, ensureDirCallback, ensureFileCallback, existsCallback, fchmodCallback, fchownCallback, fdatasyncCallback, FileReadStreamCallback, FileWriteStreamCallback, fstatCallback, fsyncCallback, ftruncateCallback, futimesCallback, lchmodCallback, lchownCallback, linkCallback, lstatCallback, lutimesCallback, mkdirCallback, mkdirpCallback, mkdirsCallback, moveCallback, openCallback, outputFileCallback, outputJsonCallback, outputJSONCallback, readCallback, readdirCallback, readFileCallback, readJsonCallback, readJSONCallback, readJsonFileCallback, readJSONFileCallback, readlinkCallback, ReadStreamCallback, realpathCallback, removeCallback, renameCallback, rmdirCallback, statCallback, StatsCallback, symlinkCallback, truncateCallback, unlinkCallback, unwatchFileCallback, utimesCallback, watchCallback, watchFileCallback, writeCallback, writeFileCallback, writeJsonCallback, writeJSONCallback, writeJsonFileCallback, writeJSONFileCallback, WriteStreamCallback

sync functions (blocking code - do use this)

accessSync, existsSync, readFileSync, closeSync, openSync, readSync, writeSync, renameSync, truncateSync, ftruncateSync, rmdirSync, fdatasyncSync, fsyncSync, mkdirSync, readdirSync, fstatSync, lstatSync, statSync, readlinkSync, symlinkSync, linkSync, unlinkSync, fchmodSync, chmodSync, fchownSync, chownSync, utimesSync, futimesSync, writeFileSync, appendFileSync, realpathSync, lutimesSync, lchownSync, lchmodSync, copySync, removeSync, deleteSync, mkdirsSync, mkdirpSync, createFileSync, ensureFileSync, ensureDirSync, outputFileSync, readJsonFileSync, readJSONFileSync, readJsonSync, readJSONSync, outputJsonSync, outputJSONSync, writeJsonFileSync, writeJSONFileSync, writeJsonSync, writeJSONSync, emptyDirSync, emptydirSync

CONTRIBUTING

  • Install/Update dependencies:

    $ npm install --save-dev azk-dev
    $ gulp editor:config
    $ gulp babel:runtime:install
    $ npm install
    
  • Commit

    $ git add .
    $ git commit -m 'Updated azk-dev.'
    

azk-dev

Show all gulp tasks:

$ gulp help

Tests

# default (lint + test, no watch)
$ gulp lint test

# test + lint + watch
$ gulp watch:lint:test

# test + watch (no-lint)
$ gulp watch:test

Deploy npm package

You can deploy package with:

$ npm run deploy [<newversion> | major | minor | patch | premajor | preminor | prepatch | prerelease]

This should run the following steps:

  • Check if not tracked commits in git
  • Run tests with npm test
  • Upgrade version in package.json, commit and add tag
  • Publish package in npmjs.com

Keywords

fs

FAQs

Package last updated on 05 Jan 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts