isbot
Advanced tools
Comparing version 4.1.1 to 4.1.2
@@ -12,7 +12,7 @@ /** | ||
*/ | ||
export declare const isbot: (userAgent: string) => boolean; | ||
export declare const isbot: (userAgent: string | null) => boolean; | ||
/** | ||
* Create a custom isbot function with a custom pattern. | ||
*/ | ||
export declare const createIsbot: (customPattern: RegExp) => (userAgent: string) => boolean; | ||
export declare const createIsbot: (customPattern: RegExp) => (userAgent: string | null) => boolean; | ||
/** | ||
@@ -25,14 +25,14 @@ * Create a custom isbot function with a custom pattern. | ||
*/ | ||
export declare const isbotMatch: (userAgent: string) => string | null; | ||
export declare const isbotMatch: (userAgent: string | null) => string | null; | ||
/** | ||
* Find all parts of the user agent that match a bot pattern. | ||
*/ | ||
export declare const isbotMatches: (userAgent: string) => string[]; | ||
export declare const isbotMatches: (userAgent: string | null) => string[]; | ||
/** | ||
* Find the first bot patterns that match the given user agent. | ||
*/ | ||
export declare const isbotPattern: (userAgent: string) => string | null; | ||
export declare const isbotPattern: (userAgent: string | null) => string | null; | ||
/** | ||
* Find all bot patterns that match the given user agent. | ||
*/ | ||
export declare const isbotPatterns: (userAgent: string) => string[]; | ||
export declare const isbotPatterns: (userAgent: string | null) => string[]; |
@@ -225,5 +225,5 @@ var __defProp = Object.defineProperty; | ||
}; | ||
var isbotMatch = (userAgent) => userAgent.match(pattern)?.[0]; | ||
var isbotMatches = (userAgent) => list.map((part) => userAgent.match(new RegExp(part, "i"))?.[0]).filter(Boolean); | ||
var isbotPattern = (userAgent) => list.find((pattern2) => new RegExp(pattern2, "i").test(userAgent)) ?? null; | ||
var isbotPatterns = (userAgent) => list.filter((pattern2) => new RegExp(pattern2, "i").test(userAgent)); | ||
var isbotMatch = (userAgent) => userAgent?.match(pattern)?.[0] ?? null; | ||
var isbotMatches = (userAgent) => list.map((part) => userAgent?.match(new RegExp(part, "i"))?.[0]).filter(Boolean); | ||
var isbotPattern = (userAgent) => userAgent ? list.find((pattern2) => new RegExp(pattern2, "i").test(userAgent)) ?? null : null; | ||
var isbotPatterns = (userAgent) => userAgent ? list.filter((pattern2) => new RegExp(pattern2, "i").test(userAgent)) : []; |
{ | ||
"name": "isbot", | ||
"version": "4.1.1", | ||
"version": "4.1.2", | ||
"description": "🤖 Recognise bots/crawlers/spiders using the user agent string.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
# isbot 🤖/👨🦰 | ||
[![](https://img.shields.io/npm/v/isbot/next?style=flat-square)](https://www.npmjs.com/package/isbot/v/next) [![](https://img.shields.io/npm/dt/isbot?style=flat-square)](https://www.npmjs.com/package/isbot) [![](https://img.shields.io/circleci/build/github/omrilotan/isbot?style=flat-square)](https://circleci.com/gh/omrilotan/isbot) [![](https://img.shields.io/github/last-commit/omrilotan/isbot?style=flat-square)](https://github.com/omrilotan/isbot/graphs/commit-activity) [![](https://data.jsdelivr.com/v1/package/npm/isbot/badge)](https://www.jsdelivr.com/package/npm/isbot) | ||
[![](https://img.shields.io/npm/v/isbot?style=flat-square)](https://www.npmjs.com/package/isbot) [![](https://img.shields.io/npm/dt/isbot?style=flat-square)](https://www.npmjs.com/package/isbot) [![](https://img.shields.io/circleci/build/github/omrilotan/isbot?style=flat-square)](https://circleci.com/gh/omrilotan/isbot) [![](https://img.shields.io/github/last-commit/omrilotan/isbot?style=flat-square)](https://github.com/omrilotan/isbot/graphs/commit-activity) [![](https://data.jsdelivr.com/v1/package/npm/isbot/badge)](https://www.jsdelivr.com/package/npm/isbot) | ||
@@ -9,8 +9,2 @@ [![](./page/isbot.svg)](https://isbot.js.org) | ||
> ## Migrate to version 4 today | ||
> | ||
> ### Version 4 will become the "latest" version on npm on January 2024 | ||
> | ||
> `npm i isbot@4` or `npm i isbot@next` | ||
## Usage | ||
@@ -51,12 +45,12 @@ | ||
| import | Type | Description | | ||
| ------------------- | --------------------------------------------------- | ---------------------------------------------------------------------------- | | ||
| pattern | _{RegExp}_ | The regular expression used to identify bots | | ||
| list | _{string[]}_ | List of all individual pattern parts | | ||
| isbotMatch | _{(userAgent: string): string \| null}_ | The substring matched by the regular expression | | ||
| isbotMatches | _{(userAgent: string): string[]}_ | All substrings matched by the regular expression | | ||
| isbotPattern | _{(userAgent: string): string \| null}_ | The regular expression used to identify bot substring in the user agent | | ||
| isbotPatterns | _{(userAgent: string): string[]}_ | All regular expressions used to identify bot substrings in the user agent | | ||
| createIsbot | _{(pattern: RegExp): (userAgent: string): boolean}_ | Create a custom isbot function | | ||
| createIsbotFromList | _{(list: string): (userAgent: string): boolean}_ | Create a custom isbot function from a list of string representation patterns | | ||
| import | Type | Description | | ||
| ------------------- | ------------------------------------------------- | ---------------------------------------------------------------------------- | | ||
| pattern | _RegExp_ | The regular expression used to identify bots | | ||
| list | _string[]_ | List of all individual pattern parts | | ||
| isbotMatch | _(userAgent: string): string \| null_ | The substring matched by the regular expression | | ||
| isbotMatches | _(userAgent: string): string[]_ | All substrings matched by the regular expression | | ||
| isbotPattern | _(userAgent: string): string \| null_ | The regular expression used to identify bot substring in the user agent | | ||
| isbotPatterns | _(userAgent: string): string[]_ | All regular expressions used to identify bot substrings in the user agent | | ||
| createIsbot | _(pattern: RegExp): (userAgent: string): boolean_ | Create a custom isbot function | | ||
| createIsbotFromList | _(list: string): (userAgent: string): boolean_ | Create a custom isbot function from a list of string representation patterns | | ||
@@ -63,0 +57,0 @@ ## Example usages of helper functions |
Sorry, the diff of this file is not supported yet
27358
157