0.1.5 • Published 7 months ago

@cerebrusinc/fstring v0.1.5

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

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.

ParameterDefault SettingRequired?Definition
txtnullYesThe string you wish to abbreviate
delimiter" "NoThe character or string that seperates words in the string
reversefalseNoAn 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.

ParameterDefault SettingRequired?Definition
txtnullYesThe string you wish to change to title case
delimiter" "NoThe 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.

ParameterDefault SettingRequired?Definition
txtnullYesThe string you wish to change to sentence case
delimiter" "NoThe character or string that seperates words in the string

Changelog

v0.1.x

  • 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