Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion tfjs-core/src/io/indexed_db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function getIndexedDBFactory(): IDBFactory {
'is not a web browser.');
}
// tslint:disable-next-line:no-any
const theWindow: any = window;
const theWindow: any = window || self;
const factory = theWindow.indexedDB || theWindow.mozIndexedDB ||
theWindow.webkitIndexedDB || theWindow.msIndexedDB ||
theWindow.shimIndexedDB;
Expand Down
5 changes: 4 additions & 1 deletion tfjs-core/src/io/local_storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const MODEL_METADATA_SUFFIX = 'model_metadata';
*/
export function purgeLocalStorageArtifacts(): string[] {
if (!env().getBool('IS_BROWSER') ||
typeof window === 'undefined' ||
typeof window.localStorage === 'undefined') {
throw new Error(
'purgeLocalStorageModels() cannot proceed because local storage is ' +
Expand Down Expand Up @@ -119,7 +120,8 @@ export class BrowserLocalStorage implements IOHandler {

constructor(modelPath: string) {
if (!env().getBool('IS_BROWSER') ||
typeof window.localStorage === 'undefined') {
typeof window === 'undefined' ||
typeof window.localStorage === 'undefined') {
// TODO(cais): Add more info about what IOHandler subtypes are
// available.
// Maybe point to a doc page on the web and/or automatically determine
Expand Down Expand Up @@ -307,6 +309,7 @@ export class BrowserLocalStorageManager implements ModelStoreManager {
env().getBool('IS_BROWSER'),
() => 'Current environment is not a web browser');
assert(
typeof window === 'undefined' ||
typeof window.localStorage !== 'undefined',
() => 'Current browser does not appear to support localStorage');
this.LS = window.localStorage;
Expand Down