JSPM

decimal-type

3.0.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3
  • Score
    100M100P100Q66866F
  • License MIT

Package Exports

  • decimal-type
  • decimal-type/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (decimal-type) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

decimal-type

npm version npm downloads/month GitHub license

A collection of helper functions for working with decimal numbers in various JS/TS environments.

Installation

# With Yarn
yarn add decimal-type

# or with npm
npm i decimal-type

Usage

As this is more like a bundle, you are free to combine the functions you need. Check the Examples section for some use cases.

Examples

Nest.js / GraphQL (code-first) / Prisma / class-transformer

import { DecimalScalar, DecimalType } from 'decimal-type';
import { Field, InputType } from '@nestjs/graphql';
import { Decimal } from '@prisma/client/runtime';

@InputType()
export class NewTransactionInput {
  @Field()
  name: string;

  @Field(() => DecimalScalar)
  @DecimalType()
  amount: Decimal;
}

NOTE: Don't forget to register the DecimalScalar scalar with Nest.js. See here for more information.

INFO: If the @DecimalType() decorator is not used, class-transformer will not know how to transform the Decimal type returned by the DecimalScalar scalar into a new Decimal instance.