@lazy-ipfs/detect-cid-lib
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

README.md

detect input cid is js-multiformats or js-cid

install

yarn add @lazy-ipfs/detect-cid-lib
yarn-tool add @lazy-ipfs/detect-cid-lib
yt add @lazy-ipfs/detect-cid-lib
import typeofCID, { EnumTypeofCID, isJsCID, isMultiformatsCID } from '@lazy-ipfs/detect-cid-lib';
import JsCID from 'cids';
import { CID as MultiformatsCID } from 'multiformats';

describe(`describe`, () =>
{

	test(EnumTypeofCID.js_cid, () =>
	{
		const cid = new JsCID('bafybeidw5mmxmimpuzo7wiwmhwvea2zalug5djderubacu2aqnneva6zwy');

		let actual = typeofCID(cid);
		let expected = EnumTypeofCID.js_cid;

		console.dir(cid)

		expect(cid.multihash).toMatchSnapshot();
		expect(cid).toMatchSnapshot();
		expect(actual).toStrictEqual(expected);
		expect(isJsCID(cid)).toBeTruthy();

	});

	test(EnumTypeofCID.multiformats_cid, () =>
	{
		const cid = MultiformatsCID.parse('bafybeidw5mmxmimpuzo7wiwmhwvea2zalug5djderubacu2aqnneva6zwy');

		let actual = typeofCID(cid);
		let expected = EnumTypeofCID.multiformats_cid;

		console.dir(cid)

		expect(cid.multihash).toMatchSnapshot();
		expect(cid).toMatchSnapshot();
		expect(actual).toStrictEqual(expected);
		expect(isMultiformatsCID(cid)).toBeTruthy();

	});

})

Package Sidebar

Install

npm i @lazy-ipfs/detect-cid-lib

Weekly Downloads

3

Version

1.1.1

License

ISC

Unpacked Size

31.6 kB

Total Files

18

Last publish

Collaborators

  • bluelovers