JSPM

hamming

0.0.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 5497
  • Score
    100M100P100Q120658F
  • License

Calculate the Hamming distance between two strings.

Package Exports

  • hamming

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (hamming) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

hamming

Calculate the Hamming distance between two strings.

The Hamming distance measures the minimum number of substitutions required to change one string into the other of equal length.

Demo

https://lab.miguelmota.com/hamming

Install

npm install hamming

Usage

const hammingDistance = require('hamming');

console.log(hammingDistance('foo', 'foo')); // 0
console.log(hammingDistance('for', 'foo')); // 1
console.log(hammingDistance('foobar', 'fudbaz')); // 3
console.log(hammingDistance('unequal', 'length')); // null

Hamming distance requires both strings to have the same length.

Test

npm test

License

MIT