Socket
Book a DemoInstallSign in
Socket

hyperreduce

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hyperreduce

Distributed reduce on top of hypercore

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

hyperreduce stability

npm version build status downloads js-standard-style

Distributed reduce on top of hypercore.

Usage

const hypercore = require('hypercore')
const memdb = require('memdb')

const reduce = require('./')
const core = hypercore(memdb())
const inp = core.createFeed()

const head = reduce(inp, memdb({ valueEncoding: 'json' }), reducer)
head(function (err, last) {
  if (err) throw err
  console.log('head:', last || 'no data')
})

function reducer (last, data, next) {
  last = last || 0
  console.log('last:', last)
  next(null, last + data.length)
}

inp.append('hello planet')
inp.append('hello planet')
inp.append('hello planet')

Why

We believe ops doesn't need to be complicated. If hypercore is distributed streams, hyperfilter is a distributed reducer for streams. We needed this to to turn our feed of server errors into a single meaningful value.

API

getLasthyperReduce(inputFeed, db, reducer(last, data, next), done?)

Create a new reduce function that reads data from an input hypercore feed to and applies the reducer function.

getLast(cb(err, last))

Get the last value from hyperreduce.

Installation

$ npm install hyperreduce

See Also

License

MIT

Keywords

hyper

FAQs

Package last updated on 03 Nov 2016

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