1 | 'use strict';
|
2 |
|
3 | var _api = require('./api');
|
4 |
|
5 | var _api2 = _interopRequireDefault(_api);
|
6 |
|
7 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
8 |
|
9 | const ENC_TYPE = configSize => configSize > 1 ? 'encode' : 'encodeSync';
|
10 |
|
11 | class DataURI extends _api2.default {
|
12 |
|
13 | constructor() {
|
14 | super();
|
15 |
|
16 | for (var _len = arguments.length, config = Array(_len), _key = 0; _key < _len; _key++) {
|
17 | config[_key] = arguments[_key];
|
18 | }
|
19 |
|
20 | const configSize = config.length;
|
21 |
|
22 |
|
23 | if (configSize) {
|
24 | this[ENC_TYPE(configSize)].apply(this, config);
|
25 | }
|
26 | }
|
27 |
|
28 | static promise(fileName) {
|
29 | const datauri = new DataURI();
|
30 |
|
31 | return new Promise((resolve, reject) => {
|
32 | datauri.on('encoded', resolve).on('error', reject).encode(fileName);
|
33 | });
|
34 | }
|
35 |
|
36 | static sync(fileName) {
|
37 | var _ref = new DataURI(fileName);
|
38 |
|
39 | const content = _ref.content;
|
40 |
|
41 |
|
42 | return content;
|
43 | }
|
44 |
|
45 | }
|
46 |
|
47 | module.exports = DataURI; |
\ | No newline at end of file |