From 612db1c4bf5b43134340543a3793b4087264e634 Mon Sep 17 00:00:00 2001 From: 30secondsofcode <30secondsofcode@gmail.com> Date: Wed, 3 Jan 2018 18:17:12 +0000 Subject: [PATCH] Travis build: 980 --- README.md | 11 ++++------- docs/index.html | 11 ++++------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 1d4cfc28b..c8c3c420d 100644 --- a/README.md +++ b/README.md @@ -2097,10 +2097,7 @@ Return a promise, listening for `onmessage` and `onerror` events and resolving t ```js const runAsync = fn => { - const blob = ` - var fn = ${fn.toString()}; - this.postMessage(fn()); - `; + const blob = `var fn = ${fn.toString()}; postMessage(fn());`; const worker = new Worker( URL.createObjectURL(new Blob([blob]), { type: 'application/javascript; charset=utf-8' @@ -2123,9 +2120,9 @@ const runAsync = fn => { ```js const longRunningFunction = () => { let result = 0; - for (var i = 0; i < 1000; i++) { - for (var j = 0; j < 700; j++) { - for (var k = 0; k < 300; k++) { + for (let i = 0; i < 1000; i++) { + for (let j = 0; j < 700; j++) { + for (let k = 0; k < 300; k++) { result = result + i + j + k; } } diff --git a/docs/index.html b/docs/index.html index 645a1252f..b75d36899 100644 --- a/docs/index.html +++ b/docs/index.html @@ -422,10 +422,7 @@ elementIsVisibleInViewport(el, true); // true // (partially visible) asLink ? (window.location.href = url) : window.location.replace(url);
redirect('https://google.com');
Runs a function in a separate thread by using a Web Worker, allowing long running functions to not block the UI.
Create a new Worker using a Blob object URL, the contents of which should be the stringified version of the supplied function. Immediately post the return value of calling the function back. Return a promise, listening for onmessage and onerror events and resolving the data posted back from the worker, or throwing an error.
const runAsync = fn => {
- const blob = `
- var fn = ${fn.toString()};
- this.postMessage(fn());
- `;
+ const blob = `var fn = ${fn.toString()}; postMessage(fn());`;
const worker = new Worker(
URL.createObjectURL(new Blob([blob]), {
type: 'application/javascript; charset=utf-8'
@@ -442,9 +439,9 @@ elementIsVisibleInViewport(el, true); // true // (partially visible)
};
const longRunningFunction = () => {
let result = 0;
- for (var i = 0; i < 1000; i++) {
- for (var j = 0; j < 700; j++) {
- for (var k = 0; k < 300; k++) {
+ for (let i = 0; i < 1000; i++) {
+ for (let j = 0; j < 700; j++) {
+ for (let k = 0; k < 300; k++) {
result = result + i + j + k;
}
}