@refactorlabs/recount 0.11.1 → 0.11.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -527,6 +527,11 @@ declare class CalculationBuilder<K extends string = never> {
527
527
  get problems(): readonly string[];
528
528
  /** The calculation as it's sent. Attach calls build it for you. */
529
529
  build(): Calculation;
530
+ /**
531
+ * @internal A copy holding the steps so far, so adding to this builder
532
+ * doesn't change it. Cheap: nothing is built.
533
+ */
534
+ snapshot(): CalculationBuilder<K>;
530
535
  /** @internal Builds once, never throws. */
531
536
  compile(): BuiltCalculation;
532
537
  }
@@ -565,7 +570,7 @@ declare class SpanGroup {
565
570
  span(type: Exclude<SpanType, 'group'>, name: string, options?: SpanOptions): this;
566
571
  addMessage(name: string, text?: string, opts?: MessageSpanOptions): this;
567
572
  /** A table span holding these calculations, as a child of the group. */
568
- calculation(name: string, calcs: CalculationLike | CalculationLike[], options?: CalculationSpanOptions): this;
573
+ calculation(name: string, calcs: CalculationLike | Iterable<CalculationLike>, options?: CalculationSpanOptions): this;
569
574
  alert(label: string, level: SpanAlertLevel, options?: SpanAlertOptions): this;
570
575
  _flush(push: (type: string, name: string, opts?: SpanOptions) => void, options?: Pick<GroupSpanOptions, 'limit' | 'sample' | 'sampleThreshold'>, log?: (msg: string) => void): void;
571
576
  }
@@ -587,7 +592,7 @@ declare class Trace {
587
592
  alert(label: string, level: SpanAlertLevel, options?: SpanAlertOptions): this;
588
593
  addMessage(name: string, text?: string, opts?: MessageSpanOptions): this;
589
594
  /** A table span holding these calculations. Pass builders without `.build()`. */
590
- calculation(name: string, calcs: CalculationLike | CalculationLike[], options?: CalculationSpanOptions): this;
595
+ calculation(name: string, calcs: CalculationLike | Iterable<CalculationLike>, options?: CalculationSpanOptions): this;
591
596
  addMetadata(data: Metadata): this;
592
597
  setEnvironment(environment: string): this;
593
598
  /**
@@ -654,6 +659,13 @@ declare class TableBuilder {
654
659
  /**
655
660
  * Colours a column's numbers (records) or a row (objects) by sign:
656
661
  * `.signHighlight('saving', { positive: 'success', negative: 'danger' })`.
662
+ * A row takes the sign of the number shown, after `transformValues()`,
663
+ * `.round()` and a format's places, as Recount shows it: money, number and
664
+ * percent to 2 places unless given, an integer to none, and a percent times
665
+ * 100. So -0.004 as money is zero, and 0.004 as a percent (0.40%) positive.
666
+ * When what's shown is text with a number in it, such as `'$-5'`, it
667
+ * takes the raw value's sign; a blank row, or text with no number such as
668
+ * `'N/A'`, takes none.
657
669
  */
658
670
  signHighlight(key: string, highlight: SignHighlight): this;
659
671
  round(decimals: number): this;
@@ -743,7 +755,7 @@ declare function addSpan<T>(type: Exclude<SpanType, 'group'>, name: string, fn:
743
755
  declare function addSpan<T>(type: Exclude<SpanType, 'group'>, name: string, opts: SpanOptions, fn: () => Promise<T>): Promise<T>;
744
756
  declare function addGroup(name: string, builder: (g: SpanGroup) => void, options?: GroupSpanOptions): void;
745
757
  declare function addMessage(name: string, text?: string, opts?: MessageSpanOptions): void;
746
- declare function addCalculation(name: string, calcs: CalculationLike | CalculationLike[], opts?: CalculationSpanOptions): void;
758
+ declare function addCalculation(name: string, calcs: CalculationLike | Iterable<CalculationLike>, opts?: CalculationSpanOptions): void;
747
759
  declare function addAlert(label: string, level: SpanAlertLevel, opts?: SpanAlertOptions): void;
748
760
  declare function named<T>(name: string, fn: () => Promise<T>): Promise<T>;
749
761
  declare function addMetadata(data: Metadata): void;
package/dist/index.d.ts CHANGED
@@ -527,6 +527,11 @@ declare class CalculationBuilder<K extends string = never> {
527
527
  get problems(): readonly string[];
528
528
  /** The calculation as it's sent. Attach calls build it for you. */
529
529
  build(): Calculation;
530
+ /**
531
+ * @internal A copy holding the steps so far, so adding to this builder
532
+ * doesn't change it. Cheap: nothing is built.
533
+ */
534
+ snapshot(): CalculationBuilder<K>;
530
535
  /** @internal Builds once, never throws. */
531
536
  compile(): BuiltCalculation;
532
537
  }
@@ -565,7 +570,7 @@ declare class SpanGroup {
565
570
  span(type: Exclude<SpanType, 'group'>, name: string, options?: SpanOptions): this;
566
571
  addMessage(name: string, text?: string, opts?: MessageSpanOptions): this;
567
572
  /** A table span holding these calculations, as a child of the group. */
568
- calculation(name: string, calcs: CalculationLike | CalculationLike[], options?: CalculationSpanOptions): this;
573
+ calculation(name: string, calcs: CalculationLike | Iterable<CalculationLike>, options?: CalculationSpanOptions): this;
569
574
  alert(label: string, level: SpanAlertLevel, options?: SpanAlertOptions): this;
570
575
  _flush(push: (type: string, name: string, opts?: SpanOptions) => void, options?: Pick<GroupSpanOptions, 'limit' | 'sample' | 'sampleThreshold'>, log?: (msg: string) => void): void;
571
576
  }
@@ -587,7 +592,7 @@ declare class Trace {
587
592
  alert(label: string, level: SpanAlertLevel, options?: SpanAlertOptions): this;
588
593
  addMessage(name: string, text?: string, opts?: MessageSpanOptions): this;
589
594
  /** A table span holding these calculations. Pass builders without `.build()`. */
590
- calculation(name: string, calcs: CalculationLike | CalculationLike[], options?: CalculationSpanOptions): this;
595
+ calculation(name: string, calcs: CalculationLike | Iterable<CalculationLike>, options?: CalculationSpanOptions): this;
591
596
  addMetadata(data: Metadata): this;
592
597
  setEnvironment(environment: string): this;
593
598
  /**
@@ -654,6 +659,13 @@ declare class TableBuilder {
654
659
  /**
655
660
  * Colours a column's numbers (records) or a row (objects) by sign:
656
661
  * `.signHighlight('saving', { positive: 'success', negative: 'danger' })`.
662
+ * A row takes the sign of the number shown, after `transformValues()`,
663
+ * `.round()` and a format's places, as Recount shows it: money, number and
664
+ * percent to 2 places unless given, an integer to none, and a percent times
665
+ * 100. So -0.004 as money is zero, and 0.004 as a percent (0.40%) positive.
666
+ * When what's shown is text with a number in it, such as `'$-5'`, it
667
+ * takes the raw value's sign; a blank row, or text with no number such as
668
+ * `'N/A'`, takes none.
657
669
  */
658
670
  signHighlight(key: string, highlight: SignHighlight): this;
659
671
  round(decimals: number): this;
@@ -743,7 +755,7 @@ declare function addSpan<T>(type: Exclude<SpanType, 'group'>, name: string, fn:
743
755
  declare function addSpan<T>(type: Exclude<SpanType, 'group'>, name: string, opts: SpanOptions, fn: () => Promise<T>): Promise<T>;
744
756
  declare function addGroup(name: string, builder: (g: SpanGroup) => void, options?: GroupSpanOptions): void;
745
757
  declare function addMessage(name: string, text?: string, opts?: MessageSpanOptions): void;
746
- declare function addCalculation(name: string, calcs: CalculationLike | CalculationLike[], opts?: CalculationSpanOptions): void;
758
+ declare function addCalculation(name: string, calcs: CalculationLike | Iterable<CalculationLike>, opts?: CalculationSpanOptions): void;
747
759
  declare function addAlert(label: string, level: SpanAlertLevel, opts?: SpanAlertOptions): void;
748
760
  declare function named<T>(name: string, fn: () => Promise<T>): Promise<T>;
749
761
  declare function addMetadata(data: Metadata): void;