f5io / bonobo-js Goto Github PK
View Code? Open in Web Editor NEWA work-monkey to do your dirty business.
A work-monkey to do your dirty business.
It would be nice if the run method accepted a callback or returned a promise so that associating calls and emitted events could be abstracted away. This was easy enough to do in a wrapper, but it would be a nice feature of the library itself. It there and I'm missing it? And if not, would you accept a pull request around that?
Please add working examples
It seems that Bonobo expects to be loaded through a <script>
tag, so that it can import itself to worker scripts. But this is not documented. It's also unfortunate, because I concatenate all my .js files into one. And even if I make an exception for Bonobo, the main script would have to be in the server's root to have the bonobo-path resolve properly.
If I understand Bonobo's principles correctly, you should be able to do away with this restriction. Could you put Bonobo's code inside a function, and then use .hoist
to get it into the workers?
At the very least, it would be useful if I could manually specify the path where the lib could be found.
Line 92 contains the following statement:
_.loc = d.location.href.substr(0, d.location.href.lastIndexOf('/'));
This assumes the last '/' symbol represents the folder name. This is an incorrect assumption. I worked around this problem with the following code:
_.loc = d.location.href.split('#')[0].split('?')[0];
_.loc = _.loc.substr(0, _.loc.lastIndexOf('/'));
Not the most elegant, but gets the job done. If you can come up with a better solution, more power to ya!
I've tried to send JSON-like objects from a worker thread to the main thread using Bonobo. This still seems to take up to 10 seconds for large arrays. I profiled my app, and nearly all of this time is used by Bonobo function _self.messageHandler
.
Question 1: The Bonobo docs claim that Bonobo intelligently uses transferable objects to make the transfer more efficient. From what I've been able to figure out, however, objects are translated to ArrayBuffer
s, which are then transferred, when are then translated back to their original form. Is that correct?
Question 2: From what I understand of web-workers, there is native support for copying JSON objects from thread to thread, using structured clone. Is this 'transferable-object-inbetween' approach really more efficient, given that it requires two translations, one of them in the main thread?
Question 3: What sort of data does Bonobo accept to actually get the (near) zero transfer time promised by transferable objects? If I send a raw ArrayBuffer
, will it send it directly, or still try to copy? What about an object that contains raw ArrayBuffer
s?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.