maxkfranz / weaver Goto Github PK
View Code? Open in Web Editor NEWA JS library that facilitates concise and readable parallelism
Home Page: http://weaver.js.org
License: MIT License
A JS library that facilitates concise and readable parallelism
Home Page: http://weaver.js.org
License: MIT License
When I attempt to pass in a js object to my fabric, I am given the following error:
obj["url"] = JSON.parse(""www.test.com"");
^^
SyntaxError: missing ) after argument list
at process.<anonymous> (.../weaverjs/dist/thread-node-fork.js:61:12)
at emitTwo (events.js:87:13)
at process.emit (events.js:172:7)
at handleMessage (internal/child_process.js:686:10)
at Pipe.channel.onread (internal/child_process.js:440:11)
undefined:3
See code below
return f.require({url: url}, 'obj').pass(dataToSync).spread(sliceToSync => {
var obj = _ref_('obj');
var message = {};
message.payload = sliceToSync;
console.log(`syncing to `, obj);
return JSON.stringify(message);
}).then(res => {
console.log('res is ' + res);
f.stop();
return res;
});
e.g. function cellCentroid(e){for(var n,t
Edit: Didn't mean to close!
To give more context, I copied this from the docs:
function foo(){
return 'bar';
}
var t = weaver.thread();
t.require( foo, 'foo' ); // explicitly specify name to avoid minification issues
t.run(function(){
// explicitly get by reference to avoid minification issues:
var foo = _ref_('foo');
var resolve = _ref_('resolve');
resolve( foo() );
}).then(function( val ){
console.log( val ); // bar
});
I attempt to run this code from a meteor method or from inside meteor.startup
The errors we have aren't conducive to continuing to run afterwards, so throwing would be better.
The child-process impl works, but it's just a stopgap
Attempted to run require a function into a thread and get this output. I have attempted to run the examples in the docs but always get this error.
Thanks in advance.
For systems without threading systems (like many versions of IE), fall back on running the same API in the main thread.
This may make it unnecessary to use threads (e.g. threads-a-gogo) on Node.js:
fabric.spread()
simply splits the array of data between the threads. Sometimes you have an array that contains items of varying processing expense.
Using fabric.pass( array.sort( byExpense ) ).spreadOneByOne( ... )
, the items in the sorted array will be divvied up one by one, alternating the owning thread. In this way, the processing expense is more evenly distributed among the threads -- thereby increasing performance.
If building the worker from the blob fails, fallback on the simulated worker
fn.name
becomes fn.name || fn.toString().match(/^function\s*([^\s(]+)/)[1]
Not used and reduces kB
This helps with minification. It is important that the function name be such that the dev is very unlikely to use it himself elsewhere in the same scope. Otherwise, it could be incorrectly minified.
Great project. IMHO, full working examples are always useful to have, especially as boilerplate. This includes some ideas on "what can I build with weaverjs." An example of some useful things to have might be:
etc.
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.