cids
0.5.7

Intro

Installable via npm install --save cids, it can also be used directly in the browser.

Download

The source is available for download from GitHub. Alternatively, you can install using npm:

$ npm install --save cids

You can then require() cids as normal:

const cids = require('cids')

In the Browser

Cids should work in any ES2015 environment out of the box.

Usage:

<script type="text/javascript" src="index.js"></script>

The portable versions of cids, including index.js and index.min.js, are included in the /dist folder. Cids can also be found on unpkg.com under

SerializedCID

Parameters

  1. codec: string:  
  2. version: number:  
  3. multihash: Buffer:  

buffer

The CID as a Buffer

Returns

prefix

Get the prefix of the CID.

Returns

toV0

Convert to a CID of version 0.

Returns

toV1

Convert to a CID of version 1.

Returns

toBaseEncodedString

Encode the CID into a string.

Parameters

  1. base: string (='base58btc'):  
    Base encoding to use.

Returns

toJSON

Serialize to a plain object.

equals

Compare equality with another CID.

Parameters

  1. other: CID:  

Returns

bool

validateCID

Test if the given input is a valid CID object. Throws if it is not.

Parameters

  1. other: any:  

Returns

void

CID

Class representing a CID <mbase><version><mcodec><mhash> , as defined in ipld/cid.

static

CID.isCID

isCID(other: any): bool

Test if the given input is a CID.

Parameters

  1. other: any:  

Returns

bool

instance

CID.prototype.codec

codec: string

CID.prototype.version

version: number

CID.prototype.multihash

multihash: Buffer

checkCIDComponents

Test if the given input is a valid CID object. Returns an error message if it is not. Returns undefined if it is a valid CID.

Parameters

  1. other: any:  

Returns