Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support bare option and objectURL prop #21

Merged
merged 1 commit into from
Oct 29, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function quoteRegExp(str) {
return (str+'').replace(/[.?*+^$[\]\\(){}|-]/g, "\\$&");
}

module.exports = function (fn) {
module.exports = function (fn, options) {
var moduleWrapperStrings = [];
var potentialFnModuleIds = [ENTRY_MODULE];

Expand Down Expand Up @@ -108,10 +108,12 @@ module.exports = function (fn) {
+ moduleWrapperStrings.join(',')
+ ']);\n'
+ '(typeof fn === "function") && fn(self);'; // not a function when calling a function from the current scope


var blob = new Blob([src], { type: 'text/javascript' })
if (options && options.bare) { return blob; }
var URL = window.URL || window.webkitURL || window.mozURL || window.msURL;

return new Worker(URL.createObjectURL(
new Blob([src], { type: 'text/javascript' })
));
var workerUrl = URL.createObjectURL(blob);
var worker = new Worker(workerUrl);
worker.objectURL = workerUrl;
return worker;
};