Skip to content

vasrap/keyval.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

keyval.js BETA

a fast key value pair library

USAGE

// Instantiate keyval.
var kv = new keyval();

// Add 1 million key value pairs. for (var i = 1; i <= 1000000; i++) { // 1st arg is the key, second is the value. kv.set(i.toString(), i); }

// Delete a key value pair. kv.del('100000');

// Iterate over the key value pairs. var tmp, foo; while (tmp = kv.itr()) { // Assign the value to foo. foo = tmp.v; }

// Rewind the iterator to the first key. kv.rwd();

// Get the number of key value pairs set. var length = kv.len;

// Empty the key value pair pool. kv.empty();

FEATURES

  • Iterates key value associated data faster than using a JavaScript object (~10x on Chrome, ~5x on Firefox)
  • Finds a specified key in 0ms
  • Deletes a specified key in 0ms
  • Provides key count in 0ms
  • Sets key value associated data a bit slower than using a JavaScript object
Benchmarked using 1 million string keys; with each one of them associated to 1 integer value
Tested on Chrome, Firefox (pending for the rest of the browsers)

About

A fast key value pair library

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published