Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fobject

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fobject

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

  • 0.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9.6K
increased by76.72%
Maintainers
1
Weekly downloads
 
Created
Source

fobject

Build Status

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}"
)

Also, this includes a 2nd wrapper that extends the first and lets you cache the contents of the file directly in the object

File = require 'fobject/cached'
logFile = new File('log')
logFile.load().then( ->
  console.log logFile.content # print out the logs
  logFile.content += 'this is a demo\n' # add a line
).then(
  logFile.save
).done( ->
  console.log('the logs are saved, and since we only added to the string, the
  `File.save()` call was optimized into a single `append()`')
)

docs

Read the source code for now... it's all well annotated in JSDoc.

Keywords

FAQs

Package last updated on 05 Jun 2014

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