-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1bb6936
commit 16c6fac
Showing
19 changed files
with
193 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,18 @@ | ||
import GlobalScope from './global-scope'; | ||
|
||
const getHost = (url) => { | ||
const a = document.createElement('a'); | ||
a.href = url; | ||
return a.hostname || location.hostname; | ||
if (url) { | ||
if (typeof document !== 'undefined') { | ||
const a = document.createElement('a'); | ||
a.href = url; | ||
return a.hostname || GlobalScope.location.hostname; | ||
} | ||
if (typeof URL === 'function') { | ||
const u = new URL(url); | ||
return u.hostname || GlobalScope.location.hostname; | ||
} | ||
} | ||
return GlobalScope.location.hostname; | ||
}; | ||
|
||
export default getHost; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
import GlobalScope from './global-scope'; | ||
|
||
const getLocation = () => { | ||
return window.location; | ||
return GlobalScope.location; | ||
}; | ||
|
||
export default getLocation; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
const GlobalScope = typeof window !== 'undefined' ? window : self; | ||
export default GlobalScope; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
export default class WorkerStorage { | ||
constructor() { | ||
this.map = new Map(); | ||
this.length = 0; | ||
} | ||
|
||
key(index) { | ||
const keys = Array.from(this.map.keys()); | ||
const key = keys[index]; | ||
return this.map.get(key); | ||
} | ||
|
||
getItem(key) { | ||
return this.map.get(key); | ||
} | ||
|
||
setItem(key, value) { | ||
if (!this.map.has(key)) { | ||
this.length += 1; | ||
} | ||
this.map.set(key, value); | ||
} | ||
|
||
removeItem(key) { | ||
if (this.map.has(key)) { | ||
this.length -= 1; | ||
this.map.delete(key); | ||
} | ||
} | ||
|
||
clear() { | ||
this.map.clear(); | ||
} | ||
} |
Oops, something went wrong.