1 |
|
2 |
|
3 |
|
4 |
|
5 | 'use strict';
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | function prepend(candidate) {
|
11 | if (typeof candidate === 'string') {
|
12 | return 'file://' + candidate;
|
13 | } else if (candidate && (typeof candidate === 'object') && Array.isArray(candidate.sources)) {
|
14 | return Object.assign({}, candidate, {
|
15 | sources: candidate.sources.map(prepend)
|
16 | });
|
17 | } else {
|
18 | throw new Error('expected string|object');
|
19 | }
|
20 | }
|
21 |
|
22 | exports.prepend = prepend;
|
23 |
|
24 |
|
25 |
|
26 |
|
27 | function remove(candidate) {
|
28 | if (typeof candidate === 'string') {
|
29 | return candidate.replace(/^file:\/{2}/, '');
|
30 | } else if (candidate && (typeof candidate === 'object') && Array.isArray(candidate.sources)) {
|
31 | return Object.assign({}, candidate, {
|
32 | sources: candidate.sources.map(remove)
|
33 | });
|
34 | } else {
|
35 | throw new Error('expected string|object');
|
36 | }
|
37 | }
|
38 |
|
39 | exports.remove = remove;
|