Security News
Introducing the Socket Python SDK
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
base class for creating generic pull-sinks that write to some device via an async call.
base class for creating generic pull-sinks that write to some device via an async call.
async function called with an array of items to output.
This function will only ever be called once at a time (per instance),
and while it is working pull-write
will buffer any subsequent writes,
until the buffer has the length of at most max
,
or asyncWrite
has called back.
length
is the current length of the buffer.
item
is a piece of data about to be added to the internal buffer,
lengthReduce
must return the length of the buffer plus this item.
if lengthReduce
is not provided, it will default to count the number of elements in the buffer.
A number, when the internal buffer gets this big it will stop reading more, until asyncWrite calls back.
Suppose we want a to take a stream of values from one leveldb, and write it to another. If we have the timestamp they where written to the first, we can track that in the second, then it's easy to keep them both up to date. We just need to always output latest ts separately.
var Write = require('pull-write')
var LevelWrite = function (db, cb) {
var max = 100
return Write(function (ary, cb) {
var ts = 0
ary.map(function (e) {
ts = Math.max(ts, e.ts)
e.type = 'put'
})
//assuming that the incoming data always has a timestamp,
//write that out to be queried separately.
ary.push({key: '~meta~ts', value: ts, type: 'put'})
db.batch(ary, cb)
}, function (len, data) {
//since data is json and we havn't serialized it yet,
//just keep a count instead of calculating the exact length.
//if the input was buffers, it would be easy to calculate the length.
return len + 1
}, max, cb)
}
MIT
FAQs
base class for creating generic pull-sinks that write to some device via an async call.
The npm package pull-write receives a total of 141 weekly downloads. As such, pull-write popularity was classified as not popular.
We found that pull-write demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.
Security News
A new Rust RFC proposes "Trusted Publishing" for Crates.io, introducing short-lived access tokens via OIDC to improve security and reduce risks associated with long-lived API tokens.