Security News
The Push to Ban Ransom Payments Is Gaining Momentum
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
@basd/formatter
Advanced tools
Readme
A comprehensive text formatting and manipulation library written in JS. It aims to offer a simple and efficient way to format, normalize, tokenize, and filter text in various scenarios.
Install the package with:
npm install @basd/formatter
First, import the Formatter
library.
import Formatter from '@basd/formatter'
or
const Formatter = require('@basd/formatter')
Or import TextFormatter
and StopWordFilter
classes like this:
const { TextFormatter, StopWordFilter } = require('@basd/formatter')
const formatter = new TextFormatter()
console.log(formatter.normalizeSearchQuery('hello & world | earth'))
// Output: 'HELLO AND WORLD OR EARTH'
console.log(formatter.toUpperCase('hello world'))
// Output: 'HELLO WORLD'
console.log(formatter.toLowerCase('HELLO WORLD'))
// Output: 'hello world'
console.log(formatter.stripPunctuation('hello, world!'))
// Output: 'hello world'
const tokens = formatter.tokenize('This is an example.')
console.log(tokens)
// Output: ['this', 'is', 'an', 'example']
const stopWordFilter = new StopWordFilter(['a', 'an', 'the'])
console.log(stopWordFilter.filter(['this', 'is', 'a', 'test']))
// Output: ['this', 'is', 'test']
normalizeSearchQuery(text: string): string
stripPunctuation(text: string): string
toUpperCase(text: string): string
toLowerCase(text: string): string
splitWords(text: string): Array<string>
filterStopWords(words: Array<string>): Array<string>
normalize(text: string, upper: boolean = false): string
tokenize(text: string, filterStopWords: boolean = true): Array<string>
setStopWords(stopWords: Array<string>)
: Set a new list of stop words.filter(words: Array<string>): Array<string>
setStopWords(stopWords: Array<string>)
: Set a new list of stop words.get defaultStopWords(): Array<string>
: Get the default list of stop words.get extendedStopWords(): Array<string>
: Get an extended list of stop words. (extendedStopWords
must be imported or defined.)In order to run the test suite, simply clone the repository and install its dependencies:
git clone https://gitlab.com/frenware/utils/formatter.git
cd formatter
npm install
To run the tests:
npm test
Thank you! Please see our contributing guidelines for details.
If you find this project useful and want to help support further development, please send us some coin. We greatly appreciate any and all contributions. Thank you!
Bitcoin (BTC):
1JUb1yNFH6wjGekRUW6Dfgyg4J4h6wKKdF
Monero (XMR):
46uV2fMZT3EWkBrGUgszJCcbqFqEvqrB4bZBJwsbx7yA8e2WBakXzJSUK8aqT4GoqERzbg4oKT2SiPeCgjzVH6VpSQ5y7KQ
@basd/formatter is MIT licensed.
FAQs
A comprehensive text formatting and manipulation library written in JS.
We found that @basd/formatter demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
Application Security
New SEC disclosure rules aim to enforce timely cyber incident reporting, but fear of job loss and inadequate resources lead to significant underreporting.
Security News
The Python Software Foundation has secured a 5-year sponsorship from Fastly that supports PSF's activities and events, most notably the security and reliability of the Python Package Index (PyPI).