diff --git a/deepclone.js b/deepclone.js
index 7fbde95..c2abca0 100644
--- a/deepclone.js
+++ b/deepclone.js
@@ -35,4 +35,16 @@ function deepclone2(obj) {
}
return newObj
}
+}
+
+// 1 7 6 8 2 4 3 5 9 11 10 12 script end
+
+// script start async2 end Promise async1 end promise1 promise2 setTimeout
+
+if ('serviceWorker' in navigator) {
+ window.addEventListener('load', function () {
+ navigator.serviceWorker.register('/sw.js').then(function (regis) {
+ console.log('ok')
+ }, function (err) { console.log('err', err) })
+ })
}
\ No newline at end of file
diff --git a/webwoker/webworker.html b/webwoker/webworker.html
new file mode 100644
index 0000000..06ec676
--- /dev/null
+++ b/webwoker/webworker.html
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+ Document
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/webwoker/worker.js b/webwoker/worker.js
new file mode 100644
index 0000000..ae1e6f6
--- /dev/null
+++ b/webwoker/worker.js
@@ -0,0 +1,12 @@
+// Worker 线程
+// onmessage = function (e) {
+// if (e.data.length > 1) {
+// postMessage(e.data[1] - e.data[0])
+// }
+// }
+
+this.addEventListener('message', (e) => {
+ if (e.data.length) {
+ postMessage(e.data)
+ }
+})
\ No newline at end of file
diff --git "a/\351\207\215\346\213\276pro.js" "b/\351\207\215\346\213\276pro.js"
index 8e74ee6..1fefce5 100644
--- "a/\351\207\215\346\213\276pro.js"
+++ "b/\351\207\215\346\213\276pro.js"
@@ -119,16 +119,21 @@ MyPromise.race = function (promises) {
})
}
-let promise = new MyPromise((resolve, reject) => {
- setTimeout(() => {
- resolve('cccc')
- }, 1000);
-})
-promise.then((value) => {
- console.log(value)
- throw '111das'
-}).then(1,2).then(res => console.log(res), err => console.log(err))
+// let promise = new MyPromise((resolve, reject) => {
+// setTimeout(() => {
+// resolve('cccc')
+// }, 1000);
+// })
+// promise.then((value) => {
+// console.log(value)
+// throw '111das'
+// }).then(1,2).then(res => console.log(res), err => console.log(err))
-MyPromise.all([1, promise, 2]).then(res => {
- console.log(res)
-})
\ No newline at end of file
+// MyPromise.all([1, promise, 2]).then(res => {
+// console.log(res)
+// })
+const promise = MyPromise.resolve()
+ .then(() => {
+ return promise
+ })
+promise.catch(console.error)
\ No newline at end of file