1.1.4 • Published 9 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-storageUsage
import ls from 'little-storage';ls.set(key: string, value: any)- stores the givenvalueat thekeyls.get(key: string)- returns the value stored at the givenkeyls.push(key: string, value: any, maxSize = 0)- pushes thevalueto the end of an array stored at thekey- if an array doesn't exist at the
key, a new array will be created and thevaluestored 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
maxSizeis0, the size is unlimited.
- if an array doesn't exist at the
ls.insert(key: string, value: any, maxSize = 0)- inserts thevalueto the beginning of an array stored at thekey- if an array doesn't exist at the
key, a new array will be created and thevaluestored 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
maxSizeis0, the size is unlimited.
- if an array doesn't exist at the
License
little-storage is under the MIT license.