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

level-codec

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

level-codec - npm Package Compare versions

Comparing version 2.0.1 to 3.0.0

2

lib/decode-key.js

@@ -5,5 +5,5 @@ var encodings = require('./encodings');

module.exports = function decodeKey(key, optionObjects){
var encoding = walk(optionObjects, ['keyEncoding']) || 'utf8';
var encoding = walk(optionObjects, 'keyEncoding') || 'utf8';
if (typeof encoding == 'string') encoding = encodings[encoding];
return encoding.decode(key);
};

@@ -5,3 +5,3 @@ var encodings = require('./encodings');

module.exports = function decodeValue(value, optionObjects){
var encoding = walk(optionObjects, ['valueEncoding', 'encoding']) || 'utf8';
var encoding = walk(optionObjects, 'valueEncoding') || 'utf8';
if (typeof encoding == 'string') encoding = encodings[encoding];

@@ -8,0 +8,0 @@ return encoding.decode(value);

@@ -5,5 +5,5 @@ var encodings = require('./encodings');

module.exports = function encodeKey(key, optionObjects){
var encoding = walk(optionObjects, ['keyEncoding']) || 'utf8';
var encoding = walk(optionObjects, 'keyEncoding') || 'utf8';
if (typeof encoding == 'string') encoding = encodings[encoding];
return encoding.encode(key);
};

@@ -5,3 +5,3 @@ var encodings = require('./encodings');

module.exports = function encodeValue(value, optionObjects){
var encoding = walk(optionObjects, ['valueEncoding', 'encoding']) || 'utf8';
var encoding = walk(optionObjects, 'valueEncoding') || 'utf8';
if (typeof encoding == 'string') encoding = encodings[encoding];

@@ -8,0 +8,0 @@ return encoding.encode(value);

@@ -5,5 +5,5 @@ var encodings = require('./encodings');

module.exports = function keyAsBuffer(optionObjects){
var encoding = walk(optionObjects, ['keyEncoding']) || 'utf8';
var encoding = walk(optionObjects, 'keyEncoding') || 'utf8';
if (typeof encoding == 'string') encoding = encodings[encoding];
return encoding.buffer;
};

@@ -5,5 +5,5 @@ var encodings = require('./encodings');

module.exports = function valueAsBuffer(optionObjects){
var encoding = walk(optionObjects, ['valueEncoding', 'encoding']) || 'utf8';
var encoding = walk(optionObjects, 'valueEncoding') || 'utf8';
if (typeof encoding == 'string') encoding = encodings[encoding];
return encoding.buffer;
};
module.exports = function walk(objects, keys){
module.exports = function walk(objects, key){
var value;
var key;
var object;
for (var i = objects.length - 1; i >= 0; i--) {
object = objects[i];
for (var j = keys.length - 1; j >= 0; j--) {
key = keys[j];
if (object[key]) value = object[key];
}
if (objects[i][key]) value = objects[i][key];
}
return value;
};
{
"name": "level-codec",
"repository": "Level/codec",
"version": "2.0.1",
"version": "3.0.0",
"description": "Levelup's encoding logic",

@@ -6,0 +6,0 @@ "license": "MIT",

@@ -7,3 +7,3 @@ var test = require('tape');

[{ keyEncoding: 'utf8' }],
['keyEncoding', 'encoding']
'keyEncoding'
), 'utf8');

@@ -13,17 +13,7 @@

[{ keyEncoding: 'binary' }, { keyEncoding: 'utf8' }],
['keyEncoding', 'encoding']
'keyEncoding'
), 'binary');
t.equal(walk(
[{ keyEncoding: 'utf8', encoding: 'buffer' }],
['keyEncoding', 'encoding']
), 'utf8');
t.equal(walk(
[{ encoding: 'utf8' }, { keyEncoding: 'buffer', encoding: 'hex' }],
['keyEncoding', 'encoding']
), 'utf8');
t.end();
});
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