diff --git a/index.js b/index.js index 434f08a..61152b4 100644 --- a/index.js +++ b/index.js @@ -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 diff --git a/readme.md b/readme.md index c2fdc8f..4ace1d3 100644 --- a/readme.md +++ b/readme.md @@ -7,35 +7,52 @@ 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 + +``` + ## Use ```js @@ -43,18 +60,57 @@ 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] @@ -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