Move Named Exports section close to Usage

This commit is contained in:
Bjorn Stromberg 2023-08-06 11:20:15 +08:00
parent 76303b8a3a
commit d97524932c

View file

@ -54,6 +54,18 @@ assert.string(foo);
// `foo` is now typed as a `string`.
```
## Named Exports
Named exports allow tooling to perform tree-shaking, potentially reducing bundle size by including only code from the methods that are used.
Every method listed above is available as a named export. Each method is prefixed by either `is` or `assert` depending on usage.
For example:
```js
import {assertNull, isUndefined} from '@sindresorhus/is';
```
## API
### is(value)
@ -572,18 +584,6 @@ This can be useful to confirm that a value is a valid count of something, ie. 0
Returns `true` if the value is a string with only whitespace characters.
## Named Exports
Named exports allow tooling to perform tree-shaking, potentially reducing bundle size by including only code from the methods that are used.
Every method listed above is available as a named export. Each method is prefixed by either `is` or `assert` depending on usage.
For example:
```js
import {assertNull, isUndefined} from '@sindresorhus/is';
```
## Type guards
When using `is` together with TypeScript, [type guards](http://www.typescriptlang.org/docs/handbook/advanced-types.html#type-guards-and-differentiating-types) are being used extensively to infer the correct type inside if-else statements.