Skip to content

Commit ef5d19e

Browse files
committed
More logical interface for hexDataSlice (mimic slice).
1 parent 5f6bc40 commit ef5d19e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src.ts/utils/bytes.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ export function hexDataLength(data: string) {
219219
return (data.length - 2) / 2;
220220
}
221221

222-
export function hexDataSlice(data: string, offset: number, length?: number): string {
222+
export function hexDataSlice(data: string, offset: number, endOffset?: number): string {
223223
if (!isHexString(data)) {
224224
errors.throwError('invalid hex data', errors.INVALID_ARGUMENT, { arg: 'value', value: data });
225225
}
@@ -228,8 +228,8 @@ export function hexDataSlice(data: string, offset: number, length?: number): str
228228
}
229229
offset = 2 + 2 * offset;
230230

231-
if (length != null) {
232-
return '0x' + data.substring(offset, offset + 2 * length);
231+
if (endOffset != null) {
232+
return '0x' + data.substring(offset, 2 + 2 * endOffset);
233233
}
234234

235235
return '0x' + data.substring(offset);

0 commit comments

Comments
 (0)