@kobayami/number-types
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

@kobayami/number-types

Installation

npm install --save @kobayami/number-types

Version and License

Summary

A minor package that provides the type aliases int, long, float and double for number types in TypeScript. The types int, float and double are aliases for number, long is an alias for bigInt.

While the TypeScript compiler cannot enforce the associated number ranges (e.g., restricting int to the 32 bit signed integer range), these type aliases allow for a more precise notation of number types. This serves documentation purposes and makes the code more readable. For example, a variable that represents an index could be declared an int, while a variable used for computations could be declared a double.

Also, this may simplify things if code should later be ported from TypeScript to some other language.

Usage Example

import { int, double } from "@kobayami/number-types";

function getElementAt<T>(array: T[], index: int): T {
    return array[index];
}

function getDistance(velocity: double, time: double): double {
    return velocity * time;
}

See Also

Package Sidebar

Install

npm i @kobayami/number-types

Weekly Downloads

20

Version

1.0.0

License

MIT

Unpacked Size

5.3 kB

Total Files

8

Last publish

Collaborators

  • kobayami