@jplorg/jpl 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -68,5 +68,35 @@ class JPLProgram {
68
68
  const outputs = await runtime.execute(normalizedInputs);
69
69
  return runtime.stripJSON(outputs);
70
70
  };
71
+
72
+ /**
73
+ * Return a new program with the provided definition's instructions prepended to the program.
74
+ */
75
+ prepend = programDefinition => {
76
+ validateDefinition(programDefinition);
77
+ const mergedDefinition = {
78
+ version: _library.DEFINITION_VERSION,
79
+ instructions: [...programDefinition.instructions, ...this.definition.instructions]
80
+ };
81
+ return new JPLProgram(mergedDefinition, {
82
+ program: this._options,
83
+ runtime: this._runtimeOptions
84
+ });
85
+ };
86
+
87
+ /**
88
+ * Return a new program with the provided definition's instructions appended to the program.
89
+ */
90
+ append = programDefinition => {
91
+ validateDefinition(programDefinition);
92
+ const mergedDefinition = {
93
+ version: _library.DEFINITION_VERSION,
94
+ instructions: [...this.definition.instructions, ...programDefinition.instructions]
95
+ };
96
+ return new JPLProgram(mergedDefinition, {
97
+ program: this._options,
98
+ runtime: this._runtimeOptions
99
+ });
100
+ };
71
101
  }
72
102
  var _default = exports.default = JPLProgram;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jplorg/jpl",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "JPL interpreter",
5
5
  "main": "./lib/index.js",
6
6
  "exports": {
@@ -75,6 +75,40 @@ class JPLProgram {
75
75
  const outputs = await runtime.execute(normalizedInputs);
76
76
  return runtime.stripJSON(outputs);
77
77
  };
78
+
79
+ /**
80
+ * Return a new program with the provided definition's instructions prepended to the program.
81
+ */
82
+ prepend = (programDefinition) => {
83
+ validateDefinition(programDefinition);
84
+
85
+ const mergedDefinition = {
86
+ version: DEFINITION_VERSION,
87
+ instructions: [...programDefinition.instructions, ...this.definition.instructions],
88
+ };
89
+
90
+ return new JPLProgram(mergedDefinition, {
91
+ program: this._options,
92
+ runtime: this._runtimeOptions,
93
+ });
94
+ };
95
+
96
+ /**
97
+ * Return a new program with the provided definition's instructions appended to the program.
98
+ */
99
+ append = (programDefinition) => {
100
+ validateDefinition(programDefinition);
101
+
102
+ const mergedDefinition = {
103
+ version: DEFINITION_VERSION,
104
+ instructions: [...this.definition.instructions, ...programDefinition.instructions],
105
+ };
106
+
107
+ return new JPLProgram(mergedDefinition, {
108
+ program: this._options,
109
+ runtime: this._runtimeOptions,
110
+ });
111
+ };
78
112
  }
79
113
 
80
114
  export default JPLProgram;