@loop/protocol-engine
Peptide protocol logic — dosing calculations, reconstitution math, cycle management, and validation.
Installation
pnpm add @loop/protocol-engineReconstitution Calculator
Calculate how to reconstitute lyophilized peptides:
import { calculateReconstitution } from '@loop/protocol-engine';
const result = calculateReconstitution({
peptideAmount: 5, // mg per vial
bacteriostaticWater: 2, // mL of BAC water
desiredDose: 250, // mcg per injection
});
console.log(result.concentration); // mcg/mL
console.log(result.volumePerDose); // mL to draw per injection
console.log(result.dosesPerVial); // number of doses per vial
console.log(result.insulinUnits); // IU markings on insulin syringeUnit Conversion
import { toMcg, formatDose } from '@loop/protocol-engine';
toMcg(5, 'mg'); // 5000
toMcg(250, 'mcg'); // 250
formatDose(250, 'mcg'); // '250mcg'
formatDose(5, 'mg'); // '5mg'Validation
import { validateStack, validateDose } from '@loop/protocol-engine';
// Validate an entire stack
const stackResult = validateStack({
items: [
{ compound: 'BPC-157', dosage: '250mcg', frequency: '2x daily' },
{ compound: 'TB-500', dosage: '2.5mg', frequency: '2x weekly' },
],
});
// Validate a single dose
const doseResult = validateDose({
compound: 'BPC-157',
amount: 250,
unit: 'mcg',
});Cycle Management
import { getCurrentPhase, getCycleProgress, advanceCycle } from '@loop/protocol-engine';
// Get current phase of a cycle
const phase = getCurrentPhase({
startDate: '2024-06-01',
cycleLength: 8, // weeks
currentDate: '2024-07-01',
});
console.log(phase.week); // 5
console.log(phase.phase); // 'active'
console.log(phase.daysRemaining); // 21
// Get progress percentage
const progress = getCycleProgress({
startDate: '2024-06-01',
endDate: '2024-07-27',
currentDate: '2024-07-01',
});
console.log(progress.percentage); // 62.5
// Advance to next cycle
const nextCycle = advanceCycle({
currentCycle: 1,
totalCycles: 3,
restPeriod: 4, // weeks
});