0.1.0 • Published 2 years ago

cache-blockstore v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Cache Blockstore

An IPLD Blockstore on top of the browser CacheStorage API

Install

npm i cache-blockstore

Usage

import {Cachestore} from "cache-blockstore";
import * as Block from 'multiformats/block'
import * as codec from '@ipld/dag-cbor'
import { sha256 as hasher } from 'multiformats/hashes/sha2'

const value = { hello: 'world' }

(async () => {
  const store = new Cachestore("/my-app/blocks");

  await store.open();

  // encode a block
  let block = await Block.encode({ value, codec, hasher })

  await store.put(block.cid, block.bytes);
}());