main
Last change
on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
1.4 KB
|
Line | |
---|
1 | "use strict";
|
---|
2 |
|
---|
3 | exports.__esModule = true;
|
---|
4 | exports.default = void 0;
|
---|
5 | var _minim = require("minim");
|
---|
6 | var _ramdaAdjunct = require("ramda-adjunct");
|
---|
7 | class ParseResult extends _minim.ArrayElement {
|
---|
8 | constructor(content, meta, attributes) {
|
---|
9 | super(content, meta, attributes);
|
---|
10 | this.element = 'parseResult';
|
---|
11 | }
|
---|
12 | get api() {
|
---|
13 | return this.children.filter(item => item.classes.contains('api')).first;
|
---|
14 | }
|
---|
15 | get results() {
|
---|
16 | return this.children.filter(item => item.classes.contains('result'));
|
---|
17 | }
|
---|
18 | get result() {
|
---|
19 | return this.results.first;
|
---|
20 | }
|
---|
21 | get annotations() {
|
---|
22 | return this.children.filter(item => item.element === 'annotation');
|
---|
23 | }
|
---|
24 | get warnings() {
|
---|
25 | return this.children.filter(item => item.element === 'annotation' && item.classes.contains('warning'));
|
---|
26 | }
|
---|
27 | get errors() {
|
---|
28 | return this.children.filter(item => item.element === 'annotation' && item.classes.contains('error'));
|
---|
29 | }
|
---|
30 | get isEmpty() {
|
---|
31 | return this.children.reject(item => item.element === 'annotation').isEmpty;
|
---|
32 | }
|
---|
33 | replaceResult(replacement) {
|
---|
34 | const {
|
---|
35 | result
|
---|
36 | } = this;
|
---|
37 | if ((0, _ramdaAdjunct.isUndefined)(result)) {
|
---|
38 | return false;
|
---|
39 | }
|
---|
40 |
|
---|
41 | // @ts-ignore
|
---|
42 | const searchIndex = this.content.findIndex(e => e === result);
|
---|
43 | if (searchIndex === -1) {
|
---|
44 | return false;
|
---|
45 | }
|
---|
46 | this.content[searchIndex] = replacement;
|
---|
47 | return true;
|
---|
48 | }
|
---|
49 | }
|
---|
50 | var _default = exports.default = ParseResult; |
---|
Note:
See
TracBrowser
for help on using the repository browser.