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

ts-gems

Package Overview
Dependencies
Maintainers
1
Versions
51
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 0.0.1 to 0.0.2

31

lib/keys.ts

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

import {IfEquals, IsEquals} from './type-check';
import {IfEquals, IfUndefined} from './type-check';

@@ -6,10 +6,6 @@ /**

*/
export type OptionalKeys<T> = keyof {
[K in keyof T as IsEquals<{ [P in K]+?: T[K]; }, { [P in K]: T[K]; }> extends true
? K
: never
]: T[K];
};
export type OptionalKeys<T> = {
[K in keyof T]-?: {} extends Pick<T, K> ? K : never;
}[keyof T];
/**

@@ -21,2 +17,10 @@ * Gets required keys of an object

/**
* Gets Function keys of an object
*/
export type FunctionKeys<T> = {
[K in keyof T]-?: IfUndefined<T[K], never,
T[K] extends Function ? K : never>;
}[keyof T];
/**
* Gets readonly keys of an object

@@ -29,7 +33,14 @@ */

/**
* Gets readonly keys of an object
* Gets readable keys of an object
*/
export type WritableKeys<T> = Exclude<keyof T, ReadonlyKeys<T>>;
export type ReadableKeys<T> = Exclude<keyof T, FunctionKeys<T>>;
/**
* Gets writable keys of an object
*/
export type WritableKeys<T> = Exclude<{
[K in keyof T]-?: IfEquals<{ [Q in K]: T[K] }, { -readonly [Q in K]: T[K] }, K>
}[keyof T], FunctionKeys<T>>;
/**
* Gets keys that matches V of T

@@ -36,0 +47,0 @@ */

/** Like Partial but recursive */
import {Builtin} from './common';
import {IsTuple} from './type-check';
import {KnownKeys, OptionalKeys, ReadonlyKeys, RequiredKeys, TypeKeys, WritableKeys} from './keys';
import {OptionalKeys, ReadableKeys, ReadonlyKeys, RequiredKeys, TypeKeys, WritableKeys} from './keys';

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

/**
* Pick all readable properties in object type
*/
export type PickReadable<T> = Pick<T, ReadableKeys<T>>;
/**
* Pick all writable properties in object type

@@ -33,8 +38,2 @@ */

/**
* Pick all known properties in object type
*/
export type PickKnown<T> = Pick<T, KnownKeys<T>>;
/**
* Pick all optional properties in T deeply

@@ -41,0 +40,0 @@ */

@@ -99,1 +99,13 @@ import {NonObj} from './common';

export type IsEquals<T1, T2> = IfEquals<T1, T2, true, false>;
/**
* Returns Y if T1 is exactly same with T2, N otherwise
*/
export type IfUndefined<T, Y = T, N = never> =
T extends undefined ? Y: N;
/**
* Returns true if T is undefined type
*/
export type IsUndefined<T> = IfUndefined<T, true, false>;

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

],
"version": "0.0.1",
"version": "0.0.2",
"types": "lib/index.d.ts",

@@ -18,0 +18,0 @@ "repository": "git@github.com:panates/ts-gems.git",

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