New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ts-gems

Package Overview
Dependencies
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts-gems - npm Package Compare versions

Comparing version 2.9.3 to 3.0.0

lib/combine.d.ts

15

lib/helpers.d.ts

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

import { Builtin } from './common';
import { IfAny, IfClass, IfTuple } from './type-check';
import { Builtin } from './types';

@@ -7,4 +7,3 @@ /**

*/
export type IfNoDeepValue<T> = _IfNoDeepValue<T>
type _IfNoDeepValue<T> =
export type IfNoDeepValue<T> =
T extends Builtin ? true

@@ -21,3 +20,11 @@ : IfAny<T> extends true ? T

: T extends WeakSet<any> ? true
// : T extends any[] ? true
: T extends any[] ? true
: false;
/**
* ValuesOf
* @desc Returns the union type of all the values in a type
*/
export type ValuesOf<T> = T[keyof T];

@@ -1,16 +0,15 @@

export * from "./common";
export * from "./keys";
export * from "./type-check";
export * from "./modify";
export * from "./deep-buildable";
export * from "./deep-nullish";
export * from "./deep-omit";
export * from "./deep-partial";
export * from "./deep-pick";
export * from "./deep-readonly";
export * from "./deep-remove-nulls";
export * from "./deep-required";
export * from "./deep-writable";
export * from "./combine";
export * from "./helpers";
export * from "./logical.js";
export * from "./mutable";
export * from "./nullish";
export * from "./omit";
export * from "./omit-never";
export * from "./opaque";
export * from "./partial";
export * from "./pick";
export * from "./omit";
export * from "./readonly";
export * from "./required";
export * from "./type-check";
export * from "./types";

@@ -1,65 +0,54 @@

import {
JsonKeys,
OptionalKeys,
ReadonlyKeys,
RequiredKeys,
WritableKeys
} from './keys';
import { IfNoDeepValue } from './helpers';
import { Or } from './logical.js';
import { IfFunction, IfNever } from './type-check';
/**
* OmitNever<T> is a type that omits all properties with a value of type "never".
*
* @template T - The original type
*
* @example
* type MyType = {
* a: string;
* b: number;
* c?: never;
* };
*
* type Result = OmitNever<MyType>;
* // Result is:
* // {
* // a: string;
* // b: number;
* // }
*/
export type OmitNever<T> = {
[K in keyof T as (Exclude<T[K], undefined> extends never ? never : K)]: T[K]
};
/**
* Construct a type with the properties of T except for those in type K,
* while preserving strict type checking.
*
* @template T - The original type.
* @template K - The keys of the properties to be removed from the original type.
*/
export type StrictOmit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
export type StrictOmit<T, X extends keyof T> = {
[K in keyof T as (K extends X ? never : K)]: T[K]
};
/**
* Omit all optional properties in T
* Omit all function properties in T
*/
export type OmitOptional<T> = OmitNever<Omit<T, OptionalKeys<T>>>;
export type OmitFunctions<T> = {
[K in keyof T as (
Or<
// Omit never keys
IfNever<Exclude<T[K], undefined>>,
// Omit functions
IfFunction<Exclude<T[K], undefined>>
> extends true ? never : K
)]: T[K]
};
/**
* Omit all required properties in T
* Exclude from properties of T those types that are assignable to X
*/
export type OmitRequired<T> = OmitNever<Omit<T, RequiredKeys<T>>>;
export type OmitTypes<T, X> = {
[K in keyof T as (IfNever<Exclude<T[K], undefined | X>, never, K>)]: Exclude<T[K], X>
};
/**
* Omit all readonly properties in T
* Omit all function properties in T
*/
export type OmitReadonly<T> = OmitNever<Omit<T, ReadonlyKeys<T>>>;
export type DeepOmitTypes<T, X> = {
[K in keyof T as (IfNever<Exclude<T[K], undefined | X>, never, K>)]: // Do not deep process No-Deep values
IfNoDeepValue<Exclude<T[K], undefined>> extends true ? Exclude<T[K], X>
// Deep process objects
: DeepOmitTypes<Exclude<T[K], undefined>, X>
};
/**
* Omit all writable properties in T
* Omit all function properties in T deeply including arrays
*/
export type OmitWritable<T> = OmitNever<Omit<T, WritableKeys<T>>>;
/**
* Omit all JSON friendly properties in T
*/
export type OmitJson<T> = OmitNever<Omit<T, JsonKeys<T>>>;
export type DeeperOmitTypes<T, X> = {
[K in keyof T as (IfNever<Exclude<T[K], undefined | X>, never, K>)]: // Do not deep process No-Deep values
// Deep process arrays
Exclude<T[K], undefined> extends (infer U)[] ? DeeperOmitTypes<U, X>[]
: IfNoDeepValue<Exclude<T[K], undefined>> extends true ? Exclude<T[K], X>
// Deep process objects
: DeeperOmitTypes<Exclude<T[K], undefined>, X>
};

@@ -1,33 +0,93 @@

import {
JsonKeys,
OptionalKeys,
ReadonlyKeys,
RequiredKeys,
WritableKeys
} from './keys';
import { Or } from './logical.js';
import { OmitFunctions } from './omit';
import { IfAny, IfEmptyObject, IfFunction, IfNever, IfUnknown } from './type-check';
/**
* Pick all optional properties in T
* From T, pick a set of properties whose keys are in the union K,
* while preserving strict type checking.
*/
export type PickOptional<T> = Pick<T, OptionalKeys<T>>;
export type StrictPick<T, X extends keyof T> = {
[K in keyof T as (
Or<
// Omit never keys
IfNever<Exclude<T[K], undefined>>,
// Omit X
K extends X ? false : true
> extends true ? never : K
)]: T[K]
};
/**
* Pick all required properties in T
* Pick all function properties in T
*/
export type PickRequired<T> = Pick<T, RequiredKeys<T>>;
export type PickFunctions<T> = {
[K in keyof T as (
Or<
// Omit never keys
IfNever<Exclude<T[K], undefined>>,
// Omit non functions
IfFunction<Exclude<T[K], undefined>, false, true>
> extends true ? never : K
)]: T[K]
};
/**
* Pick all readonly properties in T
* Pick all function properties in T
*/
export type PickReadonly<T> = Pick<T, ReadonlyKeys<T>>;
export type PickTypes<T, X> = {
[K in keyof T as (
Or<
// Omit never keys
IfNever<Exclude<T[K], undefined>>,
// Omit types which not exists in X
T[K] extends X ? false :
X extends T[K] ? false : true
> extends true ? never : K
)]: T[K]
};
/**
* Pick all writable properties in T
* Pick all function properties in T
*/
export type PickWritable<T> = Pick<T, WritableKeys<T>>;
export type StrictPickTypes<T, X> = {
[K in keyof T as (
Or<
// Omit never keys
IfNever<Exclude<T[K], undefined>>,
// Omit unknown
IfUnknown<T[K]>,
// Omit any
IfAny<T[K]>,
// Omit {}
IfEmptyObject<T[K]>,
// Omit types which not exists in X
T[K] extends X ? false :
X extends T[K] ? false : true
> extends true ? never : K
)]: T[K]
};
/**
* Pick all JSON friendly properties (no symbols) in T
* @desc Returns Function keys of an object
*/
export type PickJson<T> = Pick<T, JsonKeys<T>>;
export type FunctionKeys<T> = keyof PickFunctions<T>;
/**
* @desc Returns non function keys of an object
*/
export type NonFunctionKeys<T> = keyof OmitFunctions<T>;
/**
* @desc Returns keys that match given type
*/
export type KeysOfTypes<T, X> = keyof PickTypes<T, X>;
/**
* @desc Returns keys that equals given type
*/
export type StrictKeysOfTypes<T, X> = keyof StrictPickTypes<T, X>;

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

import { Primitive, Type } from './common';
import { Primitive, Type } from './types';

@@ -23,7 +23,8 @@ type NonObj = Primitive | Function;

// export type IfUndefined<T, Y = true, N = false> =
// IfEquals<T, undefined, Y, N> extends Y ? Y
// : undefined extends T ? Y : N;
/**
* Returns "Y" if "T" is "never", "N" otherwise
*/
export type IfSymbol<T, Y = true, N = false> =
IfEquals<T, symbol, Y, N>;
/**

@@ -66,6 +67,8 @@ * Returns Y if typeof T is "unknown", N otherwise

IfNever<T> extends true ? N :
IfClass<T> extends true ? N :
IfFunction<T> extends true ? N :
T extends Primitive ? Y :
N;
IfNull<T> extends true ? Y :
IfUndefined<T> extends true ? Y :
IfClass<T> extends true ? N :
IfFunction<T> extends true ? N :
T extends Primitive ? Y :
N;

@@ -76,18 +79,2 @@ export type IfPrimitiveOrAny<T, Y = true, N = false> =

/**
* Returns Y if typeof T is JSON like, N otherwise
*/
export type IfJson<T, Y = true, N = false> =
IfAny<T> extends true ? Y :
IfNull<T> extends true ? Y :
IfNever<T> extends true ? N :
T extends Function ? N :
T extends symbol ? N :
IfUndefined<T> extends true ? N :
T extends (infer U)[] ? IfJson<U> extends true ? Y : N
: Y;
export type IfJsonOrAny<T, Y = true, N = false> =
IfAny<T> extends true ? Y : IfJson<T, Y, N>;
/**
* Returns Y if typeof T is an empty object, N otherwise

@@ -117,7 +104,5 @@ */

IfNever<T> extends true ? N
: IfUndefined<T> extends true ? N
: IfNull<T> extends true ? N
: T extends Type ? N
: T extends Function ? Y
: N;
: T extends Type ? N
: T extends Function ? Y
: N;

@@ -133,5 +118,3 @@ export type IfFunctionOrAny<T, Y = true, N = false> =

: IfUndefined<T> extends true ? N
: IfNull<T> extends true ? N
: T extends Type ? Y
: N;
: T extends Type ? Y : N;

@@ -145,7 +128,2 @@ export type IfClassOrAny<T, Y = true, N = false> =

*/
type EqualsWrapped<T> = T extends infer R & {}
? {
[P in keyof R]: R[P]
}
: never
export type IfEquals<T1, T2, Y = true, N = false> =

@@ -156,2 +134,6 @@ IfObject<T1> | IfObject<T2> extends true

type EqualsWrapped<T> = T extends infer R & {}
? { [P in keyof R]: R[P] }
: never;
/**

@@ -158,0 +140,0 @@ * Returns "Y" if type "T" matches "U", "N" otherwise

@@ -15,3 +15,3 @@ {

],
"version": "2.9.3",
"version": "3.0.0",
"types": "lib/index.d.ts",

@@ -18,0 +18,0 @@ "main": "lib/index.js",

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