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

@darkwolf/base58

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@darkwolf/base58 - npm Package Compare versions

Comparing version 13.21.71 to 13.21.72

10

index.js

@@ -6,6 +6,6 @@ const constants = require('./constants')

function base58(alphabet) {
if (!validator.isString(alphabet) || !validator.isAlphabet(alphabet)) throw new Base58Error('invalid-alphabet', `"alphabet" argument must be a non-empty alphabetical string consisting of characters in the range: [${constants.BITCOIN_ALPHABET}]`)
if (!(validator.isNonEmptyString(alphabet) && validator.isAlphabet(alphabet))) throw new Base58Error('invalid-alphabet', `"alphabet" argument must be a non-empty alphabetical string consisting of characters in the range: [${constants.BITCOIN_ALPHABET}]`)
function encode(input) {
if (!validator.isString(input) || !validator.isASCII(input)) throw new Base58Error('invalid-input', '"input" argument must be a non-empty ASCII encoded string')
if (!(validator.isNonEmptyString(input) && validator.isASCII(input))) throw new Base58Error('invalid-input', '"input" argument must be a non-empty ASCII encoded string')
return Buffer.from(input).reduce((bytes, carry, i) => {

@@ -25,3 +25,3 @@ if (!(carry || bytes.length ^ i)) bytes.push(1)

function decode(input) {
if (!validator.isString(input) || !validator.isBase58(input)) throw new Base58Error('invalid-input', '"input" argument must be a non-empty Base58 encoded string')
if (!(validator.isNonEmptyString(input) && validator.isBase58(input))) throw new Base58Error('invalid-input', '"input" argument must be a non-empty Base58 encoded string')
return String.fromCharCode(...input.split('').map(o => alphabet.indexOf(o)).reduce((bytes, carry, i) => {

@@ -41,3 +41,3 @@ if (!(carry || bytes.length ^ i)) bytes.push(0)

function encodeInt(input) {
if (!validator.isSafeInteger(input) || !validator.isNonNegative(input)) throw new Base58Error('invalid-input', '"input" argument must be a non-negative safe integer')
if (!(validator.isSafeInteger(input) && validator.isNonNegative(input))) throw new Base58Error('invalid-input', '"input" argument must be a non-negative safe integer')
let int = input

@@ -55,3 +55,3 @@ let str = ''

function decodeInt(input) {
if (!validator.isString(input) || !validator.isBase58(input)) throw new Base58Error('invalid-input', '"input" argument must be a non-empty Base58 encoded string')
if (!(validator.isNonEmptyString(input) && validator.isBase58(input))) throw new Base58Error('invalid-input', '"input" argument must be a non-empty Base58 encoded string')
return input.split('').reverse().reduce((int, char, i) => int + alphabet.indexOf(char) * Math.pow(58, i), 0)

@@ -58,0 +58,0 @@ }

{
"name": "@darkwolf/base58",
"version": "13.21.71",
"version": "13.21.72",
"description": "Base58",

@@ -26,4 +26,4 @@ "main": "index.js",

"@darkwolf/code-error": "^13.21.69",
"@darkwolf/validator": "^13.21.69"
"@darkwolf/validator": "^13.21.70"
}
}
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