@jellybeanci/int
v0.1.1
Published
Basic int converter
Downloads
5
Readme
int
Integer type caster module for JavaScript/TypeScript.
npm i @jellybeanci/int
import module
// ES6 Syntax
import {int} from "@jellybeanci/int";
// Commonjs Syntax
const {int} = require("@jellybeanci/int");
// Commonjs with custom name
const integer = require("@jellybeanci/int").int;
usage
const integerNumber = int(floatingPointNumber);
const parsedIntegerNumber = int(stringNumber);
demo
console.log(int(3.1415)); // 3
console.log(int(-6.2342)); // -6
console.log(int("25.3")); // 25
console.log(int("not a number")); // 0
types
type intFunctionType = (numberValue: number | string) => number;