Socket
Book a DemoInstallSign in
Socket

sorted-key-buckets

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sorted-key-buckets

Map a key to a bucket where the keys assigned to each bucket must be sorted. Creates new buckets as needed. used to make sorted string tables.

latest
Source
npmnpm
Version
0.0.2
Version published
Maintainers
1
Created
Source

sorted-key-buckets

Map a key to a bucket where the keys assigned to each bucket must be sorted. Creates new buckets as needed. used to make sorted string tables. (SST)


var keyBuckets = require('sorted-key-buckets')

var buckets = [];

var res = keyBuckets('a',buckets)
// returns ['a',false]

res[1] = {start:'a'}

res = keyBuckets('c',buckets)
// returns ['c',{start:'a'}]

res = keyBuckets('b',buckets)
// returns ['b',false]

// to find out if this is a new bucket test the value of offset 1 
if(!res[1]) res[1] = {start:'b'};

console.log(buckets)
// prints [['c',{start:'a'}],['b',{start:'b'}]]


in my use case the data associated with each bucket is an fs writestream

Keywords

SST

FAQs

Package last updated on 08 Sep 2013

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