{
          name = name || "";
          if (self.alarms.has(name)) {
            self.alarms.get(name).clear();
          }
          let alarm = new Alarm(self, name, alarmInfo);
          self.alarms.set(alarm.name, alarm);
        },

        get: function (name) {
          name = name || "";
          if (self.alarms.has(name)) {
            return Promise.resolve(self.alarms.get(name).data);
          }
          return Promise.resolve();
        },

        getAll: function () {
          let result = Array.from(self.alarms.values(), alarm => alarm.data);
          return Promise.resolve(result);
        },

        clear: function (name) {
          name = name || "";
          if (self.alarms.has(name)) {
            self.alarms.get(name).clear();
            return Promise.resolve(true);
          }
          return Promise.resolve(false);
        },

        clearAll: function () {
          let cleared = false;
          for (let alarm of self.alarms.values()) {
            alarm.clear();
            cleared = true;
          }
          return Promise.resolve(cleared);
        },

        onAlarm: new EventManager({
          context,
          module: "alarms",
          event: "onAlarm",
          extensionApi: self,
        }).api(),
      },
    };
  }
};
PK