Seek () in javascript / node.js?

I am currently trying to read some files with the fs module for node.js. Since it lacks the function that I used (fseek (), getline () ...), I create another module to return them. (a node.js copy of C stdio.h).

My simple question is:

Does search () exist in some other name, or do I need to reinstall almost every function in order to have it?

+5
source share
2 answers

In node.js, seek functionality is included in the read function. When you use the fs.read function, there is a position parameter that works like a search position.

If you want to write to a file, the fs.write function also has a position parameter.

Check out the docs here: https://nodejs.org/api/fs.html#fs_fs_read_fd_buffer_offset_length_position_callback

+5
source

This package is worth a look: https://npmjs.org/package/fs-ext

Besides the package, the closest I could find: http://nodejs.org/api/fs.html#fs_fs_createreadstream_path_options or using these parameters on fs.read

 length is an integer specifying the number of bytes to read. position is an integer specifying where to begin reading from in the file. If position is null, data will be read from the current file position. 
+3
source

All Articles