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

@ipld/codec-interface

Package Overview
Dependencies
Maintainers
3
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ipld/codec-interface - npm Package Compare versions

Comparing version 1.0.4 to 1.0.5

4

index.js

@@ -89,7 +89,7 @@ 'use strict'

}
async reader (block) {
reader (block) {
// Skip a decoding if the source is available.
if (block.source && block.source()) return new Reader(block.source())
// Full decoding is required for the standard Reader interface
let decoded = await block.decode()
let decoded = block.decode()
return new Reader(decoded)

@@ -96,0 +96,0 @@ }

{
"name": "@ipld/codec-interface",
"version": "1.0.4",
"version": "1.0.5",
"description": "Codec interface for IPLD.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -12,3 +12,3 @@ 'use strict'

/* very bad dag codec for testing */
const encode = async obj => {
const encode = obj => {
for (let key of Object.keys(obj)) {

@@ -22,3 +22,3 @@ if (key.startsWith('link:')) {

}
const decode = async buffer => {
const decode = buffer => {
let obj = JSON.parse(buffer.toString())

@@ -41,4 +41,4 @@ for (let key of Object.keys(obj)) {

let codec = create()
let buffer = await codec.encode({ hello: 'world' })
let obj = await codec.decode(buffer)
let buffer = codec.encode({ hello: 'world' })
let obj = codec.decode(buffer)
same(obj, { hello: 'world' })

@@ -45,0 +45,0 @@ })

@@ -28,3 +28,3 @@ 'use strict'

test('get path', async () => {
let reader = await getReader()
let reader = getReader()
let one = reader.get('/a/1').value

@@ -38,6 +38,6 @@ same(one, 1)

test('source optimization', async () => {
let reader = await mock.reader({ source: () => fixture })
let reader = mock.reader({ source: () => fixture })
let one = reader.get('/a/1').value
same(one, 1)
reader = await mock.reader({ source: () => null, decode: () => fixture })
reader = mock.reader({ source: () => null, decode: () => fixture })
one = reader.get('/a/1').value

@@ -48,3 +48,3 @@ same(one, 1)

test('links', async () => {
let reader = await getReader()
let reader = getReader()
let links = Array.from(reader.links())

@@ -57,3 +57,3 @@ let keys = new Set(links.map(a => a[0]))

test('tree', async () => {
let reader = await getReader()
let reader = getReader()
let tree = Array.from(reader.tree())

@@ -78,3 +78,3 @@ same(new Set(tree), new Set([

test('property not found', async () => {
let reader = await getReader()
let reader = getReader()
let threw = false

@@ -81,0 +81,0 @@ try {

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