Skip to content

Commit

Permalink
Chore: Refactor Completion records
Browse files Browse the repository at this point in the history
  • Loading branch information
nzakas committed Sep 30, 2020
1 parent 520e342 commit c8f799b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@
"rollup": "^1.20.3",
"rollup-plugin-babel-minify": "^9.0.0"
}
}
}
26 changes: 17 additions & 9 deletions src/utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,34 @@ export function isCallable(argument) {
return typeof argument === "function";
}

//-----------------------------------------------------------------------------
// 6.2.3 The Completion Record Specification Type
//-----------------------------------------------------------------------------

export class Completion {
constructor(type, value, target) {
this.type = type;
this.value = value;
this.target = target;
}
}

//-----------------------------------------------------------------------------
// 6.2.3.2 NormalCompletion
//-----------------------------------------------------------------------------

export class NormalCompletion {
export class NormalCompletion extends Completion {
constructor(argument) {
this.type = "normal";
this.value = argument;
this.target = undefined;
super("normal", argument);
}
}

//-----------------------------------------------------------------------------
// 6.2.3.3 ThrowCompletion
//-----------------------------------------------------------------------------

export class ThrowCompletion {
export class ThrowCompletion extends Completion {
constructor(argument) {
this.type = "throw";
this.value = argument;
this.target = undefined;
super("throw", argument);
}
}
}

0 comments on commit c8f799b

Please sign in to comment.