Socket
Socket
Sign inDemoInstall

base-x

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

base-x - npm Package Compare versions

Comparing version 1.0.4 to 1.1.0

27

index.js

@@ -36,18 +36,13 @@ // base-x encoding

var string = ''
// deal with leading zeros
for (var k = 0; source[k] === 0 && k < source.length - 1; ++k) {
digits.push(0)
}
for (var k = 0; source[k] === 0 && k < source.length - 1; ++k) string += ALPHABET[0]
// convert digits to a string
for (var ii = 0, jj = digits.length - 1; ii <= jj; ++ii, --jj) {
var tmp = ALPHABET[digits[ii]]
digits[ii] = ALPHABET[digits[jj]]
digits[jj] = tmp
}
for (var q = digits.length - 1; q >= 0; --q) string += ALPHABET[digits[q]]
return digits.join('')
return string
}
function decode (string) {
function decodeUnsafe (string) {
if (string.length === 0) return []

@@ -58,3 +53,3 @@

var value = ALPHABET_MAP[string[i]]
if (value === undefined) throw new Error('Non-base' + BASE + ' character')
if (value === undefined) return

@@ -81,6 +76,14 @@ for (var j = 0, carry = value; j < bytes.length; ++j) {

function decode (string) {
var array = decodeUnsafe(string)
if (array) return array
throw new Error('Non-base' + BASE + ' character')
}
return {
encode: encode,
decodeUnsafe: decodeUnsafe,
decode: decode
}
}
{
"name": "base-x",
"version": "1.0.4",
"version": "1.1.0",
"description": "Fast base encoding / decoding of any given alphabet",

@@ -32,3 +32,2 @@ "keywords": [

"scripts": {
"benchmark:node": "node benchmark/benchmark.js",
"standard": "standard",

@@ -39,6 +38,5 @@ "test": "npm run unit && npm run standard",

"devDependencies": {
"benchmark": "^2.0.0",
"standard": "^5.4.1",
"standard": "^6.0.8",
"tape": "^4.5.1"
}
}
# base-x
[![TRAVIS](https://secure.travis-ci.org/cryptocoinjs/base-x.png)](http://travis-ci.org/cryptocoinjs/base-x)
[![NPM](http://img.shields.io/npm/v/base-x.svg)](https://www.npmjs.org/package/base-x)
[![NPM Package](https://img.shields.io/npm/v/base-x.svg?style=flat-square)](https://www.npmjs.org/package/base-x)
[![Build Status](https://img.shields.io/travis/cryptocoinjs/base-x.svg?branch=master&style=flat-square)](https://travis-ci.org/cryptocoinjs/base-x)

@@ -22,2 +22,5 @@ [![js-standard-style](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard)

console.log(decoded)
// => [128,237,219,220,17,104,241,218,234,219,211,228,76,10,106,249,133,131,164,153,222,91,25,19,164,248,99]
console.log(Buffer.from(decoded))
// => <Buffer 80 ed db dc 11 68 f1 da ea db d3 e4 4c 1e 3f 8f 5a 28 4c 20 29 f7 8a d2 6a f9 85 83 a4 99 de 5b 19>

@@ -35,2 +38,4 @@

------------- | -------------
2 | `01`
8 | `01234567`
11 | `0123456789a`

@@ -37,0 +42,0 @@ 16 | `0123456789abcdef`

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