Skip to content

oracular / ms

Variable: ms ​

ts
const ms: Units;

Defined in: units.ts:37

Durations in milliseconds, the unit of Date.now(): ms.days(7) is 604800000. Plain multiplications and nothing else, for halfLife, cooldown, episodeTimeout and learning.halfLife when your timestamps are in milliseconds. If your at is in another unit, write durations in that unit instead: the engine only needs the two to agree.

Example ​

ts
const config = {
  episodeTimeout: ms.minutes(30),
  intents: {
    upgrade: {
      prior: 0.05,
      priorStrength: 10,
      halfLife: ms.days(7),
      signals: { 'pricing.viewed': 3 },
      reveal: { cooldown: ms.weeks(2) },
    },
  },
};

Released under the MIT License.