diff options
author | eric thul <thul.eric@gmail.com> | 2016-02-24 22:53:40 -0500 |
---|---|---|
committer | eric thul <thul.eric@gmail.com> | 2016-02-24 22:53:40 -0500 |
commit | 460393439a8dd7d94fe02a2013e96c9146282bf1 (patch) | |
tree | 178492f39cc5afa716f1c403d4a28d45606336a3 /src/PursLoader/Plugin.js | |
parent | ef1525b5a0fe3f4561493aaca49907dba827dbd6 (diff) | |
download | purs-loader-460393439a8dd7d94fe02a2013e96c9146282bf1.tar.gz purs-loader-460393439a8dd7d94fe02a2013e96c9146282bf1.tar.zst purs-loader-460393439a8dd7d94fe02a2013e96c9146282bf1.zip |
Adds dependencies of modules process by the loader.
The module file path and dependency graph information is provided by the
purescript-webpack-plugin.
Resolves #37
Diffstat (limited to 'src/PursLoader/Plugin.js')
-rw-r--r-- | src/PursLoader/Plugin.js | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/PursLoader/Plugin.js b/src/PursLoader/Plugin.js new file mode 100644 index 0000000..90feb33 --- /dev/null +++ b/src/PursLoader/Plugin.js | |||
@@ -0,0 +1,20 @@ | |||
1 | 'use strict'; | ||
2 | |||
3 | // module PursLoader.Plugin | ||
4 | |||
5 | function getFn(nothing, just, map, key) { | ||
6 | var value = map.get(key); | ||
7 | return value === undefined ? nothing : just(value); | ||
8 | } | ||
9 | exports.getFn = getFn; | ||
10 | |||
11 | function dependenciesOfFn(left, right, graph, node) { | ||
12 | try { | ||
13 | var dependencies = graph.dependenciesOf(node); | ||
14 | return right(dependencies); | ||
15 | } | ||
16 | catch (error) { | ||
17 | return left(error); | ||
18 | } | ||
19 | } | ||
20 | exports.dependenciesOfFn = dependenciesOfFn; | ||