Modernize VC scripts
Change-Id: I260af56726ba75a56857a5af97c373432d69a910
diff --git a/dev/js/src/vc/rewrite.js b/dev/js/src/vc/rewrite.js
index 150ee87..5af4b35 100644
--- a/dev/js/src/vc/rewrite.js
+++ b/dev/js/src/vc/rewrite.js
@@ -1,6 +1,8 @@
/**
* Implementation of rewrite objects.
*/
+"use strict";
+
define(['vc/jsonld', 'util'], function (jsonldClass) {
// injection, modification, and deletion should probably be enough
@@ -8,15 +10,16 @@
new RegExp("^(operation:)?(?:injec|inser|modifica|dele)tion|override$");
return {
+
// Construction method
create : function (json) {
- var obj = Object(jsonldClass).
- create().
- upgradeTo(this).
- fromJson(json);
- return obj;
+ return Object(jsonldClass).
+ create().
+ upgradeTo(this).
+ fromJson(json);
},
+
// Get or set source
src : function (string) {
if (arguments.length === 1)
@@ -24,6 +27,7 @@
return this._src;
},
+
// Get or set operation
operation : function (op) {
if (arguments.length === 1) {
@@ -38,6 +42,7 @@
return this._op || 'injection';
},
+
// Get or set scope
scope : function (attr) {
if (arguments.length === 1)
@@ -45,6 +50,7 @@
return this._scope;
},
+
// Serialize from Json
fromJson : function (json) {
if (json === undefined)
@@ -68,8 +74,7 @@
// Set operation
if (json["operation"] !== undefined) {
- var operation = json["operation"];
- this.operation(operation.replace(/^operation:/,''));
+ this.operation(json["operation"].replace(/^operation:/,''));
};
// Set scope
@@ -80,9 +85,10 @@
return this;
},
+
toString : function () {
- var str = '';
- var op = this.operation();
+ let str = '';
+ const op = this.operation();
str += op.charAt(0).toUpperCase() + op.slice(1);
str += ' of ' + (
this._scope === null ?