@iota/converter
Advanced tools
Comparing version 1.0.0-beta.5 to 1.0.0-beta.722117ce
"use strict"; | ||
exports.__esModule = true; | ||
var errors = require("./errors"); | ||
var _1 = require("./"); | ||
var trits_1 = require("./trits"); | ||
/** | ||
@@ -55,4 +55,4 @@ * Converts an ascii encoded string to trytes. | ||
var dec = input[i].charCodeAt(0); | ||
trytes += _1.TRYTE_ALPHABET[dec % 27]; | ||
trytes += _1.TRYTE_ALPHABET[(dec - dec % 27) / 27]; | ||
trytes += trits_1.TRYTE_ALPHABET[dec % 27]; | ||
trytes += trits_1.TRYTE_ALPHABET[(dec - dec % 27) / 27]; | ||
} | ||
@@ -81,3 +81,3 @@ return trytes; | ||
for (var i = 0; i < trytes.length; i += 2) { | ||
ascii += String.fromCharCode(_1.TRYTE_ALPHABET.indexOf(trytes[i]) + _1.TRYTE_ALPHABET.indexOf(trytes[i + 1]) * 27); | ||
ascii += String.fromCharCode(trits_1.TRYTE_ALPHABET.indexOf(trytes[i]) + trits_1.TRYTE_ALPHABET.indexOf(trytes[i + 1]) * 27); | ||
} | ||
@@ -84,0 +84,0 @@ return ascii; |
@@ -92,3 +92,3 @@ "use strict"; | ||
function trytes(trits) { | ||
if (!(trits instanceof Int8Array)) { | ||
if (!(trits instanceof Int8Array) && !Array.isArray(trits)) { | ||
throw new Error(errors.INVALID_TRITS); | ||
@@ -95,0 +95,0 @@ } |
{ | ||
"name": "@iota/converter", | ||
"version": "1.0.0-beta.5", | ||
"version": "1.0.0-beta.722117ce", | ||
"description": "Convert values & trytes to trits and back", | ||
@@ -5,0 +5,0 @@ "main": "./out/src/index.js", |
import * as errors from './errors' | ||
import { TRYTE_ALPHABET } from './' | ||
import { TRYTE_ALPHABET } from './trits' | ||
@@ -4,0 +4,0 @@ /** |
@@ -96,3 +96,3 @@ import * as errors from './errors' | ||
export function trytes(trits: Int8Array): string { | ||
if (!(trits instanceof Int8Array)) { | ||
if (!(trits instanceof Int8Array) && !Array.isArray(trits)) { | ||
throw new Error(errors.INVALID_TRITS) | ||
@@ -99,0 +99,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
63428