project: Move to ESM Modules
This commit is contained in:
+10
-9
@@ -12,7 +12,7 @@ import type {
|
||||
} from '../Types'
|
||||
import { Curve, signedKeyPair } from './crypto'
|
||||
import { delay, generateRegistrationId } from './generics'
|
||||
import { ILogger } from './logger'
|
||||
import type { ILogger } from './logger'
|
||||
|
||||
/**
|
||||
* Adds caching capability to a SignalKeyStore
|
||||
@@ -67,8 +67,8 @@ export function makeCacheableSignalKeyStore(
|
||||
async set(data) {
|
||||
let keys = 0
|
||||
for (const type in data) {
|
||||
for (const id in data[type]) {
|
||||
cache.set(getUniqueId(type, id), data[type][id])
|
||||
for (const id in data[type as keyof SignalDataTypeMap]) {
|
||||
cache.set(getUniqueId(type, id), data[type as keyof SignalDataTypeMap]![id])
|
||||
keys += 1
|
||||
}
|
||||
}
|
||||
@@ -118,7 +118,7 @@ export const addTransactionCapability = (
|
||||
Object.assign(transactionCache[type]!, result)
|
||||
}
|
||||
|
||||
return ids.reduce((dict, id) => {
|
||||
return ids.reduce((dict: { [T in string]: any }, id) => {
|
||||
const value = transactionCache[type]?.[id]
|
||||
if (value) {
|
||||
dict[id] = value
|
||||
@@ -133,12 +133,13 @@ export const addTransactionCapability = (
|
||||
set: data => {
|
||||
if (isInTransaction()) {
|
||||
logger.trace({ types: Object.keys(data) }, 'caching in transaction')
|
||||
for (const key in data) {
|
||||
transactionCache[key] = transactionCache[key] || {}
|
||||
Object.assign(transactionCache[key], data[key])
|
||||
for (const key_ in data) {
|
||||
const key = key_ as keyof SignalDataTypeMap
|
||||
transactionCache[key] = transactionCache[key] || ({} as any)
|
||||
Object.assign(transactionCache[key]!, data[key])
|
||||
|
||||
mutations[key] = mutations[key] || {}
|
||||
Object.assign(mutations[key], data[key])
|
||||
mutations[key] = mutations[key] || ({} as any)
|
||||
Object.assign(mutations[key]!, data[key])
|
||||
}
|
||||
} else {
|
||||
return state.set(data)
|
||||
|
||||
Reference in New Issue
Block a user