Skip to content

Commit 08996d0

Browse files
committed
Update examples
1 parent 8bdee6c commit 08996d0

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

lib/node_modules/@stdlib/fs/open/README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,12 @@ var closeSync = require( '@stdlib/fs/close' ).sync;
4343

4444
open( __filename, onOpen );
4545

46-
function onFile( error, fd ) {
46+
function onOpen( error, fd ) {
4747
if ( error ) {
48-
throw error;
48+
console.error( error.message );
49+
} else {
50+
closeSync( fd );
4951
}
50-
closeSync( fd );
5152
}
5253
```
5354

@@ -64,9 +65,10 @@ var closeSync = require( '@stdlib/fs/close' ).sync;
6465

6566
var fd = open.sync( __filename );
6667
if ( fd instanceof Error ) {
67-
throw fd;
68+
console.error( fd.message );
69+
} else {
70+
closeSync( fd );
6871
}
69-
closeSync( fd );
7072
```
7173

7274
The function has the same default parameters as [`fs.openSync()`][node-fs].

0 commit comments

Comments
 (0)