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

fix support for WebWorkers #11

Closed
wants to merge 2 commits into from
Closed

fix support for WebWorkers #11

wants to merge 2 commits into from

Conversation

dryajov
Copy link
Member

@dryajov dryajov commented Jan 23, 2017

window is not defined inside WebWorkers/ServiceWorkers, fallback to self instead.

@@ -6,14 +8,13 @@ const nodeify = require('nodeify')
const webCrypto = getWebCrypto()

function getWebCrypto () {
Copy link
Member Author

Choose a reason for hiding this comment

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

Any reason why getWebCrypto is defined twice in separate files? Should it be moved to some utils lib/file?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah if you could do this please. I think I forgot to clean this up when the second one was introduced.

@daviddias daviddias added the status/deferred Conscious decision to pause or backlog label Jan 23, 2017
@@ -1,18 +1,19 @@
/* global self */

'use strict'

const nodeify = require('nodeify')

const webCrypto = getWebCrypto()

function getWebCrypto () {
Copy link
Member Author

Choose a reason for hiding this comment

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

This file (crypto-sha1-2-browser.js) adds a new method sha3 that is not present in crypto-browser.js, other than that they are exactly the same, should we remove crypto-browser.js?

@kumavis
Copy link

kumavis commented Jan 27, 2017

for browserify (not sure about webpack) you can use the keyword global which will be window or self

@dryajov
Copy link
Member Author

dryajov commented Jan 27, 2017

Doesn't seem to be defined in webpack, can someone confirm if it supports this use case? I agree, it would be much cleaner to have the bundler handle that rather than doing it in code.

@dryajov
Copy link
Member Author

dryajov commented Jan 27, 2017

@kumavis @dignifiedquire as an alternative, we can simply use self everywhere where modifying window is not required (since self is read only)? I'd hate to have the check littering the code everywhere...

@dignifiedquire
Copy link
Member

Thank you closing in favor of #14

@dignifiedquire dignifiedquire removed the status/deferred Conscious decision to pause or backlog label Jan 27, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants