Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore decimal trimming behaviour #70

Closed
randywanga opened this issue Jan 22, 2019 · 1 comment
Closed

Restore decimal trimming behaviour #70

randywanga opened this issue Jan 22, 2019 · 1 comment

Comments

@randywanga
Copy link
Contributor

randywanga commented Jan 22, 2019

Currently, it's too much of a hassle to properly implement this behaviour - it's causing a lot of bugs. So we've decided to scrap it for now. Here's the code that was written, located in decimal.ts:

export function trimDecimals(
  value: string,
  options: StateConverterOptionsWithContext,
  decimalOptions?:
    | Partial<DecimalOptions>
    | ((context: any) => Partial<DecimalOptions>)
): string {
  const [before, after] = value.split(".");
  if (typeof after === "undefined") {
    return value;
  }
  const trimmedAfter = after.substring(
    0,
    getOptions(options.context, decimalOptions).decimalPlaces
  );
  if (trimmedAfter.length === 0) {
    return before;
  }
  return [before, trimmedAfter].join(".");
}

This might be useful when trying to re-implement this behaviour.

@RickLucassen
Copy link
Contributor

Closing. Has been re-implemented since.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants