-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
46 lines (41 loc) · 1.22 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/**
* Created by imamudinnaseem on 6/9/17.
*/
import {IOptions} from './src/interfaces/IOptions';
import install from './src/install'
import activate from './src/activate'
import fetch from './src/fetch'
import {IConfig} from "./src/interfaces/Iconfig";
import config from './src/extras/config';
interface IInput {
prefetchFiles?: string[]
cacheFiles?: IConfig[]
cacheName?: string
strategy?: string
getKey?: Function
disableLogging?: boolean
}
type I = <T>(value: T) => T;
const identity: I = <T>(a: T): T => a;
var defaultOptions: IOptions = {
prefetchFiles: [],
cacheFiles: [],
cacheName: 'SW-V1',
strategy: 'CacheFirst',
getKey: identity,
disableLogging: false
}
export default (options: IInput) => {
var {
cacheFiles = defaultOptions.cacheFiles,
cacheName = defaultOptions.cacheName,
strategy = defaultOptions.strategy,
prefetchFiles = defaultOptions.prefetchFiles,
disableLogging = defaultOptions.disableLogging,
getKey = defaultOptions.getKey
} = options;
config.disableLogging = disableLogging;
install({prefetchFiles, cacheName})
activate({cacheName})
fetch({cacheName, strategy, cacheFiles, prefetchFiles, getKey})
}