0.0.3 • Published 4 years ago

@ricann/storage-map v0.0.3

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

storage-map

builds licenses

Use map structure to operate LocalStorage, SessionStorage, IndexDB and WebSQL.

Usage

const createStorage = require('@ricann/storage-map')
// Create localStorage
const storage = createStorage('localStorage')
// Create sessionStorage
const storage = createStorage('sessionStorage')

// Using storage is like using Map.
// Set a key-value to storage, and it and localStorage or sessionStorage are in sync.
storage.set('key', 'value')

Interface

abstract class StorageMap<T> implements Iterable<T> {
  abstract size: number
  abstract clear(): void
  abstract delete(key: string): void
  abstract entries(): Iterator<T>
  abstract forEach(callback: Function): void
  abstract get(key: string): any
  abstract has(key: string): boolean
  abstract keys(): Iterator<string>
  abstract set(key: string, value: any): void
  abstract values(): Iterator<any>
}

startup

# install dependencies
yarn install

# build for production
yarn build

# test unit
yarn run test
# test unit with covarage
yarn run test -- --covarage

# submit git log with conventional style
yarn commit
0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago