Coder Social home page Coder Social logo

level-ws's Introduction

level-ws

A basic writable stream for abstract-level databases, using Node.js core streams. This is not a high-performance stream. If benchmarking shows that your particular usage does not fit then try one of the alternative writable streams that are optimized for different use cases.

๐Ÿ“Œ To instead write data using Web Streams, see level-web-stream.

level badge npm Node version Test Coverage Standard Common Changelog Donate

Usage

If you are upgrading: please see UPGRADING.md.

const { Level } = require('level')
const WriteStream = require('level-ws')

const db = new Level('./db', { valueEncoding: 'json' })
const ws = new WriteStream(db)

ws.on('close', function () {
  console.log('Done!')
})

ws.write({ key: 'alice', value: 42 })
ws.write({ key: 'bob', value: 7 })

// To delete entries, specify an explicit type
ws.write({ type: 'del', key: 'tomas' })
ws.write({ type: 'put', key: 'sara', value: 16 })

ws.end()

API

ws = new WriteStream(db[, options])

Create a writable stream that operates in object mode, accepting batch operations to be committed with db.batch() on each tick of the Node.js event loop. The optional options argument may contain:

  • type (string, default: 'put'): default batch operation type if not set on indididual operations.
  • maxBufferLength (number, default Infinity): limit the size of batches. When exceeded, the stream will stop processing writes until the current batch has been committed.
  • highWaterMark (number, default 16): buffer level when stream.write() starts returning false.

Contributing

Level/level-ws is an OPEN Open Source Project. This means that:

Individuals making significant and valuable contributions are given commit-access to the project to contribute as they see fit. This project is more like an open wiki than a standard guarded open source project.

See the Contribution Guide for more details.

License

MIT

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.