How to use the iamap.create function in iamap

To help you get started, we’ve selected a few iamap examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rvagg / js-ipld-hashmap / ipld-hashmap.js View on Github external
throw new TypeError('HashMap.create() requires a \'hasher\' function and a \'hashBytes\' integer to use a custom \'hashAlg\'')
  }
  IAMap.registerHasher(hashAlg, hashBytes, hasher)

  const bitWidth = fromOptions('bitWidth', 'number', DEFAULT_BITWIDTH)
  const bucketSize = fromOptions('bucketSize', 'number', DEFAULT_BUCKET_SIZE)

  const iamapOptions = { hashAlg, bitWidth, bucketSize }

  let iamap
  if (CID.isCID(root)) {
    // load existing, ignoring bitWidth & bucketSize, they are loaded from the existing root
    iamap = await IAMap.load(store, root)
  } else {
    // create new
    iamap = await IAMap.create(store, iamapOptions)
  }

  return new HashMap(iamap)
}

iamap

An **I**mmutable **A**synchronous **Map**.

Apache-2.0
Latest version published 4 months ago

Package Health Score

61 / 100
Full package analysis