New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

nfdb

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nfdb

terribly simplistic kv store for local fs

latest
Source
npmnpm
Version
0.1.1
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

nfdb

terribly simplistic kv store for local fs

nfdb

creates a namespace (object) that will be written to disc (and read from disc upon start).

const nfdb = require('nfdb').nfdb;

var myLocalJsonFileStore = nfdb(
  'engagedUserList',                                    // name of the db
  process.cwd() + '/data/engagedUserList.ndfb.json',    // file to save the data in
  {
    saveOnWrite: false,                                 // save data on every data change (this is slow as it's sync and uses JSON.stringify)
    saveInterval: 30000                                 // (additionally) save every X milliseconds .. 
  }
);


myLocalJsonFileStore.set(
  'usernames',
  [
    'user1',
    'user2'
  ]
);

var un = myLocalJsonFileStore.get(
  'usernames'
);
´´´´



## persists

persists will monitor changes to an object/array and persists that single object to disc

const persists = require('nfdb').persists;

var pArray1 = persists( 'Array', // works for Array and Object .. fallback is an Object 'pArray1', // name ... currently only used for events './pArray1.persist.json', // filepath for saving { //options .. saveOnChange: true, // each change is written to disc saveInterval: null, // a write to disc interval in ms loadOnInit: true, // load 'old' data from the filepath (if it exists) events: null, // if an event-emitter is given, any change will trigger a name + '_change' event and a discwrite a name +'_fswrite' event } );

// NOTE ... re-initializing the persists object will lose all 'watch' effects.

´´´´

Keywords

database

FAQs

Package last updated on 08 Aug 2018

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