
Security News
Django Joins curl in Pushing Back on AI Slop Security Reports
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.
level-patch-data
Advanced tools
Store and read object patches (with metadata) in insert order
var concat = require('concat-stream')
var assert = require('assert')
var level = require('level-test')()
var Patch = require('level-patch-data')
var db = level('patch-test', {valueEncoding: 'json'})
var patch = Patch(db)
patch.add('doc', {a: 'a'}, {user: 'lee'}, function (err, commit) {
patch.add('doc', {b: 'c'}, {user: 'kara'}, function (err, commit) {
patch.readStream('doc').pipe(concat(function (body) {
// body is
[ { ts: '2014-06-28T06:05:53.100Z', // timestamp
patch: { a: 'a' },
key: 'docÿ2014-06-28T06:05:53.100Z' }, // namespaced and sorted by ts
{ user: 'lee',
ts: '2014-06-28T06:05:53.113Z',
patch: { b: 'c' },
key: 'docÿ2014-06-28T06:05:53.113Z' } ]
}))
})
})
See tests for more examples.
db
: an instance of levelup
or a sublevel
to store patches and data.
opts.separator
: the string to use as a separator for key fields. default:
'\xff'
opts.timestampField
: the field to use to store the timestamp
. default:
ts
opts.keyField
: the field to use to store the key
. default: key
opts.patchField
: the field to use to store the patch
. default: patch
opts.key
: the function to use to generate each patch's key. Use a custom
key to add some entropy if there is a chance you'll have two commits in the
same millisecond.
// default
opts.key = function (meta, namespace, opts) {
return [namespace, meta[opts.timestampField]].join(opts.separator)
}
alias: addPatch
namespace
: the string to identify this collections of patches. This module
is designed for use with patcher
patches for a single object per unique namespace
patch
: the object to store as the patchmeta
: key/value pairs to store with this patch. Note: the keys
opts.timestampField
, opts.keyField
, and opts.patchField
will be
overwritten if set.callback
: receives two arguments, err
which is only set if an error occurs
and commit
, which is the patch and its metadata exactly as it was saved.aliases: createReadStream
, read
Returns a readable stream that emits patches for namespace
in insert order.
namespace
: the collection of patches to read. patches will be streamed in
the order inserted.since
: optional. pass the key
of the commit to read commits since. The
commit with key === since
will not be returned, only all commits after it.MIT
FAQs
Store and read object patches (with metadata) in insert order
The npm package level-patch-data receives a total of 1 weekly downloads. As such, level-patch-data popularity was classified as not popular.
We found that level-patch-data 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
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.