diff --git a/src/comment.ts b/src/comment.ts new file mode 100644 index 0000000..fa48de9 --- /dev/null +++ b/src/comment.ts @@ -0,0 +1,15 @@ +export default class Comment { + content: string; + + constructor(content: string) { + this.content = content + } + + merge(other: Comment): Comment { + return new Comment(`${this} ${other}`) + } + + toString(): string { + return this.content + } +} diff --git a/src/cr/calendar-round.ts b/src/cr/calendar-round.ts index 01aeb25..409d8b9 100644 --- a/src/cr/calendar-round.ts +++ b/src/cr/calendar-round.ts @@ -7,6 +7,7 @@ import NumberCoefficient from "./component/numberCoefficient"; import {Wildcard} from "../wildcard"; import WildcardCoefficient from "./component/wildcardCoefficient"; import IPart from "../i-part"; +import Comment from '../comment'; /** @ignore */ const singleton: { [key: string]: CalendarRound } = {}; @@ -37,6 +38,7 @@ export function getCalendarRound( export class CalendarRound implements IPart { tzolkin: Tzolkin; haab: Haab; + comment: Comment | undefined; constructor(tzolkin: Tzolkin, haab: Haab) { /** @@ -50,7 +52,7 @@ export class CalendarRound implements IPart { this.validate(); } - + /** * Validate that the Calendar Round has a correct 260-day and Haab * configuration diff --git a/src/cr/haab.ts b/src/cr/haab.ts index da7c771..6a21f39 100644 --- a/src/cr/haab.ts +++ b/src/cr/haab.ts @@ -5,6 +5,7 @@ import NumberCoefficient from "./component/numberCoefficient"; import {coefficientParser as _} from "./component/coefficient"; import ICoefficient from "./component/iCoefficient"; import IPart from "../i-part"; +import Comment from "../comment"; const singleton: { [key: string]: Haab } = {}; @@ -37,6 +38,7 @@ export function getHaab(coeff: ICoefficient, month: Wildcard | HaabMonth): Haab export class Haab implements IPart { coeff: ICoefficient; month: Wildcard | HaabMonth; + comment: Comment | undefined; _privateNext: null | Haab; /** diff --git a/src/cr/tzolkin.ts b/src/cr/tzolkin.ts index 0b1d265..d08d546 100644 --- a/src/cr/tzolkin.ts +++ b/src/cr/tzolkin.ts @@ -5,6 +5,7 @@ import NumberCoefficient from "./component/numberCoefficient"; import WildcardCoefficient from "./component/wildcardCoefficient"; import ICoefficient from "./component/iCoefficient" import IPart from "../i-part"; +import Comment from "../comment"; const singleton: { [key: string]: Tzolkin } = {}; @@ -36,6 +37,7 @@ export function getTzolkin(coeff: ICoefficient, day: TzolkinDay | Wildcard): Tzo export class Tzolkin implements IPart { day: TzolkinDay | Wildcard; coeff: ICoefficient; + comment: Comment | undefined; _privateNext: Tzolkin | null; /** diff --git a/src/full-date.ts b/src/full-date.ts index 0178e08..0d8fcfe 100644 --- a/src/full-date.ts +++ b/src/full-date.ts @@ -4,11 +4,13 @@ import LongCount from "./lc/long-count"; import {CalendarRound} from "./cr/calendar-round"; import IPart from "./i-part"; +import Comment from "./comment"; export default class FullDate implements IPart { cr: CalendarRound; lc: LongCount; + comment: Comment | undefined; constructor(cr: CalendarRound, lc: LongCount) { this.cr = cr; diff --git a/src/i-part.ts b/src/i-part.ts index 6dab847..74a3313 100644 --- a/src/i-part.ts +++ b/src/i-part.ts @@ -1,3 +1,7 @@ +import Comment from "./comment"; + export default interface IPart { + comment: Comment | undefined; + equal(other: IPart): boolean; } diff --git a/src/lc/distance-number.ts b/src/lc/distance-number.ts index 046edb5..49a4cf9 100644 --- a/src/lc/distance-number.ts +++ b/src/lc/distance-number.ts @@ -5,11 +5,13 @@ import {isWildcard, Wildcard} from "../wildcard"; import LongcountAddition from "../operations/longcount-addition"; import LongcountSubtraction from "../operations/longcount-subtraction"; import IPart from "../i-part"; +import Comment from "../comment"; export default class DistanceNumber implements IPart { parts: (number | Wildcard)[]; datePattern: RegExp; sign: number; + comment: Comment | undefined /** * @param {...number|Wildcard} cycles - Components in the long count diff --git a/src/operations/calendar-round-wildcard.ts b/src/operations/calendar-round-wildcard.ts index ee11f8b..86576ee 100644 --- a/src/operations/calendar-round-wildcard.ts +++ b/src/operations/calendar-round-wildcard.ts @@ -1,6 +1,7 @@ import CalendarRoundIterator from './calendar-round-iter'; import {CalendarRound} from "../cr/calendar-round"; import IPart from "../i-part"; +import Comment from '../comment'; /** * A reusable singleton instance of the CalendarRoundIterator @@ -15,6 +16,7 @@ const iter = new CalendarRoundIterator(); */ export default class CalendarRoundWildcard implements IPart { private cr: CalendarRound; + comment: Comment | undefined; /** * @param {CalendarRound} cr diff --git a/src/operations/fulldate-wildcard.ts b/src/operations/fulldate-wildcard.ts index a252d4c..886ea63 100644 --- a/src/operations/fulldate-wildcard.ts +++ b/src/operations/fulldate-wildcard.ts @@ -1,6 +1,7 @@ import FullDate from '../full-date'; import LongCountWildcard from './longcount-wildcard'; import IPart from "../i-part"; +import Comment from '../comment'; /** @ignore */ // const concat = (x, y) => x.concat(y); @@ -20,6 +21,7 @@ import IPart from "../i-part"; */ export default class FullDateWildcard implements IPart { private fullDate: FullDate; + comment: Comment | undefined; /** * @param {FullDate} partialDate diff --git a/src/operations/longcount-addition.ts b/src/operations/longcount-addition.ts index 9048749..c892259 100644 --- a/src/operations/longcount-addition.ts +++ b/src/operations/longcount-addition.ts @@ -5,11 +5,13 @@ import LongCount from "../lc/long-count"; import ILongcount from "./ILongcount"; import DistanceNumber from "../lc/distance-number"; import IPart from "../i-part"; +import Comment from "../comment"; export default class LongcountAddition implements IPart { private a: DistanceNumber; private b: DistanceNumber private LcClass: ILongcount; + comment: Comment | undefined; /** * @param {object} lcClass - Special param to pass the LongCount class into this operator to diff --git a/src/operations/longcount-subtraction.ts b/src/operations/longcount-subtraction.ts index 5c2b4fe..0c4fab7 100644 --- a/src/operations/longcount-subtraction.ts +++ b/src/operations/longcount-subtraction.ts @@ -5,11 +5,13 @@ import ILongcount from "./ILongcount"; import LongCount from "../lc/long-count"; import DistanceNumber from "../lc/distance-number"; import IPart from "../i-part"; +import Comment from "../comment"; export default class LongcountSubtraction implements IPart { private a: DistanceNumber private b: DistanceNumber private LcClass: ILongcount + comment: Comment | undefined; /** * @param {object} lcClass - Special param to pass the LongCount class into this operator to diff --git a/src/operations/longcount-wildcard.ts b/src/operations/longcount-wildcard.ts index 4c2ae29..7dbbe95 100644 --- a/src/operations/longcount-wildcard.ts +++ b/src/operations/longcount-wildcard.ts @@ -1,5 +1,6 @@ import LongCount from "../lc/long-count"; import IPart from "../i-part"; +import Comment from "../comment"; /** * Given a Long Count with a wildcard, calculate all possible matching fully @@ -7,6 +8,7 @@ import IPart from "../i-part"; */ export default class LongCountWildcard implements IPart { private lc: LongCount; + comment: Comment | undefined; /** * @param {LongCount} lc diff --git a/src/wildcard.ts b/src/wildcard.ts index 83e2f85..b1b2946 100644 --- a/src/wildcard.ts +++ b/src/wildcard.ts @@ -9,8 +9,10 @@ * > true */ import IPart from "./i-part"; +import Comment from "./comment"; export class Wildcard implements IPart { + comment: Comment | undefined; /** * Represent the Wildcard as a string. ie, '*'. * @returns {string}