{"id":46634,"library":"tlhunter-sorted-set","title":"tlhunter-sorted-set","description":"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.","status":"maintenance","version":"0.1.0","language":"javascript","source_language":"en","source_url":"https://github.com/tlhunter/node-sorted-set","tags":["javascript","set","linked-list","skip-list","map","redis"],"install":[{"cmd":"npm install tlhunter-sorted-set","lang":"bash","label":"npm"},{"cmd":"yarn add tlhunter-sorted-set","lang":"bash","label":"yarn"},{"cmd":"pnpm add tlhunter-sorted-set","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Package does not export ESM. Use CommonJS require().","wrong":"import SortedSet from 'tlhunter-sorted-set';","symbol":"SortedSet","correct":"const SortedSet = require('tlhunter-sorted-set');"},{"note":"Static method prefered over instance method; instance method exists but is less efficient.","wrong":"setA.intersect(setB);","symbol":"SortedSet.intersect","correct":"const result = SortedSet.intersect(setA, setB);"},{"note":"Member can be any primitive, not necessarily a string.","wrong":"z.add({ member: 'value' }, 8.0);","symbol":"z.add(member, score)","correct":"z.add('member', 8.0);"},{"note":"Returns null if member not found, not undefined.","wrong":"z.score(member);","symbol":"z.score(member)","correct":"z.score('member');"},{"note":"Third argument is an options object, not a boolean.","wrong":"z.rangeByScore(7, 8, true);","symbol":"z.rangeByScore(min, max, { withScores: true })","correct":"z.rangeByScore(7, 8, { withScores: true });"}],"quickstart":{"code":"const SortedSet = require('tlhunter-sorted-set');\nconst z = new SortedSet();\nz.add('Terminator', 8.0);\nz.add('District 9', 8.0);\nz.add('Ex Machina', 7.7);\nconsole.log(z.score('Ex Machina')); // 7.7\nconsole.log(z.range(0, 2)); // ['Ex Machina', 'District 9', 'Terminator']\nconsole.log(z.rangeByScore(8, null, { withScores: true })); // [['District 9', 8], ['Terminator', 8]]\nconsole.log(SortedSet.intersect(z, new SortedSet())); // []","lang":"javascript","description":"Demonstrates basic usage: creating a set, adding members with scores, querying scores, range queries, and static intersect."},"warnings":[{"fix":"Consider alternatives like redis-sorted-set or implementing your own.","message":"Package is a fork of abandoned projects; no active development expected.","severity":"deprecated","affected_versions":">=0.1.0"},{"fix":"Check return value for null to determine if member existed.","message":"Methods like .add and .rem return previous score on update/removal, or null if member didn't exist.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Prefer .range() for consistency with Redis.","message":"The .slice() method is an alias for .range() but arguments differ: slice(start, length) vs range(start, stop).","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"If you need a SortedSet, wrap result: new SortedSet().add(...) (not directly supported).","message":"Static intersect returns an array, not a SortedSet.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Negative indices are supported but not documented; test behavior.","message":"Using negative index in .range() wraps: .range(-1) returns last element.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Always pass max explicitly or use null for unbounded.","message":"Omit optional params: .rangeByScore(8) does NOT default max to +∞; it sets max=8? Actually README shows single arg as min, max defaults to Infinity.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"search_vec":"'/redis-sorted-map':17 'activ':55 'add':29 'averag':27 'average-tim':26 'basic':60 'cardin':35 'case':62 'depend':53 'extern':52 'fork':18 'function':58 'implement':9 'intersect':38 'javascript':6,63 'latest':20 'link':66 'linked-list':65 'list':8,67,70 'log':24 'maintain':56 'map':16,71 'member':42 'multipl':40 'n':25 'o':23 'object':50 'oper':36 'primit':46 'provid':22 'rang':32 'rank':31 'redi':11,72 'remov':30 'score':33 'set':4,13,41,64 'skip':7,69 'skip-list':68 'sort':3,12,15 'sorted-map':14 'stabl':21 'string':48 'support':37 'symbol':49 'time':28 'tlhunter':2 'tlhunter-sorted-set':1 'use':61 'v0.1.0':19 'valu':47","created_at":"2026-06-07T13:00:52.507455+00:00","updated_at":"2026-06-07T13:00:52.507455+00:00","problems":[{"fix":"Use const SortedSet = require('tlhunter-sorted-set');","cause":"Using ESM import on a CommonJS module.","error":"TypeError: SortedSet is not a constructor"},{"fix":"const z = new SortedSet(); then z.add(member, score);","cause":"Forgot to instantiate with new SortedSet() or used static method incorrectly.","error":"z.add is not a function"},{"fix":"npm install tlhunter-sorted-set","cause":"Package not installed or missing from node_modules.","error":"Cannot find module 'tlhunter-sorted-set'"},{"fix":"Use primitive values (string, number, symbol) as members.","cause":"Attempting to add an object as member (not supported for complex objects)","error":"Uncaught TypeError: Member must be a string or number"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/tlhunter/node-sorted-set","github":"https://github.com/tlhunter/node-sorted-set","docs":null,"changelog":null,"pypi":null,"npm":"tlhunter-sorted-set","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}