0.6.3 • Published 2 years ago

holdmykeys v0.6.3

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Hold My Keys

Easy to use in-memory key value store with zero external dependancies.

Built With

Typescript-Badge


Quickstart

Installation

npm i holdmykeys or yarn add holdmykeys

NOTE: This package is likely not suitable for production environments and may be very slow with large amounts of data.

Basic Usage

import { KeyHolder } from "holdmykeys";

// Initialise a new KeyHolder instance
const keyHolder = new KeyHolder();

// Add a key to the KeyHolder
keyHolder.save({key: "my-key", value: "This is a value for a key"});

// Get the value of a key
keyHolder.read("my-key")?.value; // "This is a value for a key"

// Remove a key from the KeyHolder
keyHolder.remove("my-key");

Documentation

KeyHolder Arguments

NameDescriptionValuesDefaultRequired
SettingsThe settings to use for the keyholderTKeyStoreSettings{}{}false
DataThe data to initialise the keyholder withTKeyData[][]false

Methods

NameDescriptionArgumentsReturn
#.read()Read a key from the keyholderkey: stringstring
#.readAll()Read all keys from the keyholder,noneTKeyData[]
#.save()Save a key to the keyholderTKeyData, TSaveSettingsvoid
#.saveBulk()Save multiple keys to the keyholderTKeyData[], TSaveSettingsPromise<void>
#.saveBulkFromFile()Save multiple keys from a JSON file to the keyholdeTKeyDatavoid
#.update()DEPRECATED: Update a value if it existsTKeyDatavoid
#.dump()Dump all the keys in the keyholder to a filefilePath: stringPromise<unknown>
#.remove()Remove a key from the keyholderkey: stringvoid
#.removeBulk()Remove multiple keys from the keyholderkeys: string[]Promise<void>
#.clear()Clear all keys from the keyholdernonevoid
#.size()Get the number of keys in the keyholdernonenumber
#.isEqual()Compare a key value to the given valuekey: string, value: stringboolean
#.isHashed()Check if a key is hashedkey: stringboolean
#.exists()Check if a key exists in the keyholderkey: stringboolean

Types

NameDetails
TKeyData{ key: string, value: string \|object, hashed: boolean }
TKeyStoreSettings{ hashedByDefault?: boolean }
TKeyStoreInit{ settings?: TKeyStoreSettings, data?: TKeyData[] }
TSaveSettings{ settings?: overwrite?: boolean }
0.6.3

2 years ago

0.6.2

2 years ago

0.6.1

2 years ago

0.6.0

2 years ago

0.5.0

2 years ago

0.4.3

2 years ago

0.4.2

2 years ago

0.4.1

2 years ago

0.4.0

2 years ago

0.3.0

2 years ago

0.2.0

2 years ago

0.1.7

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago