Registry / database / tlhunter-sorted-set

tlhunter-sorted-set

JSON →
library0.1.0jsnpmunverified

A JavaScript skip list implementation of Redis Sorted Sets (sorted-map/redis-sorted-map fork). v0.1.0 (latest, stable). Provides O(log N) average-time add, remove, rank, range, score, and cardinality operations. Supports intersection of multiple sets. Members can be any primitive value (strings, symbols, objects). No external dependencies. Not actively maintained, but functional for basic use cases.

npm install tlhunter-sorted-set
INSTALL
IMPORT
SIG · TLHUNTER-SORTED-SE
T
tlhunter-sorted-set
databasejavascriptv0.1.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

SortedSet
const SortedSet = require('tlhunter-sorted-set');
import SortedSet from 'tlhunter-sorted-set';
Package does not export ESM. Use CommonJS require().
SortedSet.intersect
const result = SortedSet.intersect(setA, setB);
setA.intersect(setB);
Static method prefered over instance method; instance method exists but is less efficient.
z.add(member, score)
z.add('member', 8.0);
z.add({ member: 'value' }, 8.0);
Member can be any primitive, not necessarily a string.
z.score(member)
z.score('member');
z.score(member);
Returns null if member not found, not undefined.
z.rangeByScore(min, max, { withScores: true })
z.rangeByScore(7, 8, { withScores: true });
z.rangeByScore(7, 8, true);
Third argument is an options object, not a boolean.

Demonstrates basic usage: creating a set, adding members with scores, querying scores, range queries, and static intersect.

const SortedSet = require('tlhunter-sorted-set'); const z = new SortedSet(); z.add('Terminator', 8.0); z.add('District 9', 8.0); z.add('Ex Machina', 7.7); console.log(z.score('Ex Machina')); // 7.7 console.log(z.range(0, 2)); // ['Ex Machina', 'District 9', 'Terminator'] console.log(z.rangeByScore(8, null, { withScores: true })); // [['District 9', 8], ['Terminator', 8]] console.log(SortedSet.intersect(z, new SortedSet())); // []
Debug
Known issues
deprecatedPackage is a fork of abandoned projects; no active development expected.
fix
Consider alternatives like redis-sorted-set or implementing your own.
affects: >=0.1.0
gotchaMethods like .add and .rem return previous score on update/removal, or null if member didn't exist.
fix
Check return value for null to determine if member existed.
affects: >=0.1.0
gotchaThe .slice() method is an alias for .range() but arguments differ: slice(start, length) vs range(start, stop).
fix
Prefer .range() for consistency with Redis.
affects: >=0.1.0
gotchaStatic intersect returns an array, not a SortedSet.
fix
If you need a SortedSet, wrap result: new SortedSet().add(...) (not directly supported).
affects: >=0.1.0
gotchaUsing negative index in .range() wraps: .range(-1) returns last element.
fix
Negative indices are supported but not documented; test behavior.
affects: >=0.1.0
gotchaOmit optional params: .rangeByScore(8) does NOT default max to +∞; it sets max=8? Actually README shows single arg as min, max defaults to Infinity.
fix
Always pass max explicitly or use null for unbounded.
affects: >=0.1.0
Errors
Common errors & fixes
TypeError: SortedSet is not a constructor
Using ESM import on a CommonJS module.
fix
Use const SortedSet = require('tlhunter-sorted-set');
z.add is not a function
Forgot to instantiate with new SortedSet() or used static method incorrectly.
fix
const z = new SortedSet(); then z.add(member, score);
Cannot find module 'tlhunter-sorted-set'
Package not installed or missing from node_modules.
fix
npm install tlhunter-sorted-set
Uncaught TypeError: Member must be a string or number
Attempting to add an object as member (not supported for complex objects)
fix
Use primitive values (string, number, symbol) as members.
Upgrade
Version history
0.1.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
14 hits · last 30 days
node
10
Meta
2
Amazon
1
OpenAI (training)
1
Resources