Socket
Book a DemoInstallSign in
Socket

@p9m/local-storage-service

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@p9m/local-storage-service

localStorage wrapper for CRUD operations

1.0.3
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

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';

// Create instance with a namespace
const ls = new LocalStorageService('contacts');

// Create a record
ls.create({name: 'Reddy'});
// {name: 'Reddy', id: '6aa43c7c-69cf-df49-c927-6ba3db8d7ac1'}

// Get a record
ls.get('6aa43c7c-69cf-df49-c927-6ba3db8d7ac1');
// {name: 'Reddy', id: '6aa43c7c-69cf-df49-c927-6ba3db8d7ac1'}

// Update a record
ls.update({name: 'John Doe', id: '6aa43c7c-69cf-df49-c927-6ba3db8d7ac1'});
// {name: 'John Doe', id: '6aa43c7c-69cf-df49-c927-6ba3db8d7ac1'}

// Get all records within namespace (eg: contacts)
ls.getAll();

// Delete a record
ls.delete('6aa43c7c-69cf-df49-c927-6ba3db8d7ac1');

// Delete all record within namespace (eg: contacts)
ls.deleteAll();

Keywords

localStorage

FAQs

Package last updated on 14 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.