Gathering detailed insights and metrics for level-codec
Gathering detailed insights and metrics for level-codec
Gathering detailed insights and metrics for level-codec
Gathering detailed insights and metrics for level-codec
@types/level-codec
TypeScript definitions for level-codec
encoding-down
An abstract-leveldown implementation that wraps another store to encode keys and values
@smithy/eventstream-codec
[![NPM version](https://img.shields.io/npm/v/@smithy/eventstream-codec/latest.svg)](https://www.npmjs.com/package/@smithy/eventstream-codec) [![NPM downloads](https://img.shields.io/npm/dm/@smithy/eventstream-codec.svg)](https://www.npmjs.com/package/@smi
@jridgewell/sourcemap-codec
Encode/decode sourcemap mappings
Encode keys, values and range options, with built-in or custom encodings.
npm install level-codec
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
27 Stars
145 Commits
7 Forks
12 Watching
2 Branches
16 Contributors
Updated on 02 Jun 2022
Minified
Minified + Gzipped
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
26%
286,066
Compared to previous day
Last week
13.3%
1,388,837
Compared to previous week
Last month
11.9%
4,938,170
Compared to previous month
Last year
1%
29,857,773
Compared to previous year
1
Encode keys, values and range options, with built-in or custom encodings.
:pushpin: This module will soon be deprecated, because it is superseded by
level-transcoder
.
If you are upgrading: please see UPGRADING.md
.
1const Codec = require('level-codec') 2const codec = Codec({ keyEncoding: 'json' }) 3const key = codec.encodeKey({ foo: 'bar' }) 4console.log(key) // -> '{"foo":"bar"}' 5console.log(codec.decodeKey(key)) // -> { foo: 'bar' }
codec = Codec([opts])
Create a new codec, with a global options object.
codec.encodeKey(key[, opts])
Encode key
with given opts
.
codec.encodeValue(value[, opts])
Encode value
with given opts
.
codec.encodeBatch(batch[, opts])
Encode batch
ops with given opts
.
codec.encodeLtgt(ltgt)
Encode the ltgt values of option object ltgt
.
codec.decodeKey(key[, opts])
Decode key
with given opts
.
codec.decodeValue(value[, opts])
Decode value
with given opts
.
codec.createStreamDecoder([opts])
Create a function with signature (key, value)
, that for each key-value pair returned from a levelup read stream returns the decoded value to be emitted.
codec.keyAsBuffer([opts])
Check whether opts
and the global opts
call for a binary key encoding.
codec.valueAsBuffer([opts])
Check whether opts
and the global opts
call for a binary value encoding.
codec.encodings
The builtin encodings as object of form
1{ 2 [type]: encoding 3}
See below for a list and the format of encoding
.
Type | Input | Stored as | Output |
---|---|---|---|
utf8 | String or Buffer | String or Buffer | String |
json | Any JSON type | JSON string | Input |
binary | Buffer, string or byte array | Buffer | As stored |
hex ascii base64 ucs2 utf16le utf-16le | String or Buffer | Buffer | String |
none a.k.a. id | Any type (bypass encoding) | Input* | As stored |
* Stores may have their own type coercion. Whether type information is preserved depends on the abstract-leveldown
implementation as well as the underlying storage (LevelDB
, IndexedDB
, etc).
An encoding is an object of the form:
1{ 2 encode: function (data) { 3 return data 4 }, 5 decode: function (data) { 6 return data 7 }, 8 buffer: Boolean, 9 type: 'example' 10}
All of these properties are required.
The buffer
boolean tells consumers whether to fetch data as a Buffer, before calling your decode()
function on that data. If buffer
is true, it is assumed that decode()
takes a Buffer. If false, it is assumed that decode
takes any other type (usually a string).
To explain this in the grand scheme of things, consider a store like leveldown
which has the ability to return either a Buffer or string, both sourced from the same byte array. Wrap this store with encoding-down
and it'll select the most optimal data type based on the buffer
property of the active encoding. If your decode()
function needs a string (and the data can legitimately become a UTF8 string), you should set buffer
to false
. This avoids the cost of having to convert a Buffer to a string.
The type
string should be a unique name.
Level/codec
is an OPEN Open Source Project. This means that:
Individuals making significant and valuable contributions are given commit-access to the project to contribute as they see fit. This project is more like an open wiki than a standard guarded open source project.
See the Contribution Guide for more details.
To sustain Level
and its activities, become a backer or sponsor on Open Collective. Your logo or avatar will be displayed on our 28+ GitHub repositories and npm packages. 💖
MIT © 2012-present Contributors.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 4/17 approved changesets -- score normalized to 2
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
security policy file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More