File tree Expand file tree Collapse file tree 4 files changed +1195
-1041
lines changed Expand file tree Collapse file tree 4 files changed +1195
-1041
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " @picovoice/web-utils" ,
3
- "version" : " 1.3.1 " ,
3
+ "version" : " 1.3.2 " ,
4
4
"description" : " Picovoice web utility functions" ,
5
5
"author" : " Picovoice" ,
6
6
"license" : " Apache-2.0" ,
Original file line number Diff line number Diff line change 1
1
/*
2
- Copyright 2022 Picovoice Inc.
2
+ Copyright 2022-2023 Picovoice Inc.
3
3
4
4
You may not use this file except in compliance with the license. A copy of the license is located in the "LICENSE"
5
5
file accompanying this source.
@@ -271,6 +271,10 @@ export class PvFileIDB extends PvFile {
271
271
if ( ! this . exists ( ) && this . _mode === "readonly" ) {
272
272
throw new Error ( `'${ this . _path } ' doesn't exist.` ) ;
273
273
}
274
+ if ( ! this . exists ( ) ) {
275
+ // This is valid in ISO C but not supported by this current implementation
276
+ throw new Error ( `'${ this . _path } ' doesn't exist.` ) ;
277
+ }
274
278
275
279
if ( offset < 0 ) {
276
280
const err = new Error ( `EOF` ) ;
@@ -309,6 +313,11 @@ export class PvFileIDB extends PvFile {
309
313
*/
310
314
public async remove ( ) : Promise < void > {
311
315
return new Promise ( async ( resolve , reject ) => {
316
+ if ( ! this . exists ( ) ) {
317
+ reject ( new Error ( "ENOENT" ) ) ;
318
+ return ;
319
+ }
320
+
312
321
const numPages = this . _meta ! . numPages ;
313
322
const keyRange = IDBKeyRange . bound ( this . _path , `${ this . _path } -${ PvFileIDB . createPage ( numPages ) } ` ) ;
314
323
const store = this . _store ;
Original file line number Diff line number Diff line change @@ -83,6 +83,11 @@ export class PvFileMem extends PvFile {
83
83
if ( ! this . exists ( ) && this . _mode === "readonly" ) {
84
84
throw new Error ( `'${ this . _path } ' doesn't exist.` ) ;
85
85
}
86
+ if ( ! this . exists ( ) ) {
87
+ // This is valid in ISO C but not supported by this current implementation
88
+ throw new Error ( `'${ this . _path } ' doesn't exist.` ) ;
89
+ }
90
+
86
91
if ( offset < 0 ) {
87
92
const err = new Error ( `EOF` ) ;
88
93
err . name = "EndOfFile" ;
@@ -111,6 +116,10 @@ export class PvFileMem extends PvFile {
111
116
}
112
117
113
118
public async remove ( ) : Promise < void > {
119
+ if ( ! this . exists ( ) ) {
120
+ throw new Error ( "ENOENT" ) ;
121
+ }
122
+
114
123
PvFileMem . _memFiles . delete ( this . _path ) ;
115
124
this . _pos = 0 ;
116
125
}
You can’t perform that action at this time.
0 commit comments