New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@kobayami/number-types

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@kobayami/number-types

A minor package that provides type aliases int, long, float and double in TypeScript

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

@kobayami/number-types

Installation

npm install --save @kobayami/number-types

Version and License

  • Latest version: 1.0.0
  • License: MIT
  • Changes

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

Keywords

type

FAQs

Package last updated on 22 Jun 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts