Skip to content
This repository has been archived by the owner on Aug 24, 2021. It is now read-only.

feat: change window to self for webworker support #15

Merged
merged 4 commits into from
Feb 8, 2017
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"nodeify": "^1.0.0"
},
"devDependencies": {
"aegir": "^9.4.0",
"aegir": "^10.0.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove the --webworker flags in the scripts please, as they are not needed anymore

"benchmark": "^2.1.3",
"chai": "^3.5.0",
"pre-commit": "^1.2.2"
Expand All @@ -63,4 +63,4 @@
"Richard Littauer <richard.littauer@gmail.com>",
"npm-to-cdn-bot (by Forbes Lindesay) <npmcdn-to-unpkg-bot@users.noreply.github.com>"
]
}
}
19 changes: 4 additions & 15 deletions src/crypto-sha1-2-browser.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,16 @@
/* global self */
'use strict'

const nodeify = require('nodeify')

const webCrypto = getWebCrypto()

function getWebCrypto () {
let globalContext

if (typeof window !== 'undefined') {
globalContext = window
} else if (typeof self !== 'undefined') {
globalContext = self
} else {
return
}

if (globalContext.crypto) {
return globalContext.crypto.subtle || globalContext.crypto.webkitSubtle
if (self.crypto) {
return self.crypto.subtle || self.crypto.webkitSubtle
}

if (globalContext.msCrypto) {
return globalContext.msCrypto.subtle
if (self.msCrypto) {
return self.msCrypto.subtle
}
}

Expand Down