Skip to content

File System Storage shared same interface with Browser Storage.

License

Notifications You must be signed in to change notification settings

un-ts/node-fs-storage

Repository files navigation

node-fs-storage

GitHub Actions Codecov Codacy Grade type-coverage npm GitHub Release

David Peer David David Dev

Conventional Commits Renovate enabled JavaScript Style Guide Code Style: Prettier changesets

File System Storage shared same interface with Browser Storage.

TOC

Usage

Install

yarn add node-fs-storage    # yarn
npm install node-fs-storage # npm

API

// default
import { fsStorage } from 'node-fs-storage'

fsStorage.setItem('key', 'value')
fsStorage.getItem('key')
fsStorage.key(0)
fsStorage.length
fsStorage.removeItem('key')
fsStorage.clear()
// custom
import { FsStorage } from 'node-fs-storage'

// custom path
const fsStorage1 = new FsStorage(path.resolve('.storage'))

// custom `path` and key `encoder`, make sure it is a valid filename
const fsStorage2 = new FsStorage({
  path: path.resolve('.storage'),
  encoder: hash(key),
})

Changelog

Detailed changes for each release are documented in CHANGELOG.md.

License

MIT © JounQin@1stG.me