Encyclopedia: Store large objects in many smaller ones

Recommend this page to a friend!
  Info   View files Example   View files View files (12)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 91 All time: 430 This week: 1Up
Version License JavaScript version Categories
encyclopedia 0.0.2MIT/X Consortium ...1.7Data types, Node.js
Description Author

This object can store large objects in many smaller ones.

It acts like an object that stores key-value pairs but internally it creates multiple objects of limited length when the the number of entries exceeds the configured object limit.

The object provides functions to set and get key values, check if a key exists, remove a value with a given key, and traverse the object entries using a callback function.

Innovation Award
JavaScript Programming Innovation award nominee
March 2015
Number 2


Prize: One year server license IP to country, region, city, latitude, longitude, ZIP code, time zone, area code database
Some applications need to search data on dictionaries with a large number of entries.

This object addresses this problem by creating an associative array like interface to access large dictionaries splitting them internally into small objects that manage a limited number of entries.

Manuel Lemos
Picture of ryan silalahi
Name: ryan silalahi <contact>
Classes: 1 package by
Country: Indonesia Indonesia
Age: ???
All time rank: 1672 in Indonesia Indonesia
Week rank: 6 Up1 in Indonesia Indonesia Up
Innovation award
Innovation award
Nominee: 1x

Details

Encyclopedia

i make this library to masking big object in nodejs. you can use this when you have to store a big data in nodejs. but considering your hardware also :-)

the logic behind this is i make separated object for masking a big object. example you need to store 100.000 properties and this library is make 100 object with 1000 properties each object.

default per object is 1 million, but you can set it when create new instance. example:

	var encyclopedia = require('encyclopedia');
	var data = encyclopedia(1000); // 1000 property per object

getting started

	var encyclopedia = require('encyclopedia');
	var data = encyclopedia(); // create new instance

	data.set('some key', 'some value');
	data.get('some key'); // return 'some value'

set(k, v)

	data.set('some key', 'some value');

get(k)

	console.log( data.get('some key') );

has(k)

	if(data.has('some key')){
		console.log('gotcha!');
	}else{
		console.log('not found!');
	}

unset(k, v)

	data.set('foo', 'bar'); // foo => bar
	data.unset('foo'); // foo deleted 
	data.get('foo') // undefined

walk(callback(k, v){ })

	var max = 10;
	for(var i = 0; i < max; i++){
		data.set(i, i);
	}

	data.walk(function(k, v){
		console.log(k + ' => ' + v);
	});

note: if callback return FALSE it will break the walk, otherwise walk will continue..

getLength()

	var max = 10;
	for(var i = 0; i < max; i++){
		data.set(i, i);
	}

	console.log('now length: ' + data.getLength()); // 10

author:

  • ryan hs <mr.ryansilalahi@gmail.com>
need a lot to be improved

in this early development i just focus on main idea, separated big object.. i think there is a lot to be improved. you are very welcome to contribute :-)

  Files folder image Files  
File Role Description
Files folder imageexample (6 files)
Files folder imagelib (2 files)
Files folder imagetest (2 files)
Accessible without login Plain text file package.json Data Auxiliary data
Accessible without login Plain text file README.md Data Auxiliary data

  Files folder image Files  /  example  
File Role Description
  Accessible without login Plain text file example1.js Example Example script
  Accessible without login Plain text file example2.js Example Example script
  Accessible without login Plain text file example3.js Example Example script
  Accessible without login Plain text file example4.js Example Example script
  Accessible without login Plain text file example5.js Example Example script
  Accessible without login Plain text file example6.js Example Example script

  Files folder image Files  /  lib  
File Role Description
  Plain text file encyclopedia.js Class Class source
  Plain text file encyclopedia_rand.js Class Class source

  Files folder image Files  /  test  
File Role Description
  Accessible without login Plain text file 0-encRand.js Test Unit test script
  Accessible without login Plain text file 1-crud.js Test Unit test script

 Version Control Unique User Downloads Download Rankings  
 100%
Total:91
This week:0
All time:430
This week:1Up