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

streamsummary-stream

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

streamsummary-stream

Stream-based stream summary implementation

latest
Source
npmnpm
Version
0.4.0
Version published
Maintainers
1
Created
Source

streamsummary-stream

Stream-based implementation of the StreamSummary data structure described in this paper.

Pipe in your buffers/strings to get approximate top-K most frequent elements.

var StreamSummary = require('streamsummary-stream');
var ss = new StreamSummary(50);

//...

myDataSource.pipe(ss);

ss.on('finish', function() {
  console.log(ss.frequency('42'));
  console.log(ss.top());
});

Requires es6 Map

This module uses es6 Maps, so you probably need node.js >= 0.12 or io.js.

API

StreamSummary(size, streamOpts)

Construct a new writable StreamSummary to track the size most frequent elements (extends Stream.Writable).

  • size - the number of elements to track
  • streamOpts - the options to pass to the Stream constructor

StreamSummary.frequency(element)

Get the approximate frequency of element. Returns null if the element isn't in the top size elements.

  • element - the value in question

StreamSummary.top()

Get the top size most frequent elements in ascending order of frequency.

StreamSummary.export()

Export the StreamSummary data as an object. Exported object will look like:

{
  size: 42,
  numUsedBuckets: 40,
  trackedElements: {...},
  registers: [...]
}

StreamSummary.import(data)

Import a StreamSummary data object (expects same format as export() returns).

  • data - object containing StreamSummary data

StreamSummary.merge(ss)

Merge another StreamSummary with this one. Returns a new StreamSummary of size equal to the combined sizes of the two.

  • ss - another StreamSummary instance

Keywords

stream-summary

FAQs

Package last updated on 20 May 2015

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