Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbcb88d4

Browse files
committed
feat: 🎸 add.subarray() method
1 parent91136d0 commitbcb88d4

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

‎src/Reader.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@ export class Reader implements IReader, IReaderResettable {
4545
returnbin;
4646
}
4747

48+
publicsubarray(start:number=0,end?:number):Uint8Array{
49+
constx=this.x;
50+
constactualStart=x+start;
51+
constactualEnd=typeofend==='number' ?x+end :this.end;
52+
returnthis.uint8.subarray(actualStart,actualEnd);
53+
}
54+
4855
/**
4956
* Creates a new {@link Reader} that references the same underlying memory
5057
* buffer. But with independent cursor and end.

‎src/StreamingReader.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,13 @@ export class StreamingReader implements IReader, IReaderResettable {
9595
returnbin;
9696
}
9797

98+
publicsubarray(start:number=0,end?:number):Uint8Array{
99+
constx=this.x;
100+
constactualStart=x+start;
101+
constactualEnd=typeofend==='number' ?x+end :this.size()+x-start;
102+
returnthis.uint8.subarray(actualStart,actualEnd);
103+
}
104+
98105
/**
99106
* Creates a new {@link Reader} that references the same underlying memory
100107
* buffer. But with independent cursor and end.

‎src/types.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ export interface IReaderBase {
9191
*/
9292
cut(size?:number):IReaderBase;
9393

94+
subarray(start?:number,end?:number):Uint8Array;
95+
9496
/** Get current byte value without advancing the cursor. */
9597
peek():number;
9698

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp