Skip to content
This repository has been archived by the owner on Jun 17, 2021. It is now read-only.

Fix large string copies #269

Merged
merged 2 commits into from
Jul 31, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import * as ethjsUtil from 'ethjs-util'
* @param {string} input string to check hex prefix of
*/
export const assertIsHexString = function(input: string): void {
const msg = `This method only supports 0x-prefixed hex strings but input was: ${input}`
if (!ethjsUtil.isHexString(input)) {
const msg = `This method only supports 0x-prefixed hex strings but input was: ${input}`
throw new Error(msg)
}
}
Expand All @@ -16,8 +16,8 @@ export const assertIsHexString = function(input: string): void {
* @param {Buffer} input value to check
*/
export const assertIsBuffer = function(input: Buffer): void {
const msg = `This method only supports Buffer but input was: ${input}`
if (!Buffer.isBuffer(input)) {
const msg = `This method only supports Buffer but input was: ${input}`
throw new Error(msg)
}
}
Expand All @@ -27,8 +27,8 @@ export const assertIsBuffer = function(input: Buffer): void {
* @param {number[]} input value to check
*/
export const assertIsArray = function(input: number[]): void {
const msg = `This method only supports number arrays but input was: ${input}`
if (!Array.isArray(input)) {
const msg = `This method only supports number arrays but input was: ${input}`
throw new Error(msg)
}
}
Expand All @@ -38,8 +38,8 @@ export const assertIsArray = function(input: number[]): void {
* @param {string} input value to check
*/
export const assertIsString = function(input: string): void {
const msg = `This method only supports strings but input was: ${input}`
if (typeof input !== 'string') {
const msg = `This method only supports strings but input was: ${input}`
throw new Error(msg)
}
}