# sstable

> Sorted String Table

Latest version **0.3.3** (published 2016-05-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install sstable
pnpm add sstable
yarn add sstable
bun add sstable
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.3 |
| Published | 2016-05-30 |
| First published | 2016-05-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Ryan McCarvill |
| Maintainers | disordinary |

## Links

- npm: https://www.npmjs.com/package/sstable
- Repository: https://github.com/disordinary/SSTable
- Homepage: https://github.com/disordinary/SSTable#readme
- Issues: https://github.com/disordinary/SSTable/issues
- npm.io page: https://npm.io/package/sstable

## Recent versions

- 0.3.3 (latest) — 2016-05-30
- 0.2.3 — 2016-05-30
- 0.1.3 — 2016-05-20
- 0.0.1 — 2016-05-17

## README

# SSTable

This used to be a library for creating Sorted String Tables, as the needs of [todb](https://github.com/disordinary/todb) have changed so has the nature of this library. It's still kind of a SSTable but it's evolved.

An SSTable traditionally stores strings in sorted order something like this: `key,value|key,value|key,value...`

This library stores serialised JSON objects sorted by their key so:

`{ key : 'a' , value : 'foo' },{ key : 'b' , value : 'bah'}`, etc.

It's actually a little more complicated than that, it goes:
 0029{key : 'a' , value : 'foo' }0x1e0029{key : 'a' , value : 'foo' }0x1e

 Where 0029 is the byte length of the proceeding string and 0x1e is the row deliminator ascii record. Aditionally the first 12 bytes are reserved, the first two annotate the version of the SSTable, the next 10 the position in the table where the content stops. After all the records is a serialized JSON lookup table that I call the contents, this stores the byte offset for every section of keys, currently that is done based on the first letter but eventually it will be based on every x% of the table, or x rows, or x bytes, etc.

 So if I want to look for a record starting with the letter x SSTable will first look at the contents and see where the byte offset for all the `x` records are and look from there rather than the start of the file.

Example:

```javascript

new SSTable( "test.sst" , { id : 'email'  } , ( err , sstable ) => {
	sstable.create( [ { email : 'nikki@place.com' , age : '37' , name : 'Nikki' } ] , ( err ) => {
		sstable.seek( 'nikki@place.com' , ( err , value ) => {
		console.log(  value );
		} );
	} );
} );
```

---
_Source: https://npm.io/package/sstable · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
