@iota/converter
Advanced tools
Comparing version 1.0.0-alpha.1 to 1.0.0-alpha.42086419
"use strict"; | ||
exports.__esModule = true; | ||
var _1 = require("./"); | ||
var errors = require("./errors"); | ||
var _1 = require("./"); | ||
/** | ||
@@ -55,8 +55,4 @@ * Converts an ascii encoded string to trytes. | ||
var dec = input[i].charCodeAt(0); | ||
// If not recognizable ASCII character, throw error | ||
if (dec > 255) { | ||
throw new Error(errors.INVALID_ASCII_CHARS); | ||
} | ||
trytes += _1.TRYTE_ALPHABET[dec % 27]; | ||
trytes += _1.TRYTE_ALPHABET[(dec - dec % 27) / 27]; | ||
trytes += _1.TRYTE_ALPHABET[(dec - (dec % 27)) / 27]; | ||
} | ||
@@ -63,0 +59,0 @@ return trytes; |
@@ -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 @@ } |
"use strict"; | ||
exports.__esModule = true; | ||
var ava_1 = require("ava"); | ||
var src_1 = require("../src"); | ||
var errors_1 = require("../src/errors"); | ||
var src_1 = require("../src"); | ||
ava_1["default"]('asciiToTrytes()', function (t) { | ||
@@ -7,0 +7,0 @@ var ascii = 'IOTA'; |
"use strict"; | ||
exports.__esModule = true; | ||
var ava_1 = require("ava"); | ||
var src_1 = require("../src"); | ||
var errors = require("../src/errors"); | ||
var src_1 = require("../src"); | ||
var INVALID_ODD_LENGTH = errors.INVALID_ODD_LENGTH, INVALID_TRYTES = errors.INVALID_TRYTES; | ||
@@ -7,0 +7,0 @@ ava_1["default"]('trytesToAscii()', function (t) { |
{ | ||
"name": "@iota/converter", | ||
"version": "1.0.0-alpha.1", | ||
"version": "1.0.0-alpha.42086419", | ||
"description": "Convert values & trytes to trits and back", | ||
@@ -11,6 +11,6 @@ "main": "./out/src/index.js", | ||
"scripts": { | ||
"prepublish": "tsc", | ||
"prepare": "tsc", | ||
"test": "tsc && nyc ava", | ||
"test-ci": "nyc ava", | ||
"format": "prettier", | ||
"lint": "tslint --project .", | ||
"docs": "tsc && jsdoc2md --no-cache --plugin dmd-clear -t README_tpl.hbs --files './out/**/*.js' > README.md" | ||
@@ -17,0 +17,0 @@ }, |
@@ -0,3 +1,3 @@ | ||
import { TRYTE_ALPHABET } from './' | ||
import * as errors from './errors' | ||
import { TRYTE_ALPHABET } from './' | ||
@@ -57,9 +57,4 @@ /** | ||
// If not recognizable ASCII character, throw error | ||
if (dec > 255) { | ||
throw new Error(errors.INVALID_ASCII_CHARS) | ||
} | ||
trytes += TRYTE_ALPHABET[dec % 27] | ||
trytes += TRYTE_ALPHABET[(dec - dec % 27) / 27] | ||
trytes += TRYTE_ALPHABET[(dec - (dec % 27)) / 27] | ||
} | ||
@@ -66,0 +61,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 @@ } |
import test from 'ava' | ||
import { asciiToTrytes } from '../src' | ||
import { INVALID_ASCII_CHARS } from '../src/errors' | ||
import { asciiToTrytes } from '../src' | ||
@@ -5,0 +5,0 @@ test('asciiToTrytes()', t => { |
import test from 'ava' | ||
import { trytesToAscii } from '../src' | ||
import * as errors from '../src/errors' | ||
import { trytesToAscii } from '../src' | ||
@@ -5,0 +5,0 @@ const { INVALID_ODD_LENGTH, INVALID_TRYTES } = errors |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
63594
32
802