demotivator
Version:
A TypeScript library containing 500+ hand-curated insults organized into themed packs, along with utilities to generate, search, and transform them.
62 lines • 2.88 kB
TypeScript
/**
* @license
* Copyright 2024, PorkyProductions, and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Insult, InsultSearchResult } from './typings';
/**
* @returns a pseudorandom insult from the insult array.
*/
declare const _default: (array?: Insult[]) => Insult;
export default _default;
/**
* Get a specific insult from a point and array that you specify
*
* @param {Insult[]} [array=insults] The array to select from. Default is original only
* @param {number} position The position in the array to select. Starts indexing at 1, not 0.
* @returns {Insult}
*/
export declare const insultAt: (position: number, array?: Insult[]) => Insult;
/**
* Searches the provided insult array for the single most relevant match to `term`.
*
* Relevance is determined by the following priority (highest first):
*
* 1. **Exact match** — the insult equals the term (case-insensitive).
* 2. **Prefix match** — the insult starts with the term.
* 3. **Whole-word match** — the term appears as a complete word inside the insult.
* 4. **Substring match** — the term appears anywhere inside the insult.
*
* When multiple insults share the same highest score the first one encountered is returned.
*
* @param {string} term The search string to match against each insult.
* @param {Insult[]} [array] The pool of insults to search. Defaults to the original pack.
* @param {false} [withPosition] Return just the insult string (default).
* @returns {Insult} The most relevant insult found.
* @throws {Error} If the array is empty.
* @throws {Error} If no insult matches the term.
* @since 14.0.0
*/
export declare function searchInsults(term: string, array?: Insult[], withPosition?: false): Insult;
/**
* @param {string} term The search string to match against each insult.
* @param {Insult[] | undefined} array The pool of insults to search. Pass `undefined` to use the default original pack.
* @param {true} withPosition Return an `InsultSearchResult` containing the insult and its 1-based position, compatible with `insultAt`.
* @returns {InsultSearchResult}
* @throws {Error} If the array is empty.
* @throws {Error} If no insult matches the term.
* @since 14.0.0
*/
export declare function searchInsults(term: string, array: Insult[] | undefined, withPosition: true): InsultSearchResult;
//# sourceMappingURL=generateinsult.d.ts.map