Skip to content

Commit

Permalink
Replace eslint with prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
surma committed Apr 16, 2018
1 parent cc15e18 commit cced1a4
Show file tree
Hide file tree
Showing 12 changed files with 425 additions and 1,067 deletions.
3 changes: 0 additions & 3 deletions .eslintignore

This file was deleted.

24 changes: 0 additions & 24 deletions .eslintrc

This file was deleted.

33 changes: 19 additions & 14 deletions dist/clooney.bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ var Clooney = (function (exports) {
* limitations under the License.
*/
// Automatically proxy functions
Comlink.transferHandlers.set('FUNCTION', {
Comlink.transferHandlers.set("FUNCTION", {
canHandle(obj) {
return obj instanceof Function;
},
Expand All @@ -357,24 +357,26 @@ var Clooney = (function (exports) {
},
deserialize(obj) {
return Comlink.proxy(obj);
},
}
});
// Automatically proxy events
Comlink.transferHandlers.set('EVENT', {
Comlink.transferHandlers.set("EVENT", {
canHandle(obj) {
return obj instanceof Event;
},
serialize(obj) {
return {
targetId: obj && obj.target && obj.target.id,
targetClassList: obj && obj.target && obj.target.classList && [...obj.target.classList],
targetClassList: obj &&
obj.target &&
obj.target.classList && [...obj.target.classList],
detail: obj && obj.detail,
data: obj && obj.data,
data: obj && obj.data
};
},
deserialize(obj) {
return obj;
},
}
});
/**
* `asRemoteValue` marks a value. If a marked value is used as an parameter or return value, it will not be transferred but instead proxied.
Expand All @@ -383,10 +385,13 @@ var Clooney = (function (exports) {
/**
* `defaultWorkerSrc` is the path passed to the `new Worker()` call. It’s recommended to not change this variable but instead overload `newWorkerFunc`.
*/
let defaultWorkerSrc = 'document' in self ? document.currentScript && document.currentScript.src : '';
let defaultWorkerSrc = "document" in self
? document.currentScript &&
document.currentScript.src
: "";
const defaultOpts = {
maxNumContainers: 1,
newWorkerFunc: async () => new Worker(defaultWorkerSrc),
newWorkerFunc: async () => new Worker(defaultWorkerSrc)
};
/**
* `RoundRobingStrategy` creates up to n containers and cycles through the containers with every `spawn` call.
Expand All @@ -399,13 +404,13 @@ var Clooney = (function (exports) {
}
async _initOrGetContainer(i) {
if (i >= this._containers.length)
throw Error('No worker available');
throw Error("No worker available");
if (!this._containers[i]) {
const worker = await this._options.newWorkerFunc();
const remote = Comlink.proxy(worker);
this._containers[i] = {
spawn: remote.spawn.bind(spawn),
terminate: worker.terminate.bind(worker),
terminate: worker.terminate.bind(worker)
};
}
return this._containers[i];
Expand All @@ -417,7 +422,7 @@ var Clooney = (function (exports) {
}
async spawn(actor, constructorArgs = [], opts = {}) {
const container = await this._getNextContainer(opts);
return await container.spawn(actor.toString(), constructorArgs);
return (await container.spawn(actor.toString(), constructorArgs));
}
async terminate() {
this._containers.filter(c => c).forEach(container => container.terminate());
Expand All @@ -434,15 +439,15 @@ var Clooney = (function (exports) {
function makeContainer(endpoint = self) {
Comlink.expose({
async spawn(actorCode, constructorArgs) {
const actor = (new Function(`return ${actorCode};`))();
const actor = new Function(`return ${actorCode};`)();
return Comlink.proxyValue(new actor(...constructorArgs)); // eslint-disable-line new-cap
},
}
}, endpoint);
}
function isWorker() {
// I’d have to import lib.webworker.d.ts to have access to
// WorkerGlobalScope, but I can’t because it conflicts with lib.dom.d.ts.
const wgs = self['WorkerGlobalScope'];
const wgs = self["WorkerGlobalScope"];
return wgs && self instanceof wgs;
}
// TODO: Find a way to opt-out of autostart
Expand Down
2 changes: 1 addition & 1 deletion dist/clooney.bundle.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/clooney.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Endpoint } from 'comlinkjs';
export { Comlink } from 'comlinkjs';
import { Endpoint } from "comlinkjs";
export { Comlink } from "comlinkjs";
/**
* `asRemoteValue` marks a value. If a marked value is used as an parameter or return value, it will not be transferred but instead proxied.
*/
Expand Down
Loading

0 comments on commit cced1a4

Please sign in to comment.