new File(path)
Parameters:
| Name | Type | Argument | Default | Description |
|---|---|---|---|---|
path | String | The path to the file. This will be resolved to an | ||
options.base | String | <optional> | ./ | Used for relative pathing. This will not |
A simple promise-based wrapper for file operations that treats files as objects.
npm install fobjectA simple promise-based wrapper for file operations that treats files as objects.
``coffee``
File = require 'fobject'
configFile = new File('config.json')
configFile.read().done((data) ->
console.log "contents of #{configFile.path}: #{data}"
)
| Name | Type | Argument | Default | Description |
|---|---|---|---|---|
path | String | The path to the file. This will be resolved to an | ||
options.base | String | <optional> | ./ | Used for relative pathing. This will not |
Append data to the file
| Name | Type | Argument | Default | Description |
|---|---|---|---|---|
data | String | Buffer | |||
options.encoding | String | null | <optional> | 'utf8' | ignored if data is a |
options.mode | Number | <optional> | 438 | default is 0666 in Octal |
options.flag | String | <optional> | 'w' |
Get the dirname of the file
Get the extension of a file
Read from the file
| Name | Type | Argument | Default | Description |
|---|---|---|---|---|
options.encoding | String | null | <optional> | null | |
options.flag | String | <optional> | 'r' |
Rename the file
| Name | Type | Description |
|---|---|---|
newPath | String | The new path for the file. Will be resolved |
Return a Stat object for the file
Delete the file
Write data to the file
| Name | Type | Argument | Default | Description |
|---|---|---|---|---|
data | String | Buffer | |||
options.encoding | String | null | <optional> | 'utf8' | ignored if data is a |
options.mode | Number | <optional> | 438 | default is 0666 in Octal |
options.flag | String | <optional> | 'w' |
generated with docme