Comparing version 1.0.3 to 1.1.0
@@ -0,0 +0,0 @@ { |
@@ -0,0 +0,0 @@ const judel = require('../../index.js'); |
@@ -0,0 +0,0 @@ const Base = require('./libs/adaptor/base'); |
@@ -8,2 +8,13 @@ function AsyncStorage(RNAsyncStorage) { | ||
this.multiSet = async function (keyValuePairs = []) { | ||
await new Promise((res, rej) => { | ||
this.RNAsyncStorage.multiSet(keyValuePairs, err => { | ||
if (err) | ||
rej(err); | ||
else | ||
res(); | ||
}); | ||
}); | ||
} | ||
this.getItem = async function (key = "") { | ||
@@ -10,0 +21,0 @@ return await this.RNAsyncStorage.getItem(key); |
@@ -8,2 +8,8 @@ var storage = {}; | ||
this.multiSet = async function (keyValuePairs = []) { | ||
keyValuePairs.forEach(keyValuePair => { | ||
storage[keyValuePair[0]] = keyValuePair[1]; | ||
}); | ||
} | ||
this.getItem = async function (key = "") { | ||
@@ -10,0 +16,0 @@ return storage[key]; |
@@ -0,0 +0,0 @@ function Base (name, { adaptor }) { |
@@ -0,0 +0,0 @@ const Repo = require('./repo'); |
@@ -13,2 +13,14 @@ const uuidv4 = require('uuid/v4'); | ||
this.bulkInsert = async function (items = []) { | ||
var keyValuePairs = items.map(item => { | ||
item.id = item.id || uuidv4(); | ||
return [ | ||
this.name + item.id, | ||
JSON.stringify(item) | ||
]; | ||
}); | ||
await this.adaptor.multiSet(keyValuePairs); | ||
return items; | ||
} | ||
this.update = async function (item) { | ||
@@ -15,0 +27,0 @@ var old = await this.get(item.id); |
{ | ||
"name": "judel", | ||
"version": "1.0.3", | ||
"version": "1.1.0", | ||
"description": "For javascript key/value storage like react-native async-storage.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7303
210