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

type-plus

Package Overview
Dependencies
Maintainers
1
Versions
169
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

type-plus - npm Package Compare versions

Comparing version 1.25.0 to 1.26.0

lib/ANotB.d.ts

2

lib/assertType.d.ts

@@ -15,2 +15,4 @@ /**

var noBoolean: <T>(value: Exclude<T, boolean>) => void;
var isTrue: (value: true) => void;
var isFalse: (value: false) => void;
var isString: (value: string) => void;

@@ -17,0 +19,0 @@ var noString: <T>(value: Exclude<T, string>) => void;

25

lib/assertType.js

@@ -9,13 +9,16 @@ "use strict";

exports.assertType = assertType;
assertType.isUndefined = function (value) { return; };
assertType.noUndefined = function (value) { return; };
assertType.isNull = function (value) { return; };
assertType.noNull = function (value) { return; };
assertType.isNumber = function (value) { return; };
assertType.noNumber = function (value) { return; };
assertType.isBoolean = function (value) { return; };
assertType.noBoolean = function (value) { return; };
assertType.isString = function (value) { return; };
assertType.noString = function (value) { return; };
assertType.isNever = function (value) { return; };
assertType.isUndefined = noop;
assertType.noUndefined = noop;
assertType.isNull = noop;
assertType.noNull = noop;
assertType.isNumber = noop;
assertType.noNumber = noop;
assertType.isBoolean = noop;
assertType.noBoolean = noop;
assertType.isTrue = noop;
assertType.isFalse = noop;
assertType.isString = noop;
assertType.noString = noop;
assertType.isNever = noop;
function noop(value) { return; }
/**

@@ -22,0 +25,0 @@ * create a type assertion function for the specified type.

export { required, requiredDeep } from 'unpartial';
export * from './ANotB';
export * from './assertType';
export * from './Brand';

@@ -11,5 +13,9 @@ export * from './Except';

export * from './getField';
export * from './hasKey';
export * from './Id';
export * from './IsDisjoint';
export * from './isPromise';
export * from './IsSame';
export * from './JSONTypes';
export * from './KeysWithDiffType';
export * from './KeyTypes';

@@ -19,2 +25,3 @@ export * from './literalArray';

export * from './mapSeries';
export * from './Not';
export * from './Omit';

@@ -31,4 +38,4 @@ export * from './Partial';

export * from './tryAssign';
export * from './assertType';
export * from './typeOverrideIncompatible';
export * from './UnionKeys';
export * from './ValueOf';

@@ -9,2 +9,3 @@ "use strict";

exports.requiredDeep = unpartial_1.requiredDeep;
__export(require("./assertType"));
__export(require("./Brand"));

@@ -16,2 +17,3 @@ __export(require("./facade"));

__export(require("./getField"));
__export(require("./hasKey"));
__export(require("./Id"));

@@ -25,3 +27,3 @@ __export(require("./isPromise"));

__export(require("./tryAssign"));
__export(require("./assertType"));
__export(require("./typeOverrideIncompatible"));
//# sourceMappingURL=index.js.map

@@ -15,2 +15,4 @@ /**

var noBoolean: <T>(value: Exclude<T, boolean>) => void;
var isTrue: (value: true) => void;
var isFalse: (value: false) => void;
var isString: (value: string) => void;

@@ -17,0 +19,0 @@ var noString: <T>(value: Exclude<T, string>) => void;

@@ -6,13 +6,16 @@ /**

export function assertType(subject) { return; }
assertType.isUndefined = (value) => { return; };
assertType.noUndefined = (value) => { return; };
assertType.isNull = (value) => { return; };
assertType.noNull = (value) => { return; };
assertType.isNumber = (value) => { return; };
assertType.noNumber = (value) => { return; };
assertType.isBoolean = (value) => { return; };
assertType.noBoolean = (value) => { return; };
assertType.isString = (value) => { return; };
assertType.noString = (value) => { return; };
assertType.isNever = (value) => { return; };
assertType.isUndefined = noop;
assertType.noUndefined = noop;
assertType.isNull = noop;
assertType.noNull = noop;
assertType.isNumber = noop;
assertType.noNumber = noop;
assertType.isBoolean = noop;
assertType.noBoolean = noop;
assertType.isTrue = noop;
assertType.isFalse = noop;
assertType.isString = noop;
assertType.noString = noop;
assertType.isNever = noop;
function noop(value) { return; }
/**

@@ -19,0 +22,0 @@ * create a type assertion function for the specified type.

export { required, requiredDeep } from 'unpartial';
export * from './ANotB';
export * from './assertType';
export * from './Brand';

@@ -11,5 +13,9 @@ export * from './Except';

export * from './getField';
export * from './hasKey';
export * from './Id';
export * from './IsDisjoint';
export * from './isPromise';
export * from './IsSame';
export * from './JSONTypes';
export * from './KeysWithDiffType';
export * from './KeyTypes';

@@ -19,2 +25,3 @@ export * from './literalArray';

export * from './mapSeries';
export * from './Not';
export * from './Omit';

@@ -31,4 +38,4 @@ export * from './Partial';

export * from './tryAssign';
export * from './assertType';
export * from './typeOverrideIncompatible';
export * from './UnionKeys';
export * from './ValueOf';
export { required, requiredDeep } from 'unpartial';
export * from './assertType';
export * from './Brand';

@@ -8,2 +9,3 @@ export * from './facade';

export * from './getField';
export * from './hasKey';
export * from './Id';

@@ -17,3 +19,3 @@ export * from './isPromise';

export * from './tryAssign';
export * from './assertType';
export * from './typeOverrideIncompatible';
//# sourceMappingURL=index.js.map
{
"name": "type-plus",
"version": "1.25.0",
"version": "1.26.0",
"description": "Provides additional types for `typescript`.",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/unional/type-plus",

@@ -39,2 +39,5 @@ # type-plus

- `forEachKey()`: type adjusted for each by key.
- `HasKey<T, K>`: predicate type checking `T` has key `K`.
- `hasKey()`: function of `HasKey`.
- `KeysWithDiffTypes<A, B>`: gets the keys common in `A` and `B` but with differnt value type.
- `mapKey()`: type adjusted map by key.

@@ -61,2 +64,4 @@ - `reduceKey()`: type adjusted reduce by key.

- `ANotB<A, B>`: get object with properties in `A` and not in `B`, including properties with differnt value type.
- `BNotA<A, B>`: flip of `ANotB`
- `Except<T, K>`: Deprecated. Same as `Omit<T, K>`.

@@ -76,2 +81,12 @@ - `ExcludePropType<T, U>`: excludes type `U` from properties in `T`.

### Type Predicates
Type predicates are type alias that returns `true` or `false`.
They can be used to compose complex types.
- `HasKey<T, K>`: predicate type checking `T` has key `K`.
- `IsDisjoint<A, B>`: is `A` and `B` is a disjoint set.
- `IsSame<A, B>`: is `A` and `B` has the same properties and types.
- `Not<T>`: not operator for type.
### Type assertion

@@ -97,2 +112,3 @@

- `getField(subject, key, defaultValue)`: get a field from a subject. Works against nullable and optional subject.
- `hasKey()`: function of `HasKey`.
- `pick(obj, ...props)`: pick properties from `obj`.

@@ -102,4 +118,22 @@ - `required(...)`: merge options and removing `Partial<T>`. From [`unpartial`](https://github.com/unional/unpartial)

- `tryAssign<S, T>(from: S, to: T)`: try assign `from` to `to`. Return type `never` if not possible.
- `typeOverrideIncompatible<T>()`: override only the incompatiable portion between two types.
```ts
type A = {
foo: boolean,
bar: string,
baz: string
}
const overrider = typeOverrideIncompatible<A>()
const source = {
foo: 1,
bar: 'bar',
baz: 'baz'
}
// only the `foo` property is available to override.
overrider(source, { foo: !!source.foo })
```
## Attribution

@@ -106,0 +140,0 @@

@@ -7,14 +7,18 @@ /**

assertType.isUndefined = (value: undefined) => { return }
assertType.noUndefined = <T>(value: Exclude<T, undefined>) => { return }
assertType.isNull = (value: null) => { return }
assertType.noNull = <T>(value: Exclude<T, null>) => { return }
assertType.isNumber = (value: number) => { return }
assertType.noNumber = <T>(value: Exclude<T, number>) => { return }
assertType.isBoolean = (value: boolean) => { return }
assertType.noBoolean = <T>(value: Exclude<T, boolean>) => { return }
assertType.isString = (value: string) => { return }
assertType.noString = <T>(value: Exclude<T, string>) => { return }
assertType.isNever = (value: never) => { return }
assertType.isUndefined = noop as (value: undefined) => void
assertType.noUndefined = noop as <T>(value: Exclude<T, undefined>) => void
assertType.isNull = noop as (value: null) => void
assertType.noNull = noop as <T>(value: Exclude<T, null>) => void
assertType.isNumber = noop as (value: number) => void
assertType.noNumber = noop as <T>(value: Exclude<T, number>) => void
assertType.isBoolean = noop as (value: boolean) => void
assertType.noBoolean = noop as <T>(value: Exclude<T, boolean>) => void
assertType.isTrue = noop as (value: true) => void
assertType.isFalse = noop as (value: false) => void
assertType.isString = noop as (value: string) => void
assertType.noString = noop as <T>(value: Exclude<T, string>) => void
assertType.isNever = noop as (value: never) => void
function noop(value: any) { return }
/**

@@ -21,0 +25,0 @@ * create a type assertion function for the specified type.

export { required, requiredDeep } from 'unpartial';
export * from './ANotB';
export * from './assertType';
export * from './Brand';

@@ -11,5 +13,9 @@ export * from './Except';

export * from './getField';
export * from './hasKey';
export * from './Id';
export * from './IsDisjoint';
export * from './isPromise';
export * from './IsSame';
export * from './JSONTypes';
export * from './KeysWithDiffType';
export * from './KeyTypes';

@@ -19,2 +25,3 @@ export * from './literalArray';

export * from './mapSeries';
export * from './Not';
export * from './Omit';

@@ -31,5 +38,5 @@ export * from './Partial';

export * from './tryAssign';
export * from './assertType';
export * from './typeOverrideIncompatible';
export * from './UnionKeys';
export * from './ValueOf';

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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