Socket
Socket
Sign inDemoInstall

ts-essentials

Package Overview
Dependencies
0
Maintainers
1
Versions
57
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.8 to 2.0.9

23

dist/types.d.ts

@@ -36,3 +36,6 @@ /** Essentials */

}
/** Omit given key in object type */
/**
* Omit given key in object type
* @deprecated Starting with TypeScript 3.5, Omit is natively available.
*/
export declare type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;

@@ -63,2 +66,20 @@ /** Omit all properties of given type in object type */

export declare type AsyncOrSync<T> = PromiseLike<T> | T;
/** Dark magic helper, needed for WritableKeys & ReadonlyKeys */
declare type IfEquals<X, Y, A = X, B = never> = (<T>() => T extends X ? 1 : 2) extends (<T>() => T extends Y ? 1 : 2) ? A : B;
/** Gets keys of an object which are readonly */
export declare type ReadonlyKeys<T extends object> = {
[P in keyof T]-?: IfEquals<{
[Q in P]: T[P];
}, {
-readonly [Q in P]: T[P];
}, never, P>;
}[keyof T];
/** Gets keys of an object which are writable */
export declare type WritableKeys<T extends {}> = {
[P in keyof T]-?: IfEquals<{
[Q in P]: T[P];
}, {
-readonly [Q in P]: T[P];
}, P>;
}[keyof T];
export {};

2

package.json

@@ -9,3 +9,3 @@ {

],
"version": "2.0.8",
"version": "2.0.9",
"main": "dist/index.js",

@@ -12,0 +12,0 @@ "types": "dist/index.d.ts",

@@ -40,2 +40,4 @@ <p align="center">

- [MarkRequired](#markrequired)
- [ReadonlyKeys](#readonlykeys)
- [WritableKeys](#writablekeys)
- [UnionToIntersection](#uniontointersection)

@@ -147,2 +149,4 @@ - [Opaque types](#opaque-types)

NOTE: Builtin `Omit` became part of TypeScript 3.5
```typescript

@@ -246,2 +250,30 @@ type ComplexObject = {

### ReadonlyKeys
Gets keys of an object which are readonly.
```typescript
type T = {
readonly a: number;
b: string;
};
type Result = ReadonlyKeys<T>
// Result:
// "a"
```
### WritableKeys
Gets keys of an object which are writable
```typescript
type T = {
readonly a: number;
b: string;
};
type Result = WritableKeys<T>
// Result:
// "b"
```
### UnionToIntersection

@@ -248,0 +280,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