@iov/encoding
Advanced tools
Comparing version 0.14.3 to 0.14.4
@@ -53,3 +53,3 @@ "use strict"; | ||
static fromString(str) { | ||
if (!str.match(/^\-?[0-9]+$/)) { | ||
if (!str.match(/^-?[0-9]+$/)) { | ||
throw new Error("Invalid string format"); | ||
@@ -56,0 +56,0 @@ } |
{ | ||
"name": "@iov/encoding", | ||
"version": "0.14.3", | ||
"version": "0.14.4", | ||
"description": "Encoding helpers for IOV projects", | ||
@@ -18,3 +18,3 @@ "author": "IOV SAS <admin@iov.one>", | ||
"docs": "shx rm -rf docs && typedoc --options typedoc.js", | ||
"lint": "tslint -t verbose --project .", | ||
"lint": "eslint --max-warnings 0 \"**/*.{js,ts}\" && tslint -t verbose --project .", | ||
"format": "prettier --write --loglevel warn \"./src/**/*.ts\"", | ||
@@ -27,3 +27,2 @@ "test-node": "node jasmine-testrunner.js", | ||
"test": "yarn build-or-skip && yarn test-node", | ||
"prebuild": "yarn format", | ||
"move-types": "shx rm -r ./types/* && shx mv build/types/* ./types && shx rm ./types/*.spec.d.ts", | ||
@@ -44,3 +43,3 @@ "build": "shx rm -rf ./build && tsc && yarn move-types", | ||
}, | ||
"gitHead": "93942a81ff274b0bfcc7c01ff9016bd7c6a721ee" | ||
"gitHead": "15f31720ee4eedf9dcb7608134acff3f1facc23b" | ||
} |
@@ -13,3 +13,3 @@ import * as base64js from "base64-js"; | ||
public static toHex(data: Uint8Array): string { | ||
let out: string = ""; | ||
let out = ""; | ||
for (const byte of data) { | ||
@@ -50,3 +50,3 @@ out += ("0" + byte.toString(16)).slice(-2); | ||
public static toAscii(input: string): Uint8Array { | ||
const toNums = (str: string) => | ||
const toNums = (str: string): readonly number[] => | ||
str.split("").map((x: string) => { | ||
@@ -67,3 +67,3 @@ const charCode = x.charCodeAt(0); | ||
public static fromAscii(data: Uint8Array): string { | ||
const fromNums = (listOfNumbers: ReadonlyArray<number>) => | ||
const fromNums = (listOfNumbers: readonly number[]): readonly string[] => | ||
listOfNumbers.map( | ||
@@ -70,0 +70,0 @@ (x: number): string => { |
@@ -32,3 +32,3 @@ /* tslint:disable:no-bitwise */ | ||
constructor(input: number) { | ||
public constructor(input: number) { | ||
if (Number.isNaN(input)) { | ||
@@ -49,3 +49,3 @@ throw new Error("Input is not a number"); | ||
public toBytesBigEndian(): ReadonlyArray<number> { | ||
public toBytesBigEndian(): readonly number[] { | ||
// Use division instead of shifting since bitwise operators are defined | ||
@@ -72,3 +72,3 @@ // on SIGNED int32 in JavaScript and we don't want to risk surprises | ||
public static fromString(str: string): Int53 { | ||
if (!str.match(/^\-?[0-9]+$/)) { | ||
if (!str.match(/^-?[0-9]+$/)) { | ||
throw new Error("Invalid string format"); | ||
@@ -82,3 +82,3 @@ } | ||
constructor(input: number) { | ||
public constructor(input: number) { | ||
if (Number.isNaN(input)) { | ||
@@ -116,3 +116,3 @@ throw new Error("Input is not a number"); | ||
constructor(input: number) { | ||
public constructor(input: number) { | ||
const signed = new Int53(input); | ||
@@ -190,7 +190,7 @@ if (signed.toNumber() < 0) { | ||
public toBytesBigEndian(): ReadonlyArray<number> { | ||
public toBytesBigEndian(): readonly number[] { | ||
return this.data.toArray("be", 8); | ||
} | ||
public toBytesLittleEndian(): ReadonlyArray<number> { | ||
public toBytesLittleEndian(): readonly number[] { | ||
return this.data.toArray("le", 8); | ||
@@ -197,0 +197,0 @@ } |
@@ -9,3 +9,3 @@ interface Integer { | ||
constructor(input: number); | ||
toBytesBigEndian(): ReadonlyArray<number>; | ||
toBytesBigEndian(): readonly number[]; | ||
toNumber(): number; | ||
@@ -34,4 +34,4 @@ toString(): string; | ||
private constructor(); | ||
toBytesBigEndian(): ReadonlyArray<number>; | ||
toBytesLittleEndian(): ReadonlyArray<number>; | ||
toBytesBigEndian(): readonly number[]; | ||
toBytesLittleEndian(): readonly number[]; | ||
toString(): string; | ||
@@ -38,0 +38,0 @@ toNumber(): number; |
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
191669