3.0.1 • Published 4 years ago

workshopper-adventure-storage v3.0.1

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

workshopper-adventure-storage

NPM version Downloads Build Status Coverage Status NPM deps NPM dev devp

Simple storage for workshopper-adventure

Originally included as part of workshopper-adventure, mostly written by Martin Heidegger

Based on prior work of: @substack @rvagg

Install

npm install workshopper-adventure-storage --save
const createStorage = require('workshopper-adventure-storage')

Usage

createStorage.userDir

A default path to store data in.

createStorage([dir, ...])

Accepts a sequence of paths for path.resolve to use as the storage directory.

const createStorage = require('workshopper-adventure-storage')
const storage = createStorage(createStorage.userDir, 'my-workshopper')

Properties

storage.dir

The path to store data in.

Methods

storage.save('name', data)

JSON encodes and writes a file to the storage directory. The following will save the file as index.json.

const data = {
  foo: 'bar'
}
storage.save('index', data)

storage.get('name')

Retrieves and unserializes a file from storage.

var data = storage.get('index')

storage.reset()

Clears the storage directory.

storage.reset()
3.0.1

4 years ago

3.1.0

4 years ago

3.0.0

7 years ago

2.0.3

7 years ago

2.0.2

8 years ago

2.0.0

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago