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

fortune-indexeddb

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fortune-indexeddb - npm Package Compare versions

Comparing version 1.1.1 to 1.1.2

146

lib/index.js

@@ -176,41 +176,46 @@ 'use strict'

return Promise.resolve(records.length ?
new Promise(function (resolve, reject) {
var id = self.common.generateId()
var transfer = []
return (records.length ?
// Trampoline this call stack to ensure that `encode` has a new stack.
new Promise(function (resolve) {
setTimeout(resolve, 0)
}).then(function () {
return new Promise(function (resolve, reject) {
var id = self.common.generateId()
var transfer = []
self.worker.addEventListener('message', listener)
self.worker.postMessage({
id: id, method: 'create', type: type,
records: reduce(records, function (hash, record) {
var data, id
self.worker.addEventListener('message', listener)
self.worker.postMessage({
id: id, method: 'create', type: type,
records: reduce(records, function (hash, record) {
var data, id
// Need to set the primary key and get the raw value, since it
// will be transformed later.
id = record[primaryKey] = primaryKey in record ?
record[primaryKey] : self.common.generateId()
// Need to set the primary key and get the raw value, since it
// will be transformed later.
id = record[primaryKey] = primaryKey in record ?
record[primaryKey] : self.common.generateId()
record = inputRecord.call(self, type, record)
data = msgpack.encode(record)
record = inputRecord.call(self, type, record)
data = msgpack.encode(record)
if (collection.hasOwnProperty(id))
throw new ConflictError(
message('RecordExists', language, { id: id }))
if (collection.hasOwnProperty(id))
throw new ConflictError(
message('RecordExists', language, { id: id }))
transfer.push(data.buffer)
hash[id] = data
return hash
}, {})
}, transfer)
transfer.push(data.buffer)
hash[id] = data
return hash
}, {})
}, transfer)
function listener (event) {
var data = event.data
function listener (event) {
var data = event.data
if (data.id !== id) return null
if (data.error) return reject(new Error(data.error))
if (data.id !== id) return null
if (data.error) return reject(new Error(data.error))
self.worker.removeEventListener('message', listener)
return resolve(records)
}
}) : records)
self.worker.removeEventListener('message', listener)
return resolve(records)
}
})
}) : Promise.resolve(records))
.then(function (records) {

@@ -231,47 +236,52 @@ return MemoryAdapter.prototype.create.call(self, type, records)

return Promise.resolve(updates.length ?
new Promise(function (resolve, reject) {
var i, j, update, record, clonedRecord, records = [], transfer = []
return (updates.length ?
// Trampoline this call stack to ensure that `encode` has a new stack.
new Promise(function (resolve) {
setTimeout(resolve, 0)
}).then(function () {
return new Promise(function (resolve, reject) {
var i, j, update, record, clonedRecord, records = [], transfer = []
for (i = 0, j = updates.length; i < j; i++) {
update = updates[i]
record = db[type][update[primaryKey]]
if (!record) continue
for (i = 0, j = updates.length; i < j; i++) {
update = updates[i]
record = db[type][update[primaryKey]]
if (!record) continue
// Clone the record then apply the update before sending to
// worker thread, or else the update won't be transferred.
clonedRecord = clone(record)
applyUpdate(clonedRecord, update)
records.push(clonedRecord)
}
// Clone the record then apply the update before sending to
// worker thread, or else the update won't be transferred.
clonedRecord = clone(record)
applyUpdate(clonedRecord, update)
records.push(clonedRecord)
}
if (!records.length) return resolve()
if (!records.length) return resolve()
self.worker.addEventListener('message', listener)
self.worker.postMessage({
id: id, method: 'update', type: type,
records: reduce(records, function (hash, record) {
var data
self.worker.addEventListener('message', listener)
self.worker.postMessage({
id: id, method: 'update', type: type,
records: reduce(records, function (hash, record) {
var data
record = inputRecord.call(self, type, record)
data = msgpack.encode(record)
transfer.push(data.buffer)
hash[record[primaryKey]] = data
return hash
}, {})
}, transfer)
record = inputRecord.call(self, type, record)
data = msgpack.encode(record)
transfer.push(data.buffer)
hash[record[primaryKey]] = data
return hash
}, {})
}, transfer)
return null
return null
function listener (event) {
var data = event.data
function listener (event) {
var data = event.data
if (data.id !== id) return null
if (data.error) return reject(new Error(data.error))
if (data.id !== id) return null
if (data.error) return reject(new Error(data.error))
self.worker.removeEventListener('message', listener)
self.worker.removeEventListener('message', listener)
return resolve()
}
}) : null)
return resolve()
}
})
}) : Promise.resolve())
.then(function () {

@@ -287,3 +297,3 @@ return MemoryAdapter.prototype.update.call(self, type, updates)

return Promise.resolve(!ids || ids.length ?
return (!ids || ids.length ?
new Promise(function (resolve, reject) {

@@ -306,3 +316,3 @@ self.worker.addEventListener('message', listener)

}
}) : null)
}) : Promise.resolve())
.then(function () {

@@ -309,0 +319,0 @@ return MemoryAdapter.prototype.delete.call(self, type, ids)

{
"name": "fortune-indexeddb",
"description": "IndexedDB adapter for Fortune.",
"version": "1.1.1",
"version": "1.1.2",
"license": "MIT",

@@ -21,4 +21,4 @@ "repository": {

"devDependencies": {
"browserify": "^16.2.3",
"eslint": "^5.16.0",
"browserify": "^16.3.0",
"eslint": "^6.0.1",
"eslint-config-boss": "^1.0.6",

@@ -25,0 +25,0 @@ "fortune": "^5.5.17",

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