New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

io-extra

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

io-extra

Library to simplify file system access with promises in Node.js (Node version > 4.3.2)

  • 0.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
increased by100%
Maintainers
1
Weekly downloads
 
Created
Source

io-extra

Library to simplify file system access with promises in Node.js (Node version > 4.3.2)

npm Package

NOTE (2016-10-10): Node v4.3.2 or newer is required (builtin promises).

Installation

npm install --save io-extra

Usage

const io = require('io-extra');

io.file.exists('/tmp/myfile').then((exists) => {
    if (exists) {
        console.log(`File exists`);
    }
}

File Methods Directory Methods

File

resolve fullpath

path(file)

Returnes the resolved full path of a file. The file must exist.

const io = require('io-extra');

io.file.path('/tmp/myfile').then((file) => console.log('fullpath: ' + file));
// returns c:\tmp\myfile on Windows operating systems

file exists

exists(file)

Check if a file exists. Promise returns true or false whether the file exists or not.

Example:

const io = require('io-extra');

io.file.exists('/tmp/myfile').then((exists) => console.log('file exists: ' + exists));

create file

create(file)

Creates a file if it doesn't already exist. If the file is in directories that do not exist, these directories are created. Promise returns the full path of the created file.

Example:

const io = require('io-extra');

io.file.create('/tmp/myfile').then((file) => console.log('file ' + file + ' created.'));

remove file

remove(file)

Removes a file if it exists. Empty promise is returned.

Example:

const io = require('io-extra');

io.file.remove('/tmp/myfile').then(() => console.log('file removed.'));

Directory

resolve fullpath

path(directory)

Returnes the resolved full path of a directory. The directory must exist.

const io = require('io-extra');

io.directory.path('/tmp').then((dir) => console.log('fullpath: ' + dir));
// returns c:\tmp on Windows operating systems

directory exists

exists(directory)

Check if a directory exists. Promise returns true or false whether the directory exists or not.

Example:

const io = require('io-extra');

io.directory.exists('/tmp').then((exists) => console.log('directory exists: ' + exists));

create directory

create(directory)

Creates a directory if it doesn't already exist. If the parent directory does not exist, it is created. Promise returns the full path of the created directory.

Example:

const io = require('io-extra');

io.directory.create('/tmp').then((dir) => console.log('directory ' + dir + ' created.'));

remove directory

remove(directory)

Removes a directory if it exists. Empty promise is returned.

Example:

const io = require('io-extra');

io.directory.remove('/tmp').then(() => console.log('directory removed.'));

FAQs

Package last updated on 12 Oct 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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc