Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

util: Convert CachedValue to an ES6 class.

Anders Kaseorgaee95ecf7e07
diff --git a/static/js/util.js b/static/js/util.js
index 8710c33b8c5..5a4a8bea24a 100644
--- a/static/js/util.js
+++ b/static/js/util.js
@@ -176,23 +176,25 @@ exports.array_compare = function util_array_compare(a, b) {
* which should be a function that computes the uncached value.
*/
const unassigned_value_sentinel = {};
-exports.CachedValue = function (opts) {
- this._value = unassigned_value_sentinel;
- Object.assign(this, opts);
-};
+class CachedValue {
+ _value = unassigned_value_sentinel;
+
+ constructor(opts) {
+ Object.assign(this, opts);
+ }
-exports.CachedValue.prototype = {
- get: function CachedValue_get() {
+ get() {
if (this._value === unassigned_value_sentinel) {
this._value = this.compute_value();
}
return this._value;
- },
+ }
- reset: function CachedValue_reset() {
+ reset() {
this._value = unassigned_value_sentinel;
- },
-};
+ }
+}
+exports.CachedValue = CachedValue;
exports.find_wildcard_mentions = function (message_content) {
const mention = message_content.match(/(^|\s)(@\*{2}(all|everyone|stream)\*{2})($|\s)/);