1.14.0 • Published 5 years ago

bags v1.14.0

Weekly downloads
-
License
MIT
Repository
-
Last release
5 years ago

Bags

WIP - The Bags have simple methods to manager localStorage API + JSON API

Documentation

Browser Support

ChromeFirefoxOperaSafariIE
4+ ✔3.5+ ✔10,50+ ✔4+ ✔8+ ✔

Installation

$ npm install bags --save

How to use

ES6

import Bags from 'bags';

const store = Bags.create();

CommonJS

const Bags = require('bags');

const store = Bags.create();

UMD in Browser

<!-- to import non-minified version -->
<script src="bags.umd.js"></script>

<!-- to import minified version -->
<script src="bags.umd.min.js"></script>

After that the library will be available as bags. Follow an example:

const bag = Bags.create();

Methods

Follow the methods that the library provides.

Bags.create()

Create is a static method that create a storage instance

Arguments

Don't have arguments

Example

const bag = Bags.create();

bag.add(key, value)

Create a new entry with any value (unless the function value)

Arguments

ArgumentTypeOptions
keystring'Any string you want as a key'
valueany'any value'

Example

bag.add('object', {});
bag.add('array', []);

bag.fetch(key)

Fetch a value stored given a correspondent key

Return null if key not exists

Arguments

ArgumentTypeOptions
keystring'Any string you want as a key'

Example

bag.fetch('object'); // {}
bag.fetch('array'); // []

bag.has(key)

Verify if value related with given key exists

Return a boolean true | false

Arguments

ArgumentTypeOptions
keystring'Any string you want as a key'

Example

bag.has('object'); // true
bag.has('number'); // false

bag.remove(key)

Remove the given key and the related value

Return true if occurs correctly

Arguments

ArgumentTypeOptions
keystring'Any string you want as a key'

Example

bag.has('object'); // true
bag.remove('object');
bag.has('object'); // false

bag.clear()

Clear all the store instance

Return true if occurs correctly

Arguments

Don't have arguments

Example

bag.has('object'); // true
bag.remove('object');
bag.has('object'); // false

Maintainers

Contributors

This project exists thanks to all the people who contribute.

You're free to contribute to this project by submitting issues and/or pull requests. This project is test-driven, so keep in mind that every change and new feature should be covered by tests.

This repository uses standard style guide

License

MIT © Daniel Simão da Silva

1.14.0

5 years ago

1.13.0

5 years ago

1.12.0

5 years ago

1.11.0

5 years ago

1.10.0

5 years ago

1.9.0

5 years ago

1.8.0

5 years ago

1.7.0

5 years ago

1.6.0

5 years ago

1.5.0

5 years ago

1.4.0

5 years ago

1.3.0

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago