2.0.2 • Published 3 years ago

utils-storage-ts v2.0.2

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

install

npm

npm install utils-storage-ts

yarn

yarn add utils-storage-ts

usage

Using examples in Vue3

main.js

import config from './config'
import { initLocalStorage, initSessionStorage }  from 'utils-storage-ts'

app.config.globalProperties.$localStorage = initLocalStorage(config.namespace)

app.config.globalProperties.$sessionStorage = initSessionStorage(config.namespace)

test.vue ( without setup )

mounted () {
  /**
    *@param1: key,
    *@param2: value,
    *@param3: time(The unit is *seconds),
    *@return: void
  */
  this.$localStorage.setItem('name', 'jitong', 3000)
  this.$sessionStorage.setItem('name', 'jitong', 3000)

  
  /**
    *@param: key,
    *@return: value || false
  */
  this.$localStorage.getItem('name')
  this.$sessionStorage.getItem('name')

  /**
    *@param: key,
    *@return: void
  */
  this.$localStorage.removeItem('name')
  this.$sessionStorage.removeItem('name')

  /**
    *@param: void,
    *@return: void
  */
  this.$localStorage.clear()
  this.$sessionStorage.clear()
}

test.vue ( with setup )

import { initLocalStorage, initSessionStorage }  from 'utils-storage-ts'
export default {
  setup () {
    const localStorage = initLocalStorage(namespace)
    const sessionStorage = initSessionStorage(namespace)
  }
}
2.0.2

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago