import type ServiceScope from '../ServiceScope'; import type { IServiceKey } from '../IServiceKey'; /** * This is a {@link ServiceScope} contract for generating pseudorandom random numbers. * * @remarks * This interface abstracts the functionality of the system Math.random() API * for usage with a {@link ServiceScope}. For example, a unit test might replace * the default {@link RandomNumberGenerator} service with a mock implementation * that always returns the same sequence of random numbers, in order to ensure that * test failures are always repeatable. * * @public */ export interface IRandomNumberGenerator { /** * Returns a pseudorandom number between 0 (inclusive) and 1 (exclusive), * following the contract of Math.random(). */ generate(): number; } /** * This is the default implementation of {@link IRandomNumberGenerator} that simply * calls Math.random(). * * @public */ export default class RandomNumberGenerator implements IRandomNumberGenerator { /** * The service key for IRandomNumberGenerator. */ static readonly serviceKey: IServiceKey; constructor(serviceScope: ServiceScope); /** {@inheritDoc IRandomNumberGenerator.generate} */ generate(): number; } //# sourceMappingURL=RandomNumberGenerator.d.ts.map