Rocky_Mountain_Vending/.pnpm-store/v10/files/0b/827db18b6d08b2bf43f8b666c56ebeaff22a3b63ec1d5906c5890ffbc4eda3262fd37f4a79d4e337ced74c9a755bf0b1dda112e70032d9164d90567b1921d4
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

68 lines
1.9 KiB
Text

'use strict';
const frame = require('./frame');
const speedIndex = require('./speed-index');
/**
* @typedef {import('../speedline').TraceEvent} TraceEvent
* @typedef {import('../speedline').IncludeType} IncludeType
* @typedef {import('../speedline').Output['frames'][number]} Frame
*/
/**
* @param {Array<Frame>} frames
* @param {{startTs: number, endTs: number}} data
*/
function calculateValues(frames, data) {
const indexes = speedIndex.calculateSpeedIndexes(frames, data);
const duration = Math.floor(data.endTs - data.startTs);
const first = Math.floor(indexes.firstPaintTs - data.startTs);
const complete = Math.floor(indexes.visuallyCompleteTs - data.startTs);
return {
beginning: data.startTs,
end: data.endTs,
frames,
first,
complete,
duration,
speedIndex: indexes.speedIndex,
perceptualSpeedIndex: indexes.perceptualSpeedIndex
};
}
/** @type {{All: 'all', pSI: 'perceptualSpeedIndex', SI: 'speedIndex'}} */
const Include = {
All: 'all',
pSI: 'perceptualSpeedIndex',
SI: 'speedIndex'
};
/**
* Retrieve speed index informations
* @template {IncludeType} I
* @param {string|Array<TraceEvent>} timeline
* @param {import('../speedline').Options<I>} opts
* @return {Promise<import('../speedline').Output<I>>}
*/
module.exports = function (timeline, opts) {
const include = opts && opts.include || Include.All;
// Check for invalid `include` values
if (!Object.keys(Include).some(key => Include[key] === include)) {
throw new Error(`Unrecognized include option: ${include}`);
}
return frame.extractFramesFromTimeline(timeline, opts).then(function (data) {
const frames = data.frames;
if (include === Include.All || include === Include.SI) {
speedIndex.calculateVisualProgress(frames, opts);
}
if (include === Include.All || include === Include.pSI) {
speedIndex.calculatePerceptualProgress(frames, opts);
}
return calculateValues(frames, data);
});
};