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

async-flumelog

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

async-flumelog - npm Package Compare versions

Comparing version 1.0.10 to 1.0.11

.github/workflows/node.js.yml

48

index.js

@@ -24,4 +24,4 @@ const Cache = require('hashlru')

var waiting = []
var waitingDrain = {} // blockIndex -> []
var blocksToBeWritten = new Map() // blockIndex -> { block, fileOffset }
const waitingDrain = new Map() // blockIndex -> []
const blocksToBeWritten = new Map() // blockIndex -> { block, fileOffset }

@@ -48,3 +48,3 @@ var latestBlock = null

if (err) throw err
var recordOffset = getLastRecord(buffer, 0)

@@ -90,3 +90,3 @@ since.set(len - blockSize + recordOffset)

}
function getBlock(offset, cb) {

@@ -152,3 +152,3 @@ var blockStart = offset - getRecordOffset(offset)

}
function del(offset, cb)

@@ -197,3 +197,3 @@ {

}
appendFrame(latestBlock, encodedData, nextWriteBlockOffset)

@@ -203,3 +203,3 @@ cache.set(latestBlockIndex, latestBlock) // update cache

nextWriteBlockOffset += frameSize(encodedData)
blocksToBeWritten[latestBlockIndex] = { block: latestBlock, fileOffset }
blocksToBeWritten.set(latestBlockIndex, { block: latestBlock, fileOffset })
scheduleWrite()

@@ -225,5 +225,6 @@ debug("data inserted at offset %d", fileOffset)

function writeBlock(blockIndex) {
const { block, fileOffset } = blocksToBeWritten[blockIndex]
delete blocksToBeWritten[blockIndex]
const drainsBefore = (waitingDrain[blockIndex] || []).slice(0)
if (!blocksToBeWritten.has(blockIndex)) return
const { block, fileOffset } = blocksToBeWritten.get(blockIndex)
blocksToBeWritten.delete(blockIndex)
const drainsBefore = (waitingDrain.get(blockIndex) || []).slice(0)

@@ -256,7 +257,7 @@ debug("writing block of size: %d, to offset: %d",

let drainsAfter = waitingDrain[blockIndex] || []
let drainsAfter = waitingDrain.get(blockIndex) || []
if (drainsBefore.length == drainsAfter.length)
delete waitingDrain[blockIndex]
waitingDrain.delete(blockIndex)
else
waitingDrain[blockIndex] = waitingDrain[blockIndex].slice(drainsBefore.length)
waitingDrain.set(blockIndex, waitingDrain.get(blockIndex).slice(drainsBefore.length))

@@ -269,3 +270,3 @@ write() // next!

function write() {
for (var blockIndex in blocksToBeWritten) {
for (var blockIndex of blocksToBeWritten.keys()) {
writeBlock(blockIndex)

@@ -283,3 +284,3 @@ return // just one at a time

}
function onLoad (fn) {

@@ -297,3 +298,9 @@ return function (arg, cb) {

}
function last(iterable) {
let res = null
for (let x of iterable) res = x
return res
}
return self = {

@@ -308,9 +315,8 @@ get: onLoad(get),

onDrain: onLoad(function (fn) {
let blockIndexes = Object.keys(blocksToBeWritten)
if (blockIndexes.length == 0) fn()
if (blocksToBeWritten.size === 0) fn()
else {
const latestBlockIndex = blockIndexes[blockIndexes.length-1]
const drains = waitingDrain[latestBlockIndex] || []
const latestBlockIndex = last(blocksToBeWritten.keys())
const drains = waitingDrain.get(latestBlockIndex) || []
drains.push(fn)
waitingDrain[latestBlockIndex] = drains
waitingDrain.set(latestBlockIndex, drains)
}

@@ -317,0 +323,0 @@ }),

{
"name": "async-flumelog",
"description": "An async flumelog",
"version": "1.0.10",
"version": "1.0.11",
"homepage": "https://github.com/flumedb/async-flumelog",

@@ -6,0 +6,0 @@ "repository": {

@@ -10,6 +10,6 @@ # Async flumelog

An async flumelog consists of a number of `blocks`, that contain a
number of `record`s. A `record` is simply it's `length`, as a 16-bit unsigned integer,
followed by the `data` bytes. A record must be in one and only one block,
which means there probably will be some empty space at the end of a block.
Blocks are always written in full.
number of `record`s. A `record` is simply it's `length`, as a 16-bit
unsigned integer, followed by the `data` bytes. A record must be in
one and only one block, which means there probably will be some empty
space at the end of a block. Blocks are always written in full.

@@ -16,0 +16,0 @@ ```

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