fobject

WebJar for fobject

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

fobject
Last Version

Last Version

0.0.3
Release Date

Release Date

Type

Type

jar
Description

Description

fobject
WebJar for fobject
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/slang800/fobject

Download fobject

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/fobject/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>fobject</artifactId>
    <version>0.0.3</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/fobject/
implementation 'org.webjars.npm:fobject:0.0.3'
// https://jarcasting.com/artifacts/org.webjars.npm/fobject/
implementation ("org.webjars.npm:fobject:0.0.3")
'org.webjars.npm:fobject:jar:0.0.3'
<dependency org="org.webjars.npm" name="fobject" rev="0.0.3">
  <artifact name="fobject" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='fobject', version='0.0.3')
)
libraryDependencies += "org.webjars.npm" % "fobject" % "0.0.3"
[org.webjars.npm/fobject "0.0.3"]

Dependencies

compile (3)

Group / Artifact Type Version
org.webjars.npm : graceful-fs jar [3.0.2,4)
org.webjars.npm : semver jar [4.1.0,5)
org.webjars.npm : when jar [3.0.1,4)

Project Modules

There are no modules declared in this project.

fobject

Build Status NPM version NPM license

A simple promise-based wrapper for file operations that treats files as objects.

File = require 'fobject'
configFile = new File('config.json')
configFile.read().done((data) ->
	console.log "contents of #{configFile.path}: #{data}"
)

why?

The default fs module has a really ugly interface (including sync and async copies of almost every function) and doesn't make it easy to work with files that may or may not actually be written to the file-system. fobject abstracts out interaction with the file system so if you want to implement caching, or work with files without writing them to the disk, or whatever else you want: you can do so easily.

docs

new File(path)

Parameters:
Name Type Argument Default Description
path String

The path to the file. This will be resolved to an absolute path, so even if you change your cwd you can still access the same file.

options.base String <optional>
./

Used for relative pathing. This will not be resolved to an absolute path. Typically where a glob starts.

Source:

append(data) → {Promise}

Append data to the file

Parameters:
Name Type Argument Default Description
data String | Buffer
options.encoding String | null <optional>
'utf8'

ignored if data is a buffer

options.mode Number <optional>
438

default is 0666 in Octal

options.flag String <optional>
'w'
Source:
Returns:
Type
Promise

dirname() → {String}

Get the dirname of the file

Source:
Returns:
Type
String

extname() → {String}

Get the extension of a file

Source:
Returns:
Type
String

read() → {Promise}

Read from the file

Parameters:
Name Type Argument Default Description
options.encoding String | null <optional>
null
options.flag String <optional>
'r'
Source:
Returns:
Type
Promise

rename(newPath) → {Promise}

Rename the file

Parameters:
Name Type Description
newPath String

The new path for the file. Will be resolved relative to File.base.

Source:
Returns:
Type
Promise

stat() → {Promise}

Return a Stat object for the file

Source:
Returns:
Type
Promise

Delete the file

Source:
Returns:
Type
Promise

write(data) → {Promise}

Write data to the file

Parameters:
Name Type Argument Default Description
data String | Buffer
options.encoding String | null <optional>
'utf8'

ignored if data is a buffer

options.mode Number <optional>
438

default is 0666 in Octal

options.flag String <optional>
'w'
Source:
Returns:
Type
Promise

generated with docme

Versions

Version
0.0.3