IO(file, optsopt)

File I/O manager.

Constructor

new IO(file, optsopt)

Parameters:
Name Type Description
file string

File to read/write

optsopt object

Options

Properties
Name Type Default Description
backupopt boolean true

Whether to create a backup before overwrite

backupExtopt string '.bak'

Backup file extension

Source:
IO.js, line 8

Classes

IO

Methods

read(optsopt)string

Reads the data from the file.

Parameters:
Name Type Description
optsopt object

Option to pass to fs.readFileSync()

Source:
IO.js, line 38
Returns:

Data

Type:
string

setFile(file)IO

Sets the file to IO#load and IO#save.

Parameters:
Name Type Description
file string

File path

Source:
IO.js, line 29
Returns:

Itself

Type:
IO

write(data, optsopt)IO

Writes the given data on the file.
If options.backup is true, creats a backup before overwrite.

Parameters:
Name Type Description
data string

Data to write

optsopt object

Option to pass to fs.writeFileSync()

Source:
IO.js, line 48
Returns:

Itself

Type:
IO