Skip to content

Commit

Permalink
Add improved docs
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Nov 14, 2022
1 parent 68ebd0d commit 8e75496
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 22 deletions.
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ const expressions = [
* Check if `url` is a badge.
*
* @param {string} url
* URL to something.
* @returns {boolean}
* Whether `url` is a badge.
*/
export function isBadge(url) {
let index = -1
Expand Down
108 changes: 86 additions & 22 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,54 +7,110 @@

Check if `url` is a badge.

Supports:
## Contents

* [x] [`codeclimate`][codeclimate]
* [x] [`codecov`][codecov-ci]
* [x] [`coveralls`][coveralls]
* [x] [`david-dm`][david]
* [x] [`fury.io`][fury]
* [x] [`github.com` workflows][github]
* [x] [`gitter`][gitter]
* [x] [`inch-ci`][inch]
* [x] [`issuestats`][issuestats]
* [x] [`nodei.co`][nodei]
* [x] [`saucelabs`][sauce]
* [x] [`shields.io`][shields]
* [x] [`testling`][testling]
* [x] [`travis-ci`][travis-ci]
* [x] `opencollective`
* [What is this?](#what-is-this)
* [When should I use this?](#when-should-i-use-this)
* [Install](#install)
* [Use](#use)
* [API](#api)
* [`isBadge(url)`](#isbadgeurl)
* [Data](#data)
* [Types](#types)
* [Compatibility](#compatibility)
* [Contribute](#contribute)
* [Security](#security)
* [License](#license)

## Install
## What is this?

This is a tiny package that checks if a given url points to a badge.

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?

[npm][]:
You can use this package for example to filter out badges.

## Install

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

```sh
npm install is-badge
```

In Deno with [`esm.sh`][esmsh]:

```js
import {isBadge} from 'https://esm.sh/is-badge@2'
```

In browsers with [`esm.sh`][esmsh]:

```html
<script type="module">
import {isBadge} from 'https://esm.sh/is-badge@2?bundle'
</script>
```

## Use

```js
import {isBadge} from 'is-badge'

isBadge('https://img.shields.io/travis/joyent/node.svg') // => true
isBadge('https://example.com') // => false
isBadge(true) // [Error: is-badge expected string]
```

## API

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

### `isBadge(url)`

Check if `url` is a badge.

## Data

This project supports:

* [x] [`codeclimate`][codeclimate]
* [x] [`codecov`][codecov-ci]
* [x] [`coveralls`][coveralls]
* [x] [`david-dm`][david]
* [x] [`fury.io`][fury]
* [x] [`github.com` workflows][github]
* [x] [`gitter`][gitter]
* [x] [`inch-ci`][inch]
* [x] [`issuestats`][issuestats]
* [x] [`nodei.co`][nodei]
* [x] [`saucelabs`][sauce]
* [x] [`shields.io`][shields]
* [x] [`testling`][testling]
* [x] [`travis-ci`][travis-ci]
* [x] `opencollective`

## Types

This package is fully typed with [TypeScript][].
It exports no additional types.

## Compatibility

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

## Contribute

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

## Security

This package is safe.

## License

[MIT][license] © [Titus Wormer][author]
Expand All @@ -79,6 +135,14 @@ Check if `url` is a badge.

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

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

[esmsh]: https://esm.sh

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

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

[license]: license

[author]: https://wooorm.com
Expand Down

0 comments on commit 8e75496

Please sign in to comment.