private transformFn()

in glean/src/core/metrics/types/counter.ts [67:85]


  private transformFn(amount: number) {
    return (v?: JSONValue): CounterMetric => {
      const metric = new CounterMetric(amount);
      if (v) {
        try {
          // Throws an error if v in not valid input.
          metric.saturatingAdd(v);
        } catch {
          log(
            LOG_TAG,
            `Unexpected value found in storage for metric ${this.name}: ${JSON.stringify(
              v
            )}. Overwriting.`
          );
        }
      }
      return metric;
    };
  }