source: frontend/node_modules/webpack-sources/lib/Source.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 2.0 KB
RevLine 
[9af201e]1/*
2 MIT License http://www.opensource.org/licenses/mit-license.php
3 Author Tobias Koppers @sokra
4*/
5
6"use strict";
7
8/**
9 * @typedef {object} MapOptions
10 * @property {boolean=} columns need columns?
11 * @property {boolean=} module is module
12 */
13
14/**
15 * @typedef {object} RawSourceMap
16 * @property {number} version version
17 * @property {string[]} sources sources
18 * @property {string[]} names names
19 * @property {string=} sourceRoot source root
20 * @property {string[]=} sourcesContent sources content
21 * @property {string} mappings mappings
22 * @property {string} file file
23 * @property {string=} debugId debug id
24 * @property {number[]=} ignoreList ignore list
25 */
26
27/** @typedef {string | Buffer} SourceValue */
28
29/**
30 * @typedef {object} SourceAndMap
31 * @property {SourceValue} source source
32 * @property {RawSourceMap | null} map map
33 */
34
35/**
36 * @typedef {object} HashLike
37 * @property {(data: string | Buffer, inputEncoding?: string) => HashLike} update make hash update
38 * @property {(encoding?: string) => string | Buffer} digest get hash digest
39 */
40
41class Source {
42 /**
43 * @returns {SourceValue} source
44 */
45 source() {
46 throw new Error("Abstract");
47 }
48
49 /**
50 * @returns {Buffer} buffer
51 */
52 buffer() {
53 const source = this.source();
54 if (Buffer.isBuffer(source)) return source;
55 return Buffer.from(source, "utf8");
56 }
57
58 /**
59 * @returns {Buffer[]} buffers
60 */
61 buffers() {
62 return [this.buffer()];
63 }
64
65 /**
66 * @returns {number} size
67 */
68 size() {
69 return this.buffer().length;
70 }
71
72 /**
73 * @param {MapOptions=} options map options
74 * @returns {RawSourceMap | null} map
75 */
76 // eslint-disable-next-line no-unused-vars
77 map(options) {
78 return null;
79 }
80
81 /**
82 * @param {MapOptions=} options map options
83 * @returns {SourceAndMap} source and map
84 */
85 sourceAndMap(options) {
86 return {
87 source: this.source(),
88 map: this.map(options),
89 };
90 }
91
92 /**
93 * @param {HashLike} hash hash
94 * @returns {void}
95 */
96 // eslint-disable-next-line no-unused-vars
97 updateHash(hash) {
98 throw new Error("Abstract");
99 }
100}
101
102module.exports = Source;
Note: See TracBrowser for help on using the repository browser.