Skip to content

Commit

Permalink
✨ Add Variables#get(key) & Variables#setFromTemplate(key, value)
Browse files Browse the repository at this point in the history
…method
  • Loading branch information
skerit committed Apr 27, 2024
1 parent c76993c commit 0b840ff
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Use shorter compiled function body ids when not on development environment
* Add basic `Optional` value-wrapper class support
* Make sure variables are always cast to a `Variables` instance
* Add `Variables#get(key)` & `Variables#setFromTemplate(key, value)` method

## 2.3.19 (2024-04-13)

Expand Down
22 changes: 22 additions & 0 deletions lib/core/variables.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,28 @@ Variables.setProperty(function length() {
return Object.keys(this).length;
});

/**
* Get a specific variable
*
* @author Jelle De Loecker <[email protected]>
* @since 2.4.0
* @version 2.4.0
*/
Variables.setMethod(function get(key) {
return this[key];
});

/**
* Set a specific variable from a template
*
* @author Jelle De Loecker <[email protected]>
* @since 2.4.0
* @version 2.4.0
*/
Variables.setMethod(function setFromTemplate(key, value) {
return this[key] = value;
});

/**
* Get this instance's own key-values
* (Skipping symbols)
Expand Down

0 comments on commit 0b840ff

Please sign in to comment.