diff options
Diffstat (limited to 'src/PursLoader/LoaderRef.js')
-rw-r--r-- | src/PursLoader/LoaderRef.js | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/PursLoader/LoaderRef.js b/src/PursLoader/LoaderRef.js new file mode 100644 index 0000000..3ce0970 --- /dev/null +++ b/src/PursLoader/LoaderRef.js | |||
@@ -0,0 +1,56 @@ | |||
1 | 'use strict'; | ||
2 | |||
3 | // module PursLoader.LoaderRef | ||
4 | |||
5 | function asyncFn(isJust, fromMaybe, ref){ | ||
6 | return function(){ | ||
7 | var callback = ref.async(); | ||
8 | return function(error){ | ||
9 | return function(value){ | ||
10 | return function(){ | ||
11 | return isJust(error) ? callback(fromMaybe(new Error())(error)) | ||
12 | : callback(null, value); | ||
13 | }; | ||
14 | }; | ||
15 | }; | ||
16 | }; | ||
17 | } | ||
18 | function cacheable(ref){ | ||
19 | return function(){ | ||
20 | return ref.cacheable && ref.cacheable(); | ||
21 | }; | ||
22 | } | ||
23 | |||
24 | function query(ref){ | ||
25 | return ref.query; | ||
26 | } | ||
27 | |||
28 | function clearDependencies(ref){ | ||
29 | return function(){ | ||
30 | return ref.clearDependencies(); | ||
31 | }; | ||
32 | } | ||
33 | |||
34 | function resourcePath(ref){ | ||
35 | return ref.resourcePath; | ||
36 | } | ||
37 | |||
38 | function addDependency(ref){ | ||
39 | return function(dep){ | ||
40 | return function(){ | ||
41 | return ref.addDependency(dep); | ||
42 | }; | ||
43 | }; | ||
44 | } | ||
45 | |||
46 | exports.asyncFn = asyncFn; | ||
47 | |||
48 | exports.cacheable = cacheable; | ||
49 | |||
50 | exports.query = query; | ||
51 | |||
52 | exports.clearDependencies = clearDependencies; | ||
53 | |||
54 | exports.resourcePath = resourcePath; | ||
55 | |||
56 | exports.addDependency = addDependency; | ||