GithubHelp home page GithubHelp logo

dusty / clean-text-utils Goto Github PK

View Code? Open in Web Editor NEW

This project forked from daviseford/clean-text-utils

1.0 2.0 0.0 87 KB

A Swiss Army Knife of text operations. Great for removing smart quotes, non-ASCII characters, and more.

Home Page: https://daviseford.com/blog/

JavaScript 1.23% TypeScript 98.77%

clean-text-utils's Introduction

clean-text-utils

By Davis E. Ford - daviseford.com

A Swiss Army Knife of text operations. Great for removing smart quotes, non-ASCII characters, emojis, and more.

Usage

npm i clean-text-utils --save

import * as cleanTextUtils from 'clean-text-utils';

let txt = 'Iлtèrn, get rid of these so-called “💩emoji💩”';
// Let's clean this up
txt = cleanTextUtils.strip.emoji(txt);
txt = cleanTextUtils.replace.diacritics(txt);
txt = cleanTextUtils.replace.smartChars(txt);
console.log(txt)
>>> 'Intern, get rid of these so-called "emoji"'

Methods

.get

cleanTextUtils.get.capitalized - Capitalizes the first character of a given string.

cleanTextUtils.get.checksum - Given any data, returns a unique checksum. Pass in md5 or sha1 for different algorithms. sha256 is enabled by default.

cleanTextUtils.get.filename - Given a url or filepath, returns the filename.

cleanTextUtils.get.reversed - Reverses a string. Unicode aware.

.is

cleanTextUtils.is.hexCode - Returns true if the given string is a hex code, such as #FFF or #FA5732.

.strip

cleanTextUtils.strip.bom - Remove UTF8 Byte Order Marks from a string.

cleanTextUtils.strip.emoji - Remove emojii from a string.

cleanTextUtils.strip.extraSpace - Remove any extra padding from a string.

cleanTextUtils.strip.gutenberg - Remove Project Gutenberg header/footer watermarks for further processing.

cleanTextUtils.strip.newlines - Removes newline characters from a string.

cleanTextUtils.strip.nonASCII - Remove non-ASCII characters from a string.

cleanTextUtils.strip.punctuation - Removes common punctuation characters from a string.

cleanTextUtils.strip.whitespace - Removes ALL whitespace characters from a string.

.replace

cleanTextUtils.replace.diacritics - Replace diacritics with their sensible alternatives

cleanTextUtils.replace.exoticChars - Replace diacritics, remove UTF8 BOM, and replace smart characters from a string.

cleanTextUtils.replace.smartChars - Replace smart characters.

Types

TypeScript definitions are automatically installed.

import * as cleanTextUtils from 'clean-text-utils' to use built in types. :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.