DEV Community

toolkituse
toolkituse

Posted on

New storage utility methods added to the toolkit-use npm package

link

https://kennana.github.io/toolkit-use/

Determine if Storage is supported

import { ToolkitUseStorage } from 'toolkit-use'
ToolkitUseStorage.isSupportStorage()
Enter fullscreen mode Exit fullscreen mode

Set Storage

import { ToolkitUseStorage } from 'toolkit-use'
ToolkitUseStorage.setStorage(key, value, expire = 0)
Enter fullscreen mode Exit fullscreen mode

Get Storage

import { ToolkitUseStorage } from 'toolkit-use'
ToolkitUseStorage.getStorage(key)
Enter fullscreen mode Exit fullscreen mode

Check if Storage exists

import { ToolkitUseStorage } from 'toolkit-use'
ToolkitUseStorage.hasStorage(key)
Enter fullscreen mode Exit fullscreen mode

Get all keys

import { ToolkitUseStorage } from 'toolkit-use'
ToolkitUseStorage.getStorageKeys()
Enter fullscreen mode Exit fullscreen mode

Get key by index

import { ToolkitUseStorage } from 'toolkit-use'
ToolkitUseStorage.getStorageForIndex(index)
Enter fullscreen mode Exit fullscreen mode

Get length of localStorage

import { ToolkitUseStorage } from 'toolkit-use'
ToolkitUseStorage.getStorageLength()
Enter fullscreen mode Exit fullscreen mode

Get all storage items

import { ToolkitUseStorage } from 'toolkit-use'
ToolkitUseStorage.getStorageAll()
Enter fullscreen mode Exit fullscreen mode

Remove storage item

import { ToolkitUseStorage } from 'toolkit-use'
ToolkitUseStorage.removeStorage(key)
Enter fullscreen mode Exit fullscreen mode

Clear storage

import { ToolkitUseStorage } from 'toolkit-use'
ToolkitUseStorage.clearStorage()
Enter fullscreen mode Exit fullscreen mode

Automatically add prefix to name

import { ToolkitUseStorage } from 'toolkit-use'
ToolkitUseStorage.autoAddPrefix(key)
Enter fullscreen mode Exit fullscreen mode

Remove previously added prefix

import { ToolkitUseStorage } from 'toolkit-use'
ToolkitUseStorage.autoRemovePrefix(key)
Enter fullscreen mode Exit fullscreen mode

Encryption method

import { ToolkitUseStorage } from 'toolkit-use'
ToolkitUseStorage.encrypt(data)
Enter fullscreen mode Exit fullscreen mode

Decryption method

import { ToolkitUseStorage } from 'toolkit-use'
ToolkitUseStorage.decrypt(data)
Enter fullscreen mode Exit fullscreen mode

Top comments (0)