@techtronics/fstring
v0.1.5
Published
This brings Python string manipulation to js!
Downloads
5
Maintainers
Readme
Deprecation Notice
This package will now maintain newer versions and updates at @cerebrusinc/fstring.
fstring
This package brings some Python string formatting to Javascript! Currently you can:
- Abbreviate a string
- Make a string sentence case
- Make a string title case
Installation
npm install @techtronics/fstring
or
yarn add @techtronics/fstring
It goes hand in hand with our quality of life package qol
Importing
// ES6 Module
import * as fstring from "@techtronics/fstring";
// ES6 Destructuring
import { abbreviate, toTitleCase, toSentenceCase } from "@techtronics/fstring";
// ES5 Module
const fstring = require("@techtronics/fstring");
// ES5 Destructuring
const {
abbreviate,
toTitleCase,
toSentenceCase,
} = require("@techtronics/fstring");
Usage
const sentence = "heLLo wOrLD, mY NAME is lEwis; i am a Developer.";
const name = "lEwiS mOsho junior";
console.log(toSentenceCase(sentence));
// Hello world, my name is lewis; I am a developer.
console.log(toTitleCase(name));
// Lewis Mosho Junior
console.log(abbreviate(name));
// LMJ
Functions
abbreviate
Make an abbreviation of a string; Usually used for names. It returns a capital case abbreviation of the string.
| Parameter | Default Setting | Required? | Definition |
| --------- | --------------- | --------- | ----------------------------------------------------------- |
| txt | null
| Yes | The string you wish to abbreviate |
| delimiter | " "
| No | The character or string that seperates words in the string |
| reverse | false
| No | An option to enable you to request a reversed return string |
toTitleCase
Make any string title cased. it returns a string in which every first letter of a word is upper cased with the rest being lower cased.
| Parameter | Default Setting | Required? | Definition |
| --------- | --------------- | --------- | ---------------------------------------------------------- |
| txt | null
| Yes | The string you wish to change to title case |
| delimiter | " "
| No | The character or string that seperates words in the string |
toSentenceCase
Make any string sentence cased; The current sentence delimiters are:
.
;
:
!
?
It returns a string in which every first letter of the first word of a sentence is capitalised, with the reaminder of the senter being lower cased.
| Parameter | Default Setting | Required? | Definition |
| --------- | --------------- | --------- | ---------------------------------------------------------- |
| txt | null
| Yes | The string you wish to change to sentence case |
| delimiter | " "
| No | The character or string that seperates words in the string |
Changelog
v0.1.x
- Moved to @cerebrusinc/fstring
- Added colon support to
toSentenceCase
- Full parity with our python quality of life qolpy package
- Fixed missing build and type annotations
- Added the option to have the abbreviation reverse or not before return
- Type hint updates
- README restructuring
- toSentenceCase now supports custom delimiters 😎
- Initial release
- Sentence casing, title casing, and abrreviations added and typed