Local Storage Service
localStorage wrapper for CRUD operations.
This library is useful for mocking API service, when learning a frontend framework.
Installation
$ npm install @p9m/local-storage-service --save
or
$ yarn add @p9m/local-storage-service
In browser:
<script src="https://unpkg.com/@p9m/local-storage-service@latest"></script>
<script>
const ls = new LocalStorageService('books');
</script>
Usage
import LocalStorageService from '@p9m/local-storage-service';
const ls = new LocalStorageService('contacts');
ls.create({name: 'Reddy'});
ls.get('6aa43c7c-69cf-df49-c927-6ba3db8d7ac1');
ls.update({name: 'John Doe', id: '6aa43c7c-69cf-df49-c927-6ba3db8d7ac1'});
ls.getAll();
ls.delete('6aa43c7c-69cf-df49-c927-6ba3db8d7ac1');
ls.deleteAll();