Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Nov 4, 2021
1 parent 39f5a45 commit c1eac08
Showing 1 changed file with 76 additions and 11 deletions.
87 changes: 76 additions & 11 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,57 @@
[![Downloads][downloads-badge]][downloads]
[![Size][size-badge]][size]

Check if a character is a word character (`\w`, which equals `[a-zA-Z0-9_]`).
Check if a character is a word character.

## Install
## Contents

* [What is this?](#what-is-this)
* [When should I use this?](#when-should-i-use-this)
* [Install](#install)
* [Use](#use)
* [API](#api)
* [`isWordCharacter(character|code)`](#iswordcharactercharactercode)
* [Types](#types)
* [Compatibility](#compatibility)
* [Security](#security)
* [Related](#related)
* [Contribute](#contribute)
* [License](#license)

## What is this?

This is a function that checks if a given character is a word character:
whether it matches `\w` (which is short for `[a-zA-Z0-9_]`).

This package is ESM only: Node 12+ is needed to use it and it must be `import`ed
instead of `require`d.
## When should I use this?

Not often, as it’s relatively simple to do yourself.
This package exists because it’s needed in several related packages, at which
point it becomes useful to defer to one shared function.

## Install

[npm][]:
This package is [ESM only][esm].
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:

```sh
npm install is-word-character
```

In Deno with [Skypack][]:

```js
import {isWordCharacter} from 'https://cdn.skypack.dev/is-word-character@2?dts'
```

In browsers with [Skypack][]:

```html
<script type="module">
import {isWordCharacter} from 'https://cdn.skypack.dev/is-word-character@2?min'
</script>
```

## Use

```js
Expand All @@ -33,21 +71,40 @@ isWordCharacter('💩') // => false

## API

This package exports the following identifiers: `isWordCharacter`.
This package exports the following identifier: `isWordCharacter`.
There is no default export.

### `isWordCharacter(character|code)`

Check whether the given character code (`number`), or the character code at the
first position (`string`), is a word character.

## Types

This package is fully typed with [TypeScript][].

## Compatibility

This package is at least compatible with all maintained versions of Node.js.
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
It also works in Deno and modern browsers.

## Security

This package is safe.

## Related

* [`is-alphabetical`](/~https://github.com/wooorm/is-alphabetical)
* [`is-alphanumerical`](/~https://github.com/wooorm/is-alphanumerical)
* [`is-decimal`](/~https://github.com/wooorm/is-decimal)
* [`is-hexadecimal`](/~https://github.com/wooorm/is-hexadecimal)
* [`is-whitespace-character`](/~https://github.com/wooorm/is-whitespace-character)
* [`wooorm/is-alphabetical`](/~https://github.com/wooorm/is-alphabetical)
* [`wooorm/is-alphanumerical`](/~https://github.com/wooorm/is-alphanumerical)
* [`wooorm/is-decimal`](/~https://github.com/wooorm/is-decimal)
* [`wooorm/is-hexadecimal`](/~https://github.com/wooorm/is-hexadecimal)
* [`wooorm/is-whitespace-character`](/~https://github.com/wooorm/is-whitespace-character)

## Contribute

Yes please!
See [How to Contribute to Open Source][contribute].

## License

Expand All @@ -73,6 +130,14 @@ first position (`string`), is a word character.

[npm]: https://docs.npmjs.com/cli/install

[skypack]: https://www.skypack.dev

[license]: license

[author]: https://wooorm.com

[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c

[typescript]: https://www.typescriptlang.org

[contribute]: https://opensource.guide/how-to-contribute/

0 comments on commit c1eac08

Please sign in to comment.