Redact

Redact

  • Docs
  • Help
  • Blog

›Guides

Getting Started

  • Installing Redact
  • Updating Redact

Guides

  • Blacklist
  • Whitelist
  • Redact
  • Blacklist Check
  • Blacklist Count

Utils

  • Available lists

Counting blacklisted words in a sentence

You can check the number of blacklisted words found in a given sentence/string.

Syntax

blacklistCount(string: string, ...args: string[]): number

Parameters

string: string - Given string/sentence to be checked.

blacklist: string[] - Blacklist

Returns

number - The resulting count of blacklisted words that exists in a string.

Error

Throws an error if the required parameters are not given to the function.

Import

import { blacklistCount } from '@princedev/redact';

Examples

Basic usage with a blacklisted word.

const racialBlacklist = blacklist('nigga', 'eskimo');
const count = blacklistCount('Wassup my nigga', racialBlacklist);

count would be 1.

Basic usage with no blacklisted word.

const racialBlacklist = blacklist('nigga', 'eskimo');
const count = blacklistCount('Wassup my friend', racialBlacklist);

count would be 0.

Another example with many blacklisted words

const racialBlacklist = blacklist('nigga', 'eskimo');
const count = blacklistCount('Wassup my nigga NiGGA NIGGA', racialBlacklist);

count would be 3.

Last updated on 7/22/2020 by Prince Neil Cedrick Castro
← Blacklist CheckAvailable lists →
  • Syntax
    • Parameters
    • Returns
    • Error
  • Import
  • Examples
Redact
Docs
Getting StartedGuides
Package
NPMGitHubStar
More
HelpBlog
aws.cedi@gmail.com
Copyright © 2020 Redact