1.1.4 • Published 7 years ago
little-storage v1.1.4
Little Storage
:package: little-storage is a localStorage wrapper that adds better support for storing arrays and objects.
Installation
yarn add little-storage
Usage
import ls from 'little-storage';
ls.set(key: string, value: any)
- stores the givenvalue
at thekey
ls.get(key: string)
- returns the value stored at the givenkey
ls.push(key: string, value: any, maxSize = 0)
- pushes thevalue
to the end of an array stored at thekey
- if an array doesn't exist at the
key
, a new array will be created and thevalue
stored in it. - the array size is limited by the
maxSize
. If it's full, it will remove the first item in the array before pushing. - if
maxSize
is0
, the size is unlimited.
- if an array doesn't exist at the
ls.insert(key: string, value: any, maxSize = 0)
- inserts thevalue
to the beginning of an array stored at thekey
- if an array doesn't exist at the
key
, a new array will be created and thevalue
stored in it. - the array size is limited by the
maxSize
. If it's full, it will remove the last item in the array before inserting. - if
maxSize
is0
, the size is unlimited.
- if an array doesn't exist at the
License
little-storage is under the MIT license.