
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
ts-extended-types
Advanced tools
Set of complementary basic types related to the ones provided by TypeScript to make your application even more type-safe
Set of complementary basic types related to the ones provided by TypeScript to make your application even more type-safe
Install with npm:
$ npm install --save ts-extended-types
import {int, stringInt, double, stringDouble, LocalDate, LocalTime, LocalDateTime, uuid } from 'ts-extended-types';
var intNumber: int;
var veryBigInt: stringInt
var doubleNumber: double;
var veryBigDoubleNumber: stringDouble
var localDate: LocalDate;
var localTime: LocalTime;
var localDateTime: LocalDateTime;
var uuidString: uuid;
int
: type that represents a integer number. It can be assigned to a number, but it cannot be assigned from a number.stringInt
: type that represents a integer number. It can be assigned to a number, but it cannot be assigned from a number: it can be so long that can be represented using a string instead of a number.double
: type that represents a floating point number with double precision. It can be assigned to a number, but it cannot be assigned from a number.stringDouble
: type that represents a floating point number with double precision; it can be so long that can be represented using a string instead of a number.LocalDate
: type that represents a local date without time (without timezone). Provided methods:
getFullYear(): int
: Gets the yeargetMonth(): int
: Gets the month (value between 0 to 11)getDate(): int
: Gets the day-of-the-monthgetDay(): int
: Gets the day of the week (0 represents Sunday)LocalTime
: type that represents a local time without date (without timezone). Provided methods:
getHours(): int
: Gets the hoursgetMinutes(): int
: Gets the minutesgetSeconds(): int
: Gets the secondsgetMilliseconds(): int
: Gets the millisecondsLocalDateTime
: type that represents a local date with time (without timezone). Provided methods: all methods provided by LocalDate
and LocalTime
plus:
getTime(): int
: Gets the time value in millisecondsuuid
: type that represents an uuid string. It can be assigned to a string, but it cannot be assigned from a string.Note:
int
or double
don't exists, all of these values are represented using a number
.stringInt
or stringDouble
don't exists, all of these values are represented using a number
or a string
.LocalDate
, LocalTime
or LocalDateTime
don't exists, all of these values are represented using the Date
object.uuid
don't exists, this value is represented using a string
.isInt(value: any) => value is int
: Returns true
if the value is a int
number, otherwise returns false
.asInt(value: number) => int
: Cast the number provided by argument as int
, throws an error if the provided number is not an integer.roundToInt(value: number) => int
: Round the provided number to an integer and then cast it to int
.truncateToInt(value: number) => int
: Truncate the provided number to an integer and then cast it to int
.floorToInt(value: number) => int
: Floor the provided number to an integer and then cast it to int
.ceilToInt(value: number) => int
: Ceil the provided number to an integer and then cast it to int
.isStringInt(value: any) => value is stringInt
: Returns true
if the value is a stringInt
number, otherwise returns false
.asStringInt(value: number|string) => stringInt
: Cast the number provided by argument as stringInt
, throws an error if the provided number is not an integer.roundToStringInt(value: number) => stringInt
: Round the provided number to an integer and then cast it to stringInt
.truncateToStringInt(value: number) => stringInt
: Truncate the provided number to an integer and then cast it to stringInt
.floorToStringInt(value: number) => stringInt
: Floor the provided number to an integer and then cast it to stringInt
.ceilToStringInt(value: number) => stringInt
: Ceil the provided number to an integer and then cast it to stringInt
.isDouble(value: any) => value is double
: Returns true
if the value is a double
precision number, otherwise returns false
.asDouble(value: number) => double
: Cast the number provided by argument as double
.isStringDouble(value: any) => value is stringDouble
: Returns true
if the value is a stringDouble
precision number, otherwise returns false
.asStringDouble(value: number|string) => double
: Cast the number provided by argument as stringDouble
, throws an error if the provided number is not a double.createLocalDate() => LocalDate
: create a new LocalDate
with the current date.createLocalDate(date: Date) => LocalDate
: create a new LocalDate
with the same date provided by argument.createLocalDate(year: number, month: number, date: number) => LocalDate
: create a new LocalDate
with the year, month and date (day of the month) provided by arguments.isLocalDate(value: any) => value is LocalDate
: Returns true
if the value is a LocalDate
, otherwise returns false
createLocalTime() => LocalTime
: create a new LocalTime
with the current time.createLocalTime(date: Date) => LocalTime
: create a new LocalTime
with the same time provided by argument.createLocalTime(hours: number, minutes?: number, seconds?: number, milliseconds?: number) => LocalTime
: create a new LocalTime
with the hours, minutes, seconds and milliseconds provided by arguments.isLocalTime(value: any) => value is LocalTime
: Returns true
if the value is a LocalTime
, otherwise returns false
createLocalDateTime() => LocalDateTime
: create a new LocalDate
with the current date and time.createLocalDateTime(date: Date) => LocalDateTime
: create a new LocalDateTime
with the same date and time provided by argument.createLocalDateTime(year: number, month: number, date: number, hours?: number, minutes?: number, seconds?: number, milliseconds?: number) => LocalDateTime
: create a new LocalDateTime
with the year, month, date (day of the month), hours, minutes, seconds and milliseconds provided by arguments.isLocalDate(value: any) => value is LocalDate
: Returns true
if the value is a LocalDate
, otherwise returns false
isUuid(value: any) => value is uuid
: Returns true
if the value is an uuid
string, otherwise returns false
.asUuid(value: string) => uuid
: Cast the string provided by argument as uuid
, throws an error if the provided string is not an uuid.MIT
FAQs
Set of complementary basic types related to the ones provided by TypeScript to make your application even more type-safe
We found that ts-extended-types demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.