New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

petite-db

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

petite-db

<sub>Petite DB</sub>

latest
Source
npmnpm
Version
0.0.7
Version published
Maintainers
1
Created
Source

Petite DB

简介

一个使用起来巨简单,心智负担最轻的 indexedDB 库。像使用 localStorage、sessionStorage api 一样简单。

特色

1、api 与 localStorage、sessionStorage 基本一直

2、支持 async/await、 then-catch、callback

安装

npm install petite-db
// or
pnpm/yarn add petite-db

API

方法说明参数
setItem将指定 key 和 value 存储至 db 中key - 存储的键、 value -存储的值、callback - 回调函数(可选)
getItem获取 db 中指定 key 的值key - 需要获取键、callback - 回调函数(可选)
removeItem移除 db 中指定 key 的数据key - 需要移除的键、callback - 回调函数(可选)
clear清除 db 中所有数据callback - 回调函数(可选)
keys返回 db 中所有 key 的集合callback - 回调函数(可选)
length返回 db 中所有 key 的长度callback - 回调函数(可选)

案例

const db = new PetiteDB({ dbName: 'xxx', sotreName: 'xxxStore' })

db.setItem('test1', '我是第一个测试值')

db.getItem('test2', '我是第一个测试值').then((res) => {
  console.log('当前test2的值:', res)
}).catch((err) => {
  console.log('获取错误:', err)
})

async function getTest3Value() {
  const res = await db.getItem('test3')
  console.log('当前test3的值:', res)
}

db.getItem('test2', '我是第二个测试值', (err, val) => {
  if (err)
    console.log('获取错误:', err)

  else
    console.log('当前值:', val)

})

FAQs

Package last updated on 09 Jan 2023

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