Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import {
FlashStore,
FlashStoreSync,
VERSION,
} from 'flash-store'
if (VERSION === '0.0.0') {
throw new Error('version should be set befoer publishing')
}
const store = new FlashStore()
store.destroy()
const storeSync = new FlashStoreSync()
storeSync.destroy()
console.info(`Smoke Testing v${store.version()} PASSED!`)
path.sep,
'.wechaty',
'puppet-padchat-cache',
path.sep,
token,
path.sep,
userId,
)
const baseDirExist = await fs.pathExists(baseDir)
if (!baseDirExist) {
await fs.mkdirp(baseDir)
}
this.cacheContactRawPayload = new FlashStoreSync(path.join(baseDir, 'contact-raw-payload'))
this.cacheRoomMemberRawPayload = new FlashStoreSync(path.join(baseDir, 'room-member-raw-payload'))
this.cacheRoomRawPayload = new FlashStoreSync(path.join(baseDir, 'room-raw-payload'))
await Promise.all([
this.cacheContactRawPayload.ready(),
this.cacheRoomMemberRawPayload.ready(),
this.cacheRoomRawPayload.ready(),
])
const roomMemberTotalNum = [...this.cacheRoomMemberRawPayload.values()].reduce(
(accuVal, currVal) => {
return accuVal + Object.keys(currVal).length
},
0,
)
'.wechaty',
'puppet-padchat-cache',
path.sep,
token,
path.sep,
userId,
)
const baseDirExist = await fs.pathExists(baseDir)
if (!baseDirExist) {
await fs.mkdirp(baseDir)
}
this.cacheContactRawPayload = new FlashStoreSync(path.join(baseDir, 'contact-raw-payload'))
this.cacheRoomMemberRawPayload = new FlashStoreSync(path.join(baseDir, 'room-member-raw-payload'))
this.cacheRoomRawPayload = new FlashStoreSync(path.join(baseDir, 'room-raw-payload'))
await Promise.all([
this.cacheContactRawPayload.ready(),
this.cacheRoomMemberRawPayload.ready(),
this.cacheRoomRawPayload.ready(),
])
const roomMemberTotalNum = [...this.cacheRoomMemberRawPayload.values()].reduce(
(accuVal, currVal) => {
return accuVal + Object.keys(currVal).length
},
0,
)
log.verbose('PuppetPadchatManager', 'initCache() inited %d Contacts, %d RoomMembers, %d Rooms, cachedir="%s"',
'puppet-padchat-cache',
path.sep,
token,
path.sep,
userId,
)
const baseDirExist = await fs.pathExists(baseDir)
if (!baseDirExist) {
await fs.mkdirp(baseDir)
}
this.cacheContactRawPayload = new FlashStoreSync(path.join(baseDir, 'contact-raw-payload'))
this.cacheRoomMemberRawPayload = new FlashStoreSync(path.join(baseDir, 'room-member-raw-payload'))
this.cacheRoomRawPayload = new FlashStoreSync(path.join(baseDir, 'room-raw-payload'))
await Promise.all([
this.cacheContactRawPayload.ready(),
this.cacheRoomMemberRawPayload.ready(),
this.cacheRoomRawPayload.ready(),
])
const roomMemberTotalNum = [...this.cacheRoomMemberRawPayload.values()].reduce(
(accuVal, currVal) => {
return accuVal + Object.keys(currVal).length
},
0,
)
log.verbose('PuppetPadchatManager', 'initCache() inited %d Contacts, %d RoomMembers, %d Rooms, cachedir="%s"',
this.cacheContactRawPayload.size,