3.0.3 • Published 4 years ago

pooling.js v3.0.3

Weekly downloads
1
License
ISC
Repository
github
Last release
4 years ago

Pooling.js

npm

NPM

Introduction

Handle statuses of data, and store the information in a Keyv database

Examples

Creates a item and gets its value

const Pool = require('pooling.js');
const pool = new Pool();

pool.set('cooldataofthisitem', 'coolstatus')
.then(item => {
    return pool.get(item.key);
})
.then((data) => {
    console.log(data)
    // cooldataofthisitem
});

Documentation

Classes

Item

A item instance used to interact with pool items

Kind: global class

new Item(pool, key, status)

ParamTypeDescription
poolPoolThe pool class
keystringThe key name of the item
statusstringStatus name the item belongs to

item.set(value) ⇒ Promise.<true>

Sets the value of the item

Kind: instance method of Item
Returns: Promise.<true> - Returns promise, resolves to true if succesfull

ParamType
valueany

item.setStatus(status) ⇒ Promise.<Item>

Set the status of the

Kind: instance method of Item
Returns: Promise.<Item> - Promise resolving with the new item

ParamType
statusstring

item.get() ⇒ Promise.<any>

Gets the value of the item

Kind: instance method of Item
Returns: Promise.<any> - Promise with the value

Pool

Handles database and pools

Kind: global class

new Pool(database)

ParamTypeDescription
databaseKeyvThe keyv database of choice

pool.add(value, status) ⇒ Promise.<Item>

Add a item to the pool

Kind: instance method of Pool
Returns: Promise.<Item> - Promise with item

ParamType
valueItem | Any
statusstring

pool.set(key, value) ⇒ Promise.<true>

Sets a value of a key

Kind: instance method of Pool
Returns: Promise.<true> - promise with true if succesfull

ParamType
keyItem | string
valueany

pool.setStatus(key, status) ⇒ Promise.<Item>

Sets status of a item

Kind: instance method of Pool
Returns: Promise.<Item> - Promise with the new item

ParamType
keyItem | string
statusstring

pool.get(key) ⇒ Promise.<any>

Get item's value

Kind: instance method of Pool
Returns: Promise.<any> - The value

ParamType
keyItem | string

pool.getItemsOf(status) ⇒ Promise.<Array.<Item>>

Get all the items with certain status

Kind: instance method of Pool
Returns: Promise.<Array.<Item>> - Array with items

ParamType
statusstring

pool.getOf(status) ⇒ Promise.<Array.<any>>

get all of the value's with certain status

Kind: instance method of Pool
Returns: Promise.<Array.<any>> - Array with all the values

ParamType
statusstring
3.0.3

4 years ago

3.0.1

4 years ago

3.0.0

4 years ago

2.1.8

4 years ago

2.1.7

4 years ago

2.1.6

4 years ago

2.1.5

4 years ago

2.1.4

4 years ago

2.1.3

4 years ago

2.1.2

4 years ago

2.1.1

4 years ago