const SPACE = /[^ ]+/g

// Field-length norm: the shorter the field, the higher the weight.
// Set to 3 decimals to reduce index size.
export default function norm(mantissa = 3) {
  const cache = new Map()

  return {
    get(value) {
      const numTokens = value.match(SPACE).length

      if (cache.has(numTokens)) {
        return cache.get(numTokens)
      }

      const n = parseFloat((1 / Math.sqrt(numTokens)).toFixed(mantissa))

      cache.set(numTokens, n)

      return n
    },
    clear() {
      cache.clear()
    }
  }
}

@@ -198,16 +198,51 @@
 ew Map()
+%0A  const m = Math.pow(10, mantissa)
 %0A%0A  retu
@@ -410,23 +410,14 @@
 st n
+orm
  = 
-parseFloat((
 1 / 
@@ -440,27 +440,126 @@
 ens)
-).toFixed(mantissa)
+%0A%0A      // In place of %60toFixed(mantissa)%60, for faster computation%0A      const n = parseFloat(Math.round(norm * m) / m
 )%0A%0A 

change toFixed to use rounding