mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
This commit introduces a new process for generating data for the AIO [events page](https://angular.io/events), which streamlines the process and minimizes duplication and manual work. For more details, see `aio/scripts/generate-events/README.md`. PR Close #45588
49 lines
1.1 KiB
JavaScript
49 lines
1.1 KiB
JavaScript
/**
|
|
* Helper class to interact with project-wide properties.
|
|
*/
|
|
class Property {
|
|
/**
|
|
* Create a new `Property` instance for the specified key.
|
|
*
|
|
* @param {string} key - The key of the property.
|
|
*/
|
|
constructor(key) {
|
|
this._key = `property:${key}`;
|
|
}
|
|
|
|
/**
|
|
* Delete this property.
|
|
*/
|
|
delete() {
|
|
Property._PROPS.deleteProperty(this._key);
|
|
}
|
|
|
|
/**
|
|
* Get the current value of this property.
|
|
*
|
|
* @return {unknown} - The current value of this property or `null` if this property does not
|
|
* exist.
|
|
*/
|
|
get() {
|
|
const storedValue = Property._PROPS.getProperty(this._key);
|
|
return storedValue && JSON.parse(storedValue);
|
|
}
|
|
|
|
/**
|
|
* Set the value of this property.
|
|
* Any existing value will be replaced.
|
|
*
|
|
* @param {unknown} newValue - The new value to set.
|
|
*/
|
|
set(newValue) {
|
|
if (newValue == null) {
|
|
this.delete();
|
|
} else {
|
|
Property._PROPS.setProperty(this._key, JSON.stringify(newValue));
|
|
}
|
|
}
|
|
}
|
|
|
|
Property.editedSheets = new Property('editedSheets');
|
|
|
|
Property._PROPS = PropertiesService.getScriptProperties();
|