# node-hashtable

> This is a simple hashtable, all written in node, to help you access and store your data over multiple workers or modules. It will provide the abstraction to access it through workers (cluster).

Latest version **0.1.1** (published 2013-10-15) · 0 weekly downloads

## Install

```sh
npm install node-hashtable
pnpm add node-hashtable
yarn add node-hashtable
bun add node-hashtable
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2013-10-15 |
| First published | 2013-10-15 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.6 |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Maintainers | herenow |
| Keywords | hashtable, cluster, module, worker, API, node, hash-table, simple |

## Links

- npm: https://www.npmjs.com/package/node-hashtable
- Repository: https://github.com/herenow/node-hashtable
- Issues: https://github.com/herenow/node-hashtable/issues
- npm.io page: https://npm.io/package/node-hashtable

## Dependencies (1)

- [nssocket](https://npm.io/package/nssocket.md) *

## Alternatives

- [@expo/fingerprint](https://npm.io/package/@expo/fingerprint.md) — 6.2M weekly downloads
- [@azure/monitor-opentelemetry-exporter](https://npm.io/package/@azure/monitor-opentelemetry-exporter.md) — 850.0K weekly downloads
- [@azure/monitor-opentelemetry](https://npm.io/package/@azure/monitor-opentelemetry.md) — 624.0K weekly downloads
- [@posthog/ai](https://npm.io/package/@posthog/ai.md) — 423.3K weekly downloads
- [fakefilter](https://npm.io/package/fakefilter.md) — 63.9K weekly downloads

## Recent versions

- 0.1.1 (latest) — 2013-10-15
- 0.1.0 — 2013-10-15

## README

node-hashtable
=========

A simple hashtable written in node (not meant for production).
It will help you share data over your node clusters or modules.


Installation
----------
```
npm install node-hashtable
```


Example
----------

**With cluster:**
```javascript
var hashTable = require("node-hashtable");

var cluster = require("cluster");

var numCPUs = require('os').cpus().length;


if(cluster.isMaster) {
  hashTable.set("test", "Hello World");

  // Fork workers.
  for (var i = 0; i < numCPUs; i++) {
      cluster.fork();
  }
}
else if(cluster.isWorker) {
  hashTable.get("test", function(data) { //Callback is required!
    console.log(data); //output -> "Hello World"
  });
}
```

**Without cluster:**
```javascript
var hashTable = require("node-hashtable");


hashTable.set("test", "Hello World");

var data = hashTable.get("test"); //In this case, callback is not required.

console.log(data); //output -> "Hello World"

```

Verbs
----------

### hashTable.set("key", data, [callback])
This function will set data to a key. If your using a cluster, you should create the callback function!
```
hashTable.set("key", data, function(){
  //Do stuff
});
```

### hashTable.get("key", [callback])
This function will return data. In this case, if using with a cluster, you NEED to create the callback!
```
hashTable.get("key", function(data){
  //Do stuff
});
```

### hashTable.add("key", data, [callback])
Diferent from .set, this will append data to the key. Be carefull when appending objects.
```
hashTable.add("key", "more stuff", function(){
  //Do stuff
});
```

### hashTable.update("key", data, [callback])
This will find the property you want to update inside the key, and update it.
```
hashTable.update("key", {prop: 'new'}, function(){
  //Do stuff
});
```

### hashTable.delete("key", [callback])
No explanations needed...
```
hashTable.delete("key", function(){
  //Do stuff
});
```

### hashTable.createHash(data, [callback])
It will return a hash for your data.
```
hashTable.createHash(data, function(hash){

  hashTable.set(hash, data, function(){
    //Do stuff
  });

});
```

### hashTable.createKey(data, [callback])
It will return a random hash key.
```
hashTable.createKey(data, function(key){

  hashTable.set(key, data, function(){
    //Memo your key!
  });

});
```

### hashTable.clear([callback])
This function will clear the entire hash table.
```
hashTable.createKey(function(){
  //Do stuff
});
```

Thank you 
----------
- Nodejistu/nssocket for providing the socket middleware

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