Socket
Socket
Sign inDemoInstall

@chronark/prefixed-id

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@chronark/prefixed-id - npm Package Compare versions

Comparing version 0.3.5 to 0.3.6

2

CHANGELOG.md

@@ -7,4 +7,2 @@ # Changelog

# [0.3.0](https://github.com/chronark/libs/compare/prefixed-id-0.2.0...prefixed-id-0.3.0) (2021-11-24)

@@ -11,0 +9,0 @@

8

package.json
{
"name": "@chronark/prefixed-id",
"version": "0.3.5",
"version": "0.3.6",
"main": "./src/index.js",
"typings": "./src/index.d.ts"
"typings": "./src/index.d.ts",
"dependencies": {
"base-x": "^3.0.9"
},
"peerDependencies": {}
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.encodeBase58 = void 0;
const tslib_1 = require("tslib");
const base_x_1 = tslib_1.__importDefault(require("base-x"));
function encodeBase58(buf) {
const alphabet = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
let encoding = false;
let zeroCounter = 0;
const bytes = [];
let carry = 0;
for (let i = 0; i < buf.length; i++) {
if (i > 0 && carry === 0) {
break;
}
const byte = buf[i];
if (!encoding && byte === 0) {
zeroCounter++;
}
if (byte !== 0) {
encoding = true;
}
if (encoding) {
carry += byte * 256;
}
bytes.push(carry % 58);
carry = Math.floor(carry / 58);
}
return [
...new Array(zeroCounter).fill('1'),
...bytes.map((byte) => alphabet[byte]),
].join('');
return base_x_1.default(alphabet).encode(buf);
}
exports.encodeBase58 = encodeBase58;
// export function encodeBase58(buf: Buffer): string {
// const alphabet = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
// let encoding = false;
// let zeroCounter = 0;
// const bytes: number[] = [];
// let carry = 0;
// for (let i = 0; i < buf.length; i++) {
// if (i > 0 && carry === 0) {
// break;
// }
// const byte = buf[i];
// if (!encoding && byte === 0) {
// zeroCounter++;
// }
// if (byte !== 0) {
// encoding = true;
// }
// if (encoding) {
// carry += byte * 256;
// }
// bytes.push(carry % 58);
// carry = Math.floor(carry / 58);
// }
// return [
// ...new Array(zeroCounter).fill('1'),
// ...bytes.map((byte) => alphabet[byte]),
// ].join('');
// }
//# sourceMappingURL=encoding.js.map

@@ -38,2 +38,3 @@ "use strict";

exports.IdGenerator = IdGenerator;
new IdGenerator({ user: 'u' }).id('user');
//# sourceMappingURL=prefixed-id.js.map

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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