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

dat-encoding

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dat-encoding - npm Package Compare versions

Comparing version 2.0.2 to 2.1.0

3

index.js

@@ -9,5 +9,6 @@ 'use strict'

exports.encode = function (buf) {
exports.encode = function (buf, opts) {
if (buf.length !== 32) throw new Error('Invalid buffer')
buf = Buffer.from(buf)
if (opts && opts.legacy) return buf.toString('hex')
var str = encoding.encode(buf)

@@ -14,0 +15,0 @@ while (str.length < 50) str = '0' + str

{
"name": "dat-encoding",
"version": "2.0.2",
"version": "2.1.0",
"license": "MIT",

@@ -5,0 +5,0 @@ "repository": "juliangruber/dat-encoding",

@@ -21,6 +21,8 @@

### .encode(buf)
### .encode(buf[, opts])
Encode `buf` into a string that works well in urls. Throws if `buf` isn't 32 bytes of length.
Encode `buf` into a string that works well in urls. Throws if `buf` isn't 32 bytes of length.
Pass `legacy: true` to create an old style hex encoded link.
### .decode(str)

@@ -27,0 +29,0 @@

@@ -10,2 +10,17 @@ var test = require('tape')

t.equal(enc.encode(Buffer('0100000000000000ffffffff0000000000008004010000004012800201000000', 'hex')), '00waum9lsz88rt2zltcysggj4yc0odk8uwwrq05shegvktfgu8')
t.test('legacy: true', function (t) {
t.equal(
enc.encode(Buffer('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')).length,
50
)
t.equal(
enc.encode(
Buffer('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'),
{ legacy: true }
).length,
64
)
t.end()
})
t.end()

@@ -12,0 +27,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