Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

88
Views
Sharing array of nested objects between workers

I have an array of objects which contains more objects as values. I'm working with Web Workers and I need to use this exact array of objects (or another object) in worker file. Problem is I couldn't find any solution to forward this array or object from main file to worker. I cannot use Shared Array Buffer because it needs Typed Arrays (or I couldn't find any solution). And stringifying doesn't work because after parsing the reserve array that keeping my objects which I am using to compare can not recognize object.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Two threads cannot share an array of objects. While it's possible to transfer arrays with some objects in them between threads (where the source thread loses access to those objects, until or unless the target thread sends them back), you can only do that with transferrable objects, and plain objects are not transferrable.

You'll need to use some kind of serialization turning the objects into strings or transferable objects, and then handle deserializing them.

And stringifying doesn't work because after parsing the reserve array that keeping my objects which I am using to compare can not recognize object.

You'll need to give them unique IDs that allow you to relate the serialized version back to the original.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!