demotivator
Version:
A extremely large array of 300+ insults so you can integrate the power of (de)Motivator into your webapp.
123 lines • 3.62 kB
JavaScript
/**
* @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 { insults, profaneInsults } from './insults';
import generateInsult, { insultAt } from './generateinsult';
export { insults, generateInsult, insultAt };
/**
* createArray is a new function itroduced in version 12 that creates a custom insult array based on a configuration you provide.
* @param {CreateArrayConfig} configuration an object that has two properties: profane, and original. Both of which accept a boolean value
* @since 12.0.0
* @see CreateArrayConfig
* @returns {Insult[]} an array of insults
*/
export const createArray = (configuration) => {
if (configuration.profane && !configuration.original) {
return profaneInsults;
}
else if (configuration.profane && configuration.original) {
return insults.concat(profaneInsults);
}
else {
return insults;
}
};
/**
* The main deMotivator object.
* Contains all the functions and properties of the deMotivator.
* @date 6/15/2023 - 11:37:58 AM
* @export
* @type {__DeMotivator}
*/
export const deMotivator = {
insults: insults,
profaneInsults: profaneInsults,
createArray: createArray,
generateInsult: generateInsult,
insultAt: insultAt,
};
export default deMotivator;
/**
* A class version of the `deMotivator` object
* @see deMotivator
* @export
* @class DeMotivator
* @typedef {DeMotivator}
* @implements {__DeMotivator}
*/
export class DeMotivator {
constructor() {
/**
* The entire insults array
* @date 6/15/2023 - 11:39:04 AM
*
* @type {Insult[]}
*/
this.insults = insults;
/**
* All of the profane insults
* @date 6/15/2023 - 11:39:04 AM
*
* @type {Insult[]}
*/
this.profaneInsults = profaneInsults;
}
/**
* Creates a basic array of insults.
* @date 6/15/2023 - 11:39:04 AM
* @internal
* @private
* @returns {Insult[]}
*/
__createBasicArray() {
return createArray({ original: true, profane: false });
}
/**
* Creates a custom insult array based on a configuration you provide.
* @date 6/15/2023 - 11:39:04 AM
* @external
* @public
* @param {CreateArrayConfig} configuration
* @returns {Insult[]}
*/
createArray(configuration) {
return createArray(configuration);
}
/**
* Grabs a random insult from the insults array.
* @date 6/15/2023 - 11:39:04 AM
*
* @public
* @param {Insult[]} [array=this.__createBasicArray()]
* @returns {Insult}
*/
generateInsult(array = this.__createBasicArray()) {
return generateInsult(array);
}
/**
* Gets an insult at a specific position in the insults array.
* @date 6/15/2023 - 11:39:04 AM
*
* @public
* @param {number} position
* @param {Insult[]} [array=this.__createBasicArray()]
* @returns {Insult}
*/
insultAt(position, array = this.__createBasicArray()) {
return insultAt(position, array);
}
}
//# sourceMappingURL=index.js.map