/** * Decimal text to exact 100 ns ticks. * * Layer 1, not 3 — this file sits in `tal/` but does not belong to it. It imports `constants.ts` * and nothing else, and `header/parse.ts` and `header/lookup.ts` at layer 2 both call it, so * labelling it 3 with the rest of the directory made the only two upward runtime imports in the * package (corrected in 0.4.256). A module's layer is its dependencies, not its folder. * * Sole owner of the string -> tick conversion, which is the whole reason event times in edfcore * compare exactly. `parseFloat`, `Number(text)` and float arithmetic appear nowhere on that path: * an onset written `+0.1` and one written `+0.3` are integers here, so equality, ordering and * subtraction are decided by the digits on disk rather than by float64 rounding. */ /** * One parsed onset or duration field. * * `ticks` is the authoritative value; `seconds` and any float derived from it are conveniences. */ export interface TickParse { /** * The text matched the EDF+ grammar for its field. When false, `ticks` is 0n except in the * one documented case in `parseSignedTicks` (a valid magnitude with the sign missing). */ readonly ok: boolean; readonly ticks: bigint; /** The input verbatim, so a caller never has to reconstruct the digits it came from. */ readonly raw: string; /** Lossy by construction. See `ticksToSeconds`. */ readonly seconds: number; } /** * An EDF+ onset: `("+" / "-") 1*DIGIT [ "." 1*DIGIT ]`. * * The sign is mandatory, so an unsigned onset is a spec violation and `ok` is false — the caller * emits `TAL_MALFORMED`. The magnitude is parsed anyway and returned in `ticks`, so a lenient * caller can still use the value instead of discarding an otherwise readable annotation. That is * the only case where `ok: false` comes with a meaningful `ticks`. * * `-` applies to the WHOLE value, fraction included: `-0.5` is -5000000 ticks, not -0 plus * 5000000. Splitting the sign off the fraction flips pre-stimulus event times about zero. */ export declare function parseSignedTicks(text: string): TickParse; /** * An EDF+ duration: `1*DIGIT [ "." 1*DIGIT ]`, never signed. * * A leading `+` or `-` fails the grammar; it is not tolerated and not stripped, because a signed * duration means the writer's field layout is not the one we are reading. */ export declare function parseUnsignedTicks(text: string): TickParse; /** * Ticks as float64 seconds, for ergonomics and display. * * Lossy by construction — most tick values are not representable in binary floating point, and * beyond 2^53 ticks (~28.5 years) even the integer part rounds. The exact value always stays * available as ticks, and that is what comparisons must use. * * Split into whole seconds plus remainder so that only the remainder is ever divided; bigint * `/` truncates toward zero and `%` keeps the dividend's sign, so both parts share a sign and * the sum is correct for negative onsets. */ export declare function ticksToSeconds(ticks: bigint): number; /** * Integer division that rounds toward -Infinity and +Infinity respectively, `b` positive. * * Bigint `/` truncates toward zero, so both need a correction on the negative side, and the * negative side is reached by ordinary input: a window that starts before record 0 is how a * pre-stimulus epoch is spelled. They live here, beside the tick conversions, because every * caller is dividing a tick count by another tick count and three modules had grown their own * copies of the same four lines. */ export declare function floorDiv(a: bigint, b: bigint): bigint; /** * Division rounding toward positive infinity, the counterpart to `floorDiv` above. BigInt `/` * truncates toward zero, so neither direction is what the operator gives for a negative operand — * and a time before the recording's start is exactly where that matters. */ export declare function ceilDiv(a: bigint, b: bigint): bigint; /** * Clamps a tick count to what a `BigInt64Array` element can hold. * * Assignment to a `BigInt64Array` wraps modulo 2^64 rather than throwing, and every onset array * in edfcore is one. Wrapping turns a monotonically increasing series into one that jumps * backwards, which downstream code reads as a genuine discontinuity: a file whose declared * record duration overflows the range then indexes as one segment per record, with negative * gaps between them and no diagnostic anywhere. * * Saturating keeps the array non-decreasing, so an absurd geometry stays visibly absurd instead * of becoming plausibly wrong. Reaching either bound needs a declared geometry that is already * impossible — over 29,000 years of records — but `recordDuration` is a free-form ASCII field * that accepts exponent notation, so three bytes are enough to ask for it. */ export declare function saturateToInt64(ticks: bigint): bigint; export declare function secondsToTicks(seconds: number, name: string): bigint; //# sourceMappingURL=ticks.d.ts.map