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

linkdex

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

linkdex - npm Package Compare versions

Comparing version 1.0.1 to 2.0.0

4

decode.js

@@ -28,4 +28,8 @@ import * as Block from 'multiformats/block'

if (codec) {
if (cid.multihash.code === 0x0) {
// A CAR Block iterator would give us an empty bytes array, so use the cid bytes instead
return Block.createUnsafe({ cid, bytes: cid.multihash.digest, codec })
}
return Block.createUnsafe({ cid, bytes, codec })
}
}

24

dist/index.d.ts

@@ -29,3 +29,3 @@ /** @typedef { 'Complete' | 'Partial' | 'Unknown' } DagStructure */

idx: Map<string, Set<string>>;
indexed: number;
blocksIndexed: number;
undecodable: number;

@@ -36,3 +36,3 @@ /**

* @param {object} [opts]
* @param {import('./decode.js').BlockDecoders} [opts.codecs]
* @param {import('./decode.js').BlockDecoders} [opts.codecs] - bring your own codecs
*/

@@ -43,2 +43,14 @@ decodeAndIndex({ cid, bytes }: import('@ipld/car/api').Block, opts?: {

/**
* Decode and index identity CID but don't count it as a block.
* Where a link is an identity cid, The bytes are in the CID!
* We consider a CAR complete even if an identity CID appears only as a link, not a block entry.
* To make that work we index it, but don't count it as a block.
* @param {import('multiformats/cid').CID} cid
* @param {object} [opts]
* @param {import('./decode.js').BlockDecoders} [opts.codecs] - bring your own codecs
*/
_decodeAndIndexIdentityCidLink(cid: import('multiformats/cid').CID, opts?: {
codecs?: import("./decode.js").BlockDecoders | undefined;
} | undefined): void;
/**
* Index all the links from the block

@@ -62,4 +74,4 @@ * @param {import('multiformats/block').Block<?>} block

* @property {number} blocksIndexed - How many blocks were indexed
* @property {number} blocksUnique - How many unique CIDs
* @property {number} blocksUndecodeable - How many blocks failed to decode
* @property {number} uniqueCids - How many unique CIDs
* @property {number} undecodeable - How many blocks/CIDs failed to decode
*/

@@ -73,4 +85,4 @@ /**

blocksIndexed: number;
blocksUnique: number;
blocksUndecodeable: number;
uniqueCids: number;
undecodeable: number;
};

@@ -77,0 +89,0 @@ }

@@ -50,3 +50,3 @@ import { CarBlockIterator } from '@ipld/car/iterator'

this.idx = new Map()
this.indexed = 0
this.blocksIndexed = 0
this.undecodable = 0

@@ -59,3 +59,3 @@ }

* @param {object} [opts]
* @param {import('./decode.js').BlockDecoders} [opts.codecs]
* @param {import('./decode.js').BlockDecoders} [opts.codecs] - bring your own codecs
*/

@@ -68,2 +68,3 @@ decodeAndIndex ({ cid, bytes }, opts) {

this._index(block)
this.blocksIndexed++
}

@@ -73,2 +74,21 @@ }

/**
* Decode and index identity CID but don't count it as a block.
* Where a link is an identity cid, The bytes are in the CID!
* We consider a CAR complete even if an identity CID appears only as a link, not a block entry.
* To make that work we index it, but don't count it as a block.
* @param {import('multiformats/cid').CID} cid
* @param {object} [opts]
* @param {import('./decode.js').BlockDecoders} [opts.codecs] - bring your own codecs
*/
_decodeAndIndexIdentityCidLink (cid, opts) {
const block = maybeDecode({ cid, bytes: cid.multihash.digest }, opts)
if (!block) {
this.undecodable++
} else {
this._index(block)
// do not increment this.blocksIndexed here as its a link.
}
}
/**
* Index all the links from the block

@@ -78,3 +98,2 @@ * @param {import('multiformats/block').Block<?>} block

_index (block) {
this.indexed++
const key = block.cid.toString()

@@ -87,2 +106,5 @@ if (this.idx.has(key)) {

targets.add(targetCid.toString())
if (targetCid.multihash.code === 0x0) {
this._decodeAndIndexIdentityCidLink(targetCid)
}
}

@@ -131,4 +153,4 @@ this.idx.set(key, targets)

* @property {number} blocksIndexed - How many blocks were indexed
* @property {number} blocksUnique - How many unique CIDs
* @property {number} blocksUndecodeable - How many blocks failed to decode
* @property {number} uniqueCids - How many unique CIDs
* @property {number} undecodeable - How many blocks/CIDs failed to decode
*/

@@ -143,7 +165,7 @@

structure: this.getDagStructureLabel(),
blocksIndexed: this.indexed,
blocksUnique: this.idx.size,
blocksUndecodeable: this.undecodable
blocksIndexed: this.blocksIndexed,
uniqueCids: this.idx.size,
undecodeable: this.undecodable
}
}
}
{
"name": "linkdex",
"version": "1.0.1",
"version": "2.0.0",
"type": "module",

@@ -5,0 +5,0 @@ "description": "An index mapping block CID to linked block CID.",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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