Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
platformId: Object,
storagelock: StoragelockService,
prefix: string | null
): LocalDatabase {
if (isPlatformBrowser(platformId) && 'indexedDB' in window && indexedDB !== undefined && indexedDB !== null) {
// Try with IndexedDB in modern browsers
// CUSTOM: Use our own IndexedDB implementation
return new CustomIndexedDBDatabase(storagelock, prefix);
} else if (
isPlatformBrowser(platformId) &&
'localStorage' in window &&
localStorage !== undefined &&
localStorage !== null
) {
// Try with localStorage in old browsers (IE9)
return new LocalStorageDatabase(prefix);
} else {
// Fake database for server-side rendering (Universal)
return new MockLocalDatabase();
}
}
): LocalDatabase {
if (isPlatformBrowser(platformId) && 'indexedDB' in window && indexedDB !== undefined && indexedDB !== null) {
// Try with IndexedDB in modern browsers
// CUSTOM: Use our own IndexedDB implementation
return new CustomIndexedDBDatabase(storagelock, prefix);
} else if (
isPlatformBrowser(platformId) &&
'localStorage' in window &&
localStorage !== undefined &&
localStorage !== null
) {
// Try with localStorage in old browsers (IE9)
return new LocalStorageDatabase(prefix);
} else {
// Fake database for server-side rendering (Universal)
return new MockLocalDatabase();
}
}
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { StorageModule } from '@ngx-pwa/local-storage';
import { AppComponent } from './app.component';
@NgModule({
declarations: [AppComponent],
imports: [
BrowserModule,
StorageModule.forRoot({
IDBNoWrap: true,
})
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
import { NgModule } from '@angular/core';
import { StorageModule } from '@ngx-pwa/local-storage';
import { AppComponent } from './app.component';
import { AppRoutingModule } from './app-routing.module';
import { HomeComponent } from './home/home.component';
@NgModule({
declarations: [
AppComponent,
HomeComponent
],
imports: [
BrowserModule,
AppRoutingModule,
StorageModule.forRoot({
LSPrefix: 'localforage/',
IDBDBName: 'localforage',
IDBStoreName: 'keyvaluepairs'
}),
],
bootstrap: [AppComponent]
})
export class AppModule { }