Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

type-fest

Package Overview
Dependencies
Maintainers
1
Versions
161
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

type-fest - npm Package Compare versions

Comparing version 4.28.1 to 4.29.0

source/int-closed-range.d.ts

3

index.d.ts

@@ -69,3 +69,3 @@ // Basic

export type {StructuredCloneable} from './source/structured-cloneable';
export type {Schema} from './source/schema';
export type {Schema, SchemaOptions} from './source/schema';
export type {LiteralToPrimitive} from './source/literal-to-primitive';

@@ -110,2 +110,3 @@ export type {LiteralToPrimitiveDeep} from './source/literal-to-primitive-deep';

export type {IntRange} from './source/int-range';
export type {IntClosedRange} from './source/int-closed-range';
export type {IsEqual} from './source/is-equal';

@@ -112,0 +113,0 @@ export type {

{
"name": "type-fest",
"version": "4.28.1",
"version": "4.29.0",
"description": "A collection of essential TypeScript types",

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

@@ -195,2 +195,4 @@ <div align="center">

- [`TaggedUnion`](source/tagged-union.d.ts) - Create a union of types that share a common discriminant property.
- [`IntRange`](source/int-range.d.ts) - Generate a union of numbers (includes the start and excludes the end).
- [`IntClosedRange`](source/int-closed-range.d.ts) - Generate a union of numbers (includes the start and the end).
- [`IntRange`](source/int-range.d.ts) - Generate a union of numbers.

@@ -197,0 +199,0 @@ - [`ArrayIndices`](source/array-indices.d.ts) - Provides valid indices for a constant array or tuple.

@@ -32,2 +32,4 @@ import type {BuildTuple} from './internal';

```
@see IntClosedRange
*/

@@ -34,0 +36,0 @@ export type IntRange<Start extends number, End extends number, Step extends number = 1> = PrivateIntRange<Start, End, Step>;

@@ -22,2 +22,3 @@ /**

passwordHash: string;
attributes: ['Foo', 'Bar']
}

@@ -36,2 +37,3 @@

passwordHash: 'hide',
attributes: ['mask', 'show']
}

@@ -42,3 +44,3 @@ ```

*/
export type Schema<ObjectType, ValueType> = ObjectType extends string
export type Schema<ObjectType, ValueType, Options extends SchemaOptions = {}> = ObjectType extends string
? ValueType

@@ -54,3 +56,5 @@ : ObjectType extends Map<unknown, unknown>

: ObjectType extends Array<infer U>
? Array<Schema<U, ValueType>>
? Options['recurseIntoArrays'] extends false | undefined
? ValueType
: Array<Schema<U, ValueType>>
: ObjectType extends (...arguments_: unknown[]) => unknown

@@ -65,3 +69,3 @@ ? ValueType

: ObjectType extends object
? SchemaObject<ObjectType, ValueType>
? SchemaObject<ObjectType, ValueType, Options>
: ValueType;

@@ -72,6 +76,45 @@

*/
type SchemaObject<ObjectType extends object, K> = {
[KeyType in keyof ObjectType]: ObjectType[KeyType] extends readonly unknown[] | unknown[]
? Schema<ObjectType[KeyType], K>
: Schema<ObjectType[KeyType], K> | K;
type SchemaObject<
ObjectType extends object,
K,
Options extends SchemaOptions,
> = {
[KeyType in keyof ObjectType]: ObjectType[KeyType] extends
| readonly unknown[]
| unknown[]
? Options['recurseIntoArrays'] extends false | undefined
? K
: Schema<ObjectType[KeyType], K, Options>
: Schema<ObjectType[KeyType], K, Options> | K;
};
/**
@see Schema
*/
export type SchemaOptions = {
/**
By default, this affects elements in array and tuple types. You can change this by passing `{recurseIntoArrays: false}` as the third type argument:
- If `recurseIntoArrays` is set to `true` (default), array elements will be recursively processed as well.
- If `recurseIntoArrays` is set to `false`, arrays will not be recursively processed, and the entire array will be replaced with the given value type.
@example
```
type UserMask = Schema<User, 'mask' | 'hide' | 'show', {recurseIntoArrays: false}>;
const userMaskSettings: UserMask = {
id: 'show',
name: {
firstname: 'show',
lastname: 'mask',
},
created: 'show',
active: 'show',
passwordHash: 'hide',
attributes: 'hide'
}
```
@default true
*/
readonly recurseIntoArrays?: boolean | undefined;
};
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc