How to use the @hint/utils-string.normalizeStringByDelimiter function in @hint/utils-string

To help you get started, we’ve selected a few @hint/utils-string examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github webhintio / hint / packages / create-parser / src / new-parser.ts View on Github external
public constructor(parserData: QuestionsType) {
        this.name = parserData.name;
        this.normalizedName = normalizeStringByDelimiter(parserData.name, '-');
        this.capitalizedName = capitalize(parserData.name);
        this.description = escapeSafeString(parserData.description);

        // Using `Set` to avoid duplicates.
        const eventTypesSet: Set = new Set();

        parserData.eventsSelected.forEach((event: EventType) => {
            const isElement = event.event === 'element::';
            const type: string = events[event.event];
            const eventSplit = event.event.split('::');
            const handler: string = `on${capitalize(eventSplit[0])}${capitalize(isElement ? event.element : eventSplit[1])}${eventSplit[2] ? capitalize(eventSplit[2]) : ''}`;
            const varName: string = `${type.charAt(0).toLowerCase()}${type.substr(1)}`;

            this.events.push({
                event: isElement ? event.event + event.element : event.event,
                handler,
github webhintio / hint / packages / create-parser / src / new-parser.ts View on Github external
const capitalize = (str: string): string => {
    if (str === '*') {
        return '';
    }

    const splittedText: string[] = normalizeStringByDelimiter(str, ' ').split(' ');

    const result = splittedText.reduce((total, text) => {
        /* istanbul ignore else */
        if (!text) {
            return total;
        }

        return `${total}${text.charAt(0).toUpperCase()}${text.slice(1)}`;
    }, '');

    return result;
};
github webhintio / hint / packages / create-hint / src / create-hint.ts View on Github external
public constructor(data: inquirer.Answers) {
        this.name = data.name;
        this.isMulti = data.multi;
        this.normalizedName = normalizeStringByDelimiter(data.name, '-');
        this.description = escapeSafeString(data.description);
        this.official = data.official;

        const prefix = this.official ? '@hint/hint' : 'hint'; // package.json#name

        this.packageName = `${prefix}-${this.normalizedName}`;
        this.hints = [];

        if (this.isMulti) {
            this.packageMain = `dist/src/index.js`; // package.json#main

            (data.hints as inquirer.Answers[]).forEach((hint) => {
                this.hints.push(new NewHint(hint, this.normalizedName));
            });
        } else {
            this.packageMain = `dist/src/hint.js`; // package.json#main
github webhintio / hint / packages / create-hint / src / create-hint.ts View on Github external
public constructor(hintData: inquirer.Answers, parentName?: string) {
        this.name = hintData.name;
        this.normalizedName = normalizeStringByDelimiter(hintData.name, '-');
        this.className = `${parentName ? toPascalCase(parentName) : ''}${toPascalCase(this.normalizedName)}Hint`;
        this.category = hintData.category || Category.other;
        this.description = escapeSafeString(hintData.description);
        this.elementType = hintData.elementType;
        this.events = getEventsByUseCase(hintData.useCase);
        this.useCase[hintData.useCase] = true;
        this.scope = hintData.scope;
        this.parentName = parentName || '';
    }
}