Socket
Socket
Sign inDemoInstall

type-fest

Package Overview
Dependencies
0
Maintainers
1
Versions
141
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.15.0 to 4.16.0

source/is-float.d.ts

2

index.d.ts

@@ -101,2 +101,4 @@ // Basic

export type {Spread} from './source/spread';
export type {IsInteger} from './source/is-integer';
export type {IsFloat} from './source/is-float';
export type {TupleToUnion} from './source/tuple-to-union';

@@ -103,0 +105,0 @@ export type {IntRange} from './source/int-range';

2

package.json
{
"name": "type-fest",
"version": "4.15.0",
"version": "4.16.0",
"description": "A collection of essential TypeScript types",

@@ -5,0 +5,0 @@ "license": "(MIT OR CC0-1.0)",

@@ -52,2 +52,18 @@ <div align="center">

<br>
<br>
<a href="https://logto.io/?ref=sindre">
<div>
<picture>
<source width="200" media="(prefers-color-scheme: dark)" srcset="https://sindresorhus.com/assets/thanks/logto-logo-dark.svg?x">
<source width="200" media="(prefers-color-scheme: light)" srcset="https://sindresorhus.com/assets/thanks/logto-logo-light.svg?x">
<img width="200" src="https://sindresorhus.com/assets/thanks/logto-logo-light.svg?x" alt="Logto logo">
</picture>
</div>
<b>The better identity infrastructure for developers</b>
<div>
<sup>Logto is an open-source Auth0 alternative designed for every app.</sup>
</div>
</a>
<br>
<br>
</p>

@@ -273,2 +289,4 @@ </div>

- [`IsNegative`](source/numeric.d.ts) - Returns a boolean for whether the given number is a negative number.
- [`IsFloat`](source/is-float.d.ts) - Returns a boolean for whether the given number is a float, like `1.5` or `-1.5`.
- [`IsInteger`](source/is-integer.d.ts) - Returns a boolean for whether the given number is a integer, like `-5`, `1.0` or `100`.
- [`GreaterThan`](source/greater-than.d.ts) - Returns a boolean for whether a given number is greater than another number.

@@ -275,0 +293,0 @@ - [`GreaterThanOrEqual`](source/greater-than-or-equal.d.ts) - Returns a boolean for whether a given number is greater than or equal to another number.

@@ -0,1 +1,4 @@

import type {IsFloat} from './is-float';
import type {IsInteger} from './is-integer';
export type Numeric = number | bigint;

@@ -52,3 +55,2 @@

A `number` that is an integer.
You can't pass a `bigint` as they are already guaranteed to be integers.

@@ -59,2 +61,28 @@ Use-case: Validating and documenting parameters.

```
type Integer = Integer<1>;
//=> 1
type IntegerWithDecimal = Integer<1.0>;
//=> 1
type NegativeInteger = Integer<-1>;
//=> -1
type Float = Integer<1.5>;
//=> never
// Supports non-decimal numbers
type OctalInteger: Integer<0o10>;
//=> 0o10
type BinaryInteger: Integer<0b10>;
//=> 0b10
type HexadecimalInteger: Integer<0x10>;
//=> 0x10
```
@example
```
import type {Integer} from 'type-fest';

@@ -72,10 +100,14 @@

// Because T is a number and not a string we can effectively use this to filter out any numbers containing decimal points
export type Integer<T extends number> = `${T}` extends `${bigint}` ? T : never;
export type Integer<T> =
T extends unknown // To distributive type
? IsInteger<T> extends true ? T : never
: never; // Never happens
/**
A `number` that is not an integer.
You can't pass a `bigint` as they are already guaranteed to be integers.
Use-case: Validating and documenting parameters.
It does not accept `Infinity`.
@example

@@ -92,3 +124,6 @@ ```

*/
export type Float<T extends number> = T extends Integer<T> ? never : T;
export type Float<T> =
T extends unknown // To distributive type
? IsFloat<T> extends true ? T : never
: never; // Never happens

@@ -95,0 +130,0 @@ /**

@@ -1,2 +0,2 @@

import type {IfEmptyObject} from '../index';
import type {IfEmptyObject} from './if-empty-object';
import type {IsUnion} from './internal';

@@ -3,0 +3,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc