1 |
|
2 |
|
3 |
|
4 |
|
5 | "use strict";
|
6 |
|
7 | class Source {
|
8 | source() {
|
9 | throw new Error("Abstract");
|
10 | }
|
11 |
|
12 | buffer() {
|
13 | const source = this.source();
|
14 | if (Buffer.isBuffer(source)) return source;
|
15 | return Buffer.from(source, "utf-8");
|
16 | }
|
17 |
|
18 | size() {
|
19 | return this.buffer().length;
|
20 | }
|
21 |
|
22 | map(options) {
|
23 | return null;
|
24 | }
|
25 |
|
26 | sourceAndMap(options) {
|
27 | return {
|
28 | source: this.source(),
|
29 | map: this.map(options)
|
30 | };
|
31 | }
|
32 |
|
33 | updateHash(hash) {
|
34 | throw new Error("Abstract");
|
35 | }
|
36 | }
|
37 |
|
38 | module.exports = Source;
|