Rocky_Mountain_Vending/.pnpm-store/v10/files/31/3b6acc25e0787018b43a2ef1570ac07558192d3d0253b4a520a6a0d50f463abf6846c5fe1ef763d03bc5a7ad425de03675bed43827383752935c185607a0e1
DMleadgen 46d973904b
Initial commit: Rocky Mountain Vending website
Next.js website for Rocky Mountain Vending company featuring:
- Product catalog with Stripe integration
- Service areas and parts pages
- Admin dashboard with Clerk authentication
- SEO optimized pages with JSON-LD structured data

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-12 16:22:15 -07:00

55 lines
2.3 KiB
Text

import { asyncScheduler } from '../scheduler/async';
import { audit } from './audit';
import { timer } from '../observable/timer';
import { MonoTypeOperatorFunction, SchedulerLike } from '../types';
/**
* Ignores source values for `duration` milliseconds, then emits the most recent
* value from the source Observable, then repeats this process.
*
* <span class="informal">When it sees a source value, it ignores that plus
* the next ones for `duration` milliseconds, and then it emits the most recent
* value from the source.</span>
*
* ![](auditTime.png)
*
* `auditTime` is similar to `throttleTime`, but emits the last value from the
* silenced time window, instead of the first value. `auditTime` emits the most
* recent value from the source Observable on the output Observable as soon as
* its internal timer becomes disabled, and ignores source values while the
* timer is enabled. Initially, the timer is disabled. As soon as the first
* source value arrives, the timer is enabled. After `duration` milliseconds (or
* the time unit determined internally by the optional `scheduler`) has passed,
* the timer is disabled, then the most recent source value is emitted on the
* output Observable, and this process repeats for the next source value.
* Optionally takes a {@link SchedulerLike} for managing timers.
*
* ## Example
*
* Emit clicks at a rate of at most one click per second
*
* ```ts
* import { fromEvent, auditTime } from 'rxjs';
*
* const clicks = fromEvent(document, 'click');
* const result = clicks.pipe(auditTime(1000));
* result.subscribe(x => console.log(x));
* ```
*
* @see {@link audit}
* @see {@link debounceTime}
* @see {@link delay}
* @see {@link sampleTime}
* @see {@link throttleTime}
*
* @param duration Time to wait before emitting the most recent source value,
* measured in milliseconds or the time unit determined internally by the
* optional `scheduler`.
* @param scheduler The {@link SchedulerLike} to use for managing the timers
* that handle the rate-limiting behavior.
* @return A function that returns an Observable that performs rate-limiting of
* emissions from the source Observable.
*/
export function auditTime<T>(duration: number, scheduler: SchedulerLike = asyncScheduler): MonoTypeOperatorFunction<T> {
return audit(() => timer(duration, scheduler));
}