You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

fsos

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fsos

A file system object storage.

1.1.6
latest
Source
npmnpm
Version published
Weekly downloads
67
-49.62%
Maintainers
1
Weekly downloads
 
Created
Source
                              ┌──────────┒
                              │   fsos   ┃
                              ┕━━━━┯━━━━━┛
                                   │
                    ╭──────────────┴───────────────╮
                    │ A file system object storage │
                    ╰──────────────────────────────╯

File system IO can be hard to get right. This library offers a simpler interface to common operations expected from an object storage. It stays as close to the file system as humanly possible.

var fsos = require('fsos')
var user = { nick: 'jade', firstName: 'Jackie', lastName: 'Dent'}
fsos.set('user/' + user.nick, JSON.stringify(user)).then(function() {
  return fsos.get('user/' + user.nick)
}).then(function(value) {
  console.log(value)
})

If an object is set successfully, all subsequent gets will return the value that was set until the object is reset.

If an object is set non-successfully, all subsequent gets will return the value it had prior, if any, until the object is reset.

It should stay consistent even if the application crashes or if multiple processes write to the same files. If the system crashes, it is likely to stay consistent, but that depends on the file system.

API

set(key, value) → Promise

Sets the value at that key. It is stored directly on a file (treating the key as a path, automatically creating folders as needed). The value can be a Buffer, a String, or a JSON-serializable object. Folders (eg. foo if something was set to foo/bar) cannot contain data.

get(key) → Promise

Reads the value at that key. Yields an error if the key does not exist.

delete(key) → Promise

Ensures that a subsequent get yields an error.

Notes

exists (to get a boolean describing whether there is data at a key) is left out. Indeed, that information does not guarantee that there will be data at that key for your next operation, as other processes may have modified it.

Keywords

file

FAQs

Package last updated on 09 Jun 2019

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.