Skip to content

Read large files using JavaScript TypedArray with ServiceWorker

Notifications You must be signed in to change notification settings

safwat-fathi/read-large-files

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Process and read large files with JavaScript TypedArray & WebWorkers ✨

Large file reading or processing in javascript can cause a lot of issues, For example, but not limited to:

  • page crash
  • interactivity go wrong (UI freeze)
  • Violation warning message in chrome based browsers ([Violation] change/load handler took xxxxms)

TypedArray

TypedArray can help us to deal with big files as chunks so we can read/process every chunk of the file instead of the whole file at once.

Web Workers

The worker thread can perform tasks without interfering with the user interface. Thanks for that 🙏

Running the project

  • First clone the project.
  • You can run the project using VSCODE live server.
  • In case you want to edit any of the TS files you can run the tsc watch script.

Installing dependencies

npm install
npm run start

Testing

  • First you need to have a large file in your machine or you can download a large file from this link.
  • To test slower processing just comment out line 89 and uncomment from line 67 to 81.

About

Read large files using JavaScript TypedArray with ServiceWorker

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published