1.1.0 • Published 1 year ago

yawebs v1.1.0

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

YAWEBS

Installation

npm install yawebs

Usage

import { local } from 'yawebs'

// GET
local.get('my-key')

// SET
local.set('my-new-key', 'hello world!')

// REMOVE
local.remove('my-new-key')

// CLEAR
local.clear()

API

interface GetOptions {
  parse?: boolean // parses the value
  defaultValue?: any // returns the default value if no key is found
}
const DEFAULT_GETOPTIONS = {
  parse: true,
  defaultValue: null
}

local.get(key: string, options: GetOptions = DEFAULT_GETOPTIONS) // Gets the item with the specified key from the storage

interface SetOptions {
  stringify?: boolean // Stringifies the value before sending to the storage
  overwrite?: boolean // If true overwrites existing item, else does not add the new item if the key already exists
}
const DEFAULT_SETOPTIONS = {
  stringify: true,
  overwrite: true
}

local.set(key: string, options: SetOptions = DEFAULT_SETOPTIONS) // Sets the new key, value pair to the storage

local.remove(key: string) // Removes the item with the specified key from the storage
local.clear() // Removes all the items from the storage

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

1.1.0

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

0.0.1

1 year ago