Skip to content

In-memory key-value store that optimizes for auto-complete against keys.

Notifications You must be signed in to change notification settings

alancnet/key-table

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

KeyTable

In-memory key-value store that optimizes for auto-complete against keys.

Usage

const KeyTable = require('key-table')

const table = new KeyTable()

// Add data
table.set('reality', 1)
table.set('realtor', 2)
table.set('realtors', 3)
table.set('ranger', 4)
table.set('foo', 'bar')

// Get data
table.get('ranger') === 4

// Retrieve data structure
table.data === {
  r: {
    ealtor: {
        '': 2,
        s: { '': 3 }
    },
    anger: { '': 4 }
  },
  foo: { '': 'bar' }
}

// Get all keys (keys returns an iterable)
Array.from(table.keys) === [
  'reality',
  'realtor',
  'realtors',
  'ranger',
  'foo'
]

// Get keys by prefix (getKeys returns an iterable)
Array.from(table.getKeys('real')) === [
    'reality',
    'realtor',
    'realtors'
]

// Restore from previous data
const table2 = new KeyTable(table.data)

table.data === table2.data

About

In-memory key-value store that optimizes for auto-complete against keys.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published