Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

z32

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

z32 - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

benchmark.js

30

index.js
const b4a = require('b4a')
const ALPHABET = 'ybndrfg8ejkmcpqxot1uwisza345h769'.split('')
const MIN = 49 // 0
const MAX = 122 // z
const ALPHABET = 'ybndrfg8ejkmcpqxot1uwisza345h769'
const MIN = 0x31 // 1
const MAX = 0x7a // z
const REVERSE = new Int8Array(1 + MAX - MIN)

@@ -11,3 +11,3 @@

for (let i = 0; i < ALPHABET.length; i++) {
const v = ALPHABET[i].charCodeAt(0) - MIN
const v = ALPHABET.charCodeAt(i) - MIN
REVERSE[v] = i

@@ -39,6 +39,6 @@ }

out[pb++] = (a << 3) | (b >> 2)
out[pb++] = ((b & 0b11) << 6) | (c << 1) | (d >> 4)
out[pb++] = ((d & 0b1111) << 4) | (e >> 1)
out[pb++] = ((e & 0b1) << 7) | (f << 2) | (g >> 3)
out[pb++] = (a << 3) | (b >>> 2)
out[pb++] = ((b & 0b11) << 6) | (c << 1) | (d >>> 4)
out[pb++] = ((d & 0b1111) << 4) | (e >>> 1)
out[pb++] = ((e & 0b1) << 7) | (f << 2) | (g >>> 3)
out[pb++] = ((g & 0b111) << 5) | h

@@ -52,3 +52,3 @@ }

out[pb++] = (a << 3) | (b >> 2)
out[pb++] = (a << 3) | (b >>> 2)

@@ -60,3 +60,3 @@ if (r <= 2) return out.subarray(0, pb)

out[pb++] = ((b & 0b11) << 6) | (c << 1) | (d >> 4)
out[pb++] = ((b & 0b11) << 6) | (c << 1) | (d >>> 4)

@@ -67,3 +67,3 @@ if (r <= 4) return out.subarray(0, pb)

out[pb++] = ((d & 0b1111) << 4) | (e >> 1)
out[pb++] = ((d & 0b1111) << 4) | (e >>> 1)

@@ -75,3 +75,3 @@ if (r <= 5) return out.subarray(0, pb)

out[pb++] = ((e & 0b1) << 7) | (f << 2) | (g >> 3)
out[pb++] = ((e & 0b1) << 7) | (f << 2) | (g >>> 3)

@@ -95,7 +95,7 @@ if (r <= 7) return out.subarray(0, pb)

for (let p = 0; p < max; p += 5) {
const i = p >> 3
const i = p >>> 3
const j = p & 7
if (j <= 3) {
s += ALPHABET[(buf[i] >> (3 - j)) & 0b11111]
s += ALPHABET[(buf[i] >>> (3 - j)) & 0b11111]
continue

@@ -106,3 +106,3 @@ }

const h = (buf[i] << of) & 0b11111
const l = (i >= buf.length ? 0 : buf[i + 1]) >> (8 - of)
const l = (i >= buf.byteLength ? 0 : buf[i + 1]) >>> (8 - of)

@@ -109,0 +109,0 @@ s += ALPHABET[h | l]

{
"name": "z32",
"version": "1.0.0",
"version": "1.0.1",
"description": "Encode & decode z-base32",

@@ -10,3 +10,7 @@ "main": "index.js",

"devDependencies": {
"brittle": "^2.0.0",
"base-x": "^4.0.0",
"base32": "0.0.7",
"brittle": "^3.1.3",
"nanobench": "^3.0.0",
"rfc4648": "^1.5.2",
"standard": "^17.0.0"

@@ -19,3 +23,4 @@ },

"scripts": {
"test": "standard && brittle test.js"
"test": "standard && brittle test.js",
"bench": "node benchmark.js"
},

@@ -22,0 +27,0 @@ "author": "Mathias Buus (@mafintosh)",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc