Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

yux-storage

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

yux-storage - npm Package Compare versions

Comparing version 1.1.1 to 1.1.2

54

package.json
{
"name": "yux-storage",
"version": "1.1.1",
"description": "yux-storage 是一个基于 HTML5 IndexedDB 封装的 Web 本地数据离线存储库",
"main": "yux-storage.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/yued-fe/yux-storage.git"
},
"keywords": [
"indexedDB",
"storage",
"localStorage",
"yux"
],
"author": "XboxYan",
"license": "MIT",
"bugs": {
"url": "https://github.com/yued-fe/yux-storage/issues"
},
"files": [
"yux-storage.js"
],
"homepage": "https://github.com/yued-fe/yux-storage#readme"
}
"name": "yux-storage",
"version": "1.1.2",
"description": "yux-storage 是一个基于 HTML5 IndexedDB 封装的 Web 本地数据离线存储库",
"main": "yux-storage.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/yued-fe/yux-storage.git"
},
"keywords": [
"indexedDB",
"storage",
"localStorage",
"yux"
],
"author": "XboxYan",
"license": "MIT",
"bugs": {
"url": "https://github.com/yued-fe/yux-storage/issues"
},
"files": [
"yux-storage.js"
],
"homepage": "https://github.com/yued-fe/yux-storage#readme"
}

@@ -57,2 +57,5 @@ # yux-storage

console.log('出错了')
// 类似于 nodejs 回调格式
} else {
console.log(value)
}

@@ -69,2 +72,6 @@ })

## 测试用例
可访问 [yux-storage测试用例](https://yued-fe.github.io/yux-storage/),记得打开控制台哦~
## API

@@ -100,3 +107,3 @@

// 当离线仓库中的值被载入时,此处代码运行
console.log(value);
console.log(err, value);
});

@@ -184,3 +191,3 @@

> 其实就是遍历,然后执行 REMOVEITEM
> !小心使用,其实就是遍历,然后执行 REMOVEITEM

@@ -206,2 +213,4 @@ *示例*

*示例*
```js

@@ -224,5 +233,14 @@ yuxStorage.key(2).then(function(keyName) {

*示例*
```js
yuxStorage.keys().then(function(keyNames) {
// 所有的key名
console.log(keyNames);
})
```
## 兼容性
不支持 `IE`
现代浏览器,包括移动端,不支持 `IE`

@@ -234,2 +252,2 @@ > 兼容性取决于 [indexedDB](https://caniuse.com/?search=indexedDB) 和 [Promise](https://caniuse.com/?search=Promise)

有相关问题或者意见可与我联系 yanwenbin@yuewen.com
有相关问题或者意见可与我联系 yanwenbin@yuewen.com、yanwenbin1991@live.com

@@ -14,10 +14,10 @@ /**

ready(){
ready() {
return new Promise((resolve, reject) => {
if( this.db ){
if (this.db) {
resolve(this)
}else{
} else {
this.objectStoreName = 'yux-store';
const request = window.indexedDB.open('yux-project', 1);
request.onsuccess = (event) => {

@@ -41,3 +41,3 @@ this.db = event.target.result;

setItem(key, value, callback) {
this.ready().then(()=>{
return this.ready().then(() => {
return new Promise((resolve, reject) => {

@@ -47,3 +47,3 @@ const request = this.db.transaction(this.objectStoreName, 'readwrite').objectStore(this.objectStoreName).put(value, key);

if (callback && typeof callback === 'function') {
callback(false,value);
callback(false, value);
}

@@ -54,3 +54,3 @@ resolve(value);

if (callback && typeof callback === 'function') {
callback(true,null);
callback(true, null);
}

@@ -64,3 +64,3 @@ reject(event);

getItem(key, callback) {
this.ready().then(()=>{
return this.ready().then(() => {
return new Promise((resolve, reject) => {

@@ -85,3 +85,3 @@ const request = this.db.transaction(this.objectStoreName).objectStore(this.objectStoreName).get(key);

removeItem(key, callback) {
this.ready().then(()=>{
return this.ready().then(() => {
return new Promise((resolve, reject) => {

@@ -106,3 +106,3 @@ const request = this.db.transaction(this.objectStoreName, 'readwrite').objectStore(this.objectStoreName).delete(key);

key(index, callback) {
this.ready().then(()=>{
return this.ready().then(() => {
return new Promise((resolve, reject) => {

@@ -114,3 +114,3 @@ const request = this.db.transaction(this.objectStoreName).objectStore(this.objectStoreName).getAllKeys();

}
resolve(request.result[index]);
resolve(request.result[index] || null);
};

@@ -128,3 +128,3 @@ request.onerror = (event) => {

keys(callback) {
this.ready().then(()=>{
return this.ready().then(() => {
return new Promise((resolve, reject) => {

@@ -149,3 +149,3 @@ const request = this.db.transaction(this.objectStoreName).objectStore(this.objectStoreName).getAllKeys();

clear(callback) {
this.ready().then(()=>{
return this.ready().then(() => {
return new Promise((resolve, reject) => {

@@ -187,3 +187,2 @@ const objectStore = this.db.transaction(this.objectStoreName, 'readwrite').objectStore(this.objectStoreName);

window.yuxStorage = new yuxDB();
}
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc