Skip to content

Commit

Permalink
docs(type-core): adds documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
rafamel committed Nov 28, 2020
1 parent 2253623 commit ea2fa9d
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
* [*result-box:*](https://github.com/rafamel/utils/tree/master/packages/result-box) because throw/catch is not always best.
* [*proxy-handler:*](https://github.com/rafamel/utils/tree/master/packages/proxy-handler) a proxy object handler implementation.
* [*terminate-children:*](https://github.com/rafamel/utils/tree/master/packages/terminate-children) terminate all children for a process.
* [*type-core:*](https://github.com/rafamel/utils/tree/master/packages/type-core) a types utility belt for TypeScript.
* [*type-core:*](https://github.com/rafamel/utils/tree/master/packages/type-core) a types utility belt for TypeScript.
51 changes: 51 additions & 0 deletions packages/type-core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,54 @@
## Install

[`npm install type-core`](https://www.npmjs.com/package/type-core)

## Types

[See source.](https://github.com/rafamel/utils/blob/master/packages/type-core/src/types.ts#L1)

* Primitives
* `NonDefined`
* `Empty`
* `FalseLike`
* `Primitive`
* Records
* `Members`
* `Replace`
* Functions
* `NullaryFn`
* `UnaryFn`
* `BinaryFn`
* `MultiaryFn`
* `VariadicFn`
* Utils
* `Union`
* `Intersection`

## Utilities

### TypeGuard

[See source.](https://github.com/rafamel/utils/blob/master/packages/type-core/src/TypeGuard.ts#L1)

An exported object with methods:

* `isUndefined(item: any): item is undefined`
* `isNull(item: any): item is null`
* `isEmpty(item: any): item is Empty`: includes *null* and *undefined.*
* `isFalseLike(item: any): item is FalseLike`: item is *falsy*.
* `isBoolean(item: any): item is boolean`
* `isString(item: any): item is string`
* `isNumber(item: any): item is number`
* `isBigInt(item: any): item is bigint`
* `isSymbol(item: any): item is symbol`
* `isPrimitive(item: any): item is Primitive`: includes *bigint, boolean, number, string, symbol, null,* and *undefined.*
* `isFunction(item: any): item is VariadicFn`
* `isObject(item: any): item is any`: excludes *null*, includes array.
* `isObjectLike(item: any): item is any`: excludes *null*, includes array and function.
* `isRecord(item: any): item is Members<unknown>`: excludes *null*, array, and function.
* `isRecordLike(item: any): item is Members<unknown>`, excludes `null` and array, includes function.
* `isArray(item: any): item is unknown[]`
* `isPromise(item: any): item is Promise<unknown>`: item is a *Promise*.
* `isPromiseLike(item: any): item is PromiseLike<unknown>`: item is a *thenable*.
* `isIterable(item: any): item is Iterable<unknown>`
* `isIterator(item: any): item is Iterator<unknown, unknown, unknown>`
2 changes: 1 addition & 1 deletion packages/type-core/project.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module.exports = create({
// Build project on version bump. Boolean.
build: true,
// Generate docs from TS on version bump. Boolean.
docs: true
docs: false
},
assign: {
todo: ['xxx', 'fixme', 'todo', 'refactor'],
Expand Down
2 changes: 1 addition & 1 deletion packages/type-core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ export type BinaryFn<T extends [any, any], U = void> = (...args: T) => U;
export type MultiaryFn<T extends any[], U = void> = (...args: T) => U;
export type VariadicFn<T = any> = (...args: any[]) => T;

/* Helpers */
/* Utils */
export type Union<A, B, C = B, D = B, E = B> = A | B | C | D | E;
export type Intersection<A, B, C = B, D = B, E = B> = A & B & C & D & E;

0 comments on commit ea2fa9d

Please sign in to comment.