Last change
on this file since ceaed42 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.0 KB
|
Rev | Line | |
---|
[6a3a178] | 1 | /*
|
---|
| 2 | * MIT License http://opensource.org/licenses/MIT
|
---|
| 3 | * Author: Ben Holloway @bholloway
|
---|
| 4 | */
|
---|
| 5 | 'use strict';
|
---|
| 6 |
|
---|
| 7 | /**
|
---|
| 8 | * Prepend file:// protocol to source path string or source-map sources.
|
---|
| 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 | * Remove file:// protocol from source path string or source-map sources.
|
---|
| 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;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.