Skip to content

Commit

Permalink
fixed es lint
Browse files Browse the repository at this point in the history
  • Loading branch information
wargio committed Aug 27, 2020
1 parent 85f8bb7 commit 8cee20c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 19 deletions.
2 changes: 1 addition & 1 deletion libdec/annotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
this.value = value || "";
this.location = location || Global.evars.extra.offset;
this.type = this.value.length > 0 ? type : 'offset';
this._annotation_ = true
this._annotation_ = true;
this.define = function(current) {
var d = {
start: current,
Expand Down
10 changes: 6 additions & 4 deletions libdec/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,10 @@
*/
this.addAnnotation = function(annotation, offset) {
if (!annotation && ["undefined", "object"].indexOf(typeof(annotation)) >= 0) {
throw new Error("WOAH COWBOY!")
throw new Error("undefined object in annotation.");
}
if (!annotation._annotation_ && typeof(annotation) !== 'string') {
console.log(annotation)
throw new Error("WOAH COWBOY!")
throw new Error("not an Annotation object.");
}
if (typeof(annotation) === 'string') {
annotation = Anno.offset(annotation, offset);
Expand All @@ -47,7 +46,10 @@
*/
this.addAnnotations = function(annotations) {
if (!annotations && ["undefined", "object"].indexOf(typeof(annotations)) >= 0) {
throw new Error("WOAH COWBOY!")
throw new Error("undefined object in annotation.");
}
if (annotations.map(function(x) { return !x._annotation_; }).length > 0) {
throw new Error("found some non Annotation objects.");
}
if (Array.isArray(annotations)) {
Array.prototype.push.apply(this.lines, annotations);
Expand Down
27 changes: 13 additions & 14 deletions libdec/printer.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,17 +174,16 @@
*/
var _flush_output = function(lines, errors, log, evars) {
if (evars.annotation && lines) {
var result = {};
var jdan = {};
var last = {};
var anno = [];
result.code = "";
jdan.code = "";
lines.forEach(function(x) {
if (!x.define) {
throw new Error("invalid object");
return;
}
if (x.type == "offset") {
var def = x.define(result.code.length);
var def = x.define(jdan.code.length);
if (last.type != "offset") {
anno.push(def);
last = x;
Expand All @@ -193,27 +192,27 @@
}
} else {
if (["function_name", "function_parameter", "local_variable"].indexOf(x.type) >= 0) {
anno.push(x.define(result.code.length));
anno.push(x.define(jdan.code.length));
}
anno.push(x.syntax(result.code.length));
anno.push(x.syntax(jdan.code.length));
last = x;
}
result.annotations = anno;
result.code += x.value;
jdan.annotations = anno;
jdan.code += x.value;
});
console.log(json64.stringify(result));
console.log(json64.stringify(jdan));
} else if (evars.json) {
var result = {};
var jdata = {};
if (lines && lines.length > 0) {
result.lines = lines;
jdata.lines = lines;
}
if (errors && errors.length > 0) {
result.errors = errors;
jdata.errors = errors;
}
if (log && log.length > 0) {
result.log = log;
jdata.log = log;
}
console.log(json64.stringify(result));
console.log(json64.stringify(jdata));
} else {
var prefix = evars.allfunctions ? "// " : "";
if (lines && lines.length > 0) {
Expand Down

0 comments on commit 8cee20c

Please sign in to comment.