Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cerebrusinc/fstring
This brings Python string manipulation to js!
https://github.com/cerebrusinc/fstring
javascript nodejs package typescript
Last synced: about 1 month ago
JSON representation
This brings Python string manipulation to js!
- Host: GitHub
- URL: https://github.com/cerebrusinc/fstring
- Owner: cerebrusinc
- Created: 2022-10-09T16:33:22.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-10-16T13:56:51.000Z (about 1 year ago)
- Last Synced: 2024-10-19T14:44:40.725Z (2 months ago)
- Topics: javascript, nodejs, package, typescript
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/@cerebrusinc/fstring
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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](https://github.com/lewisjr/qol)
# Importing
```javascript
// 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
```javascript
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 Juniorconsole.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.
Params
| 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.
Params
| 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.
Params
| 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
v0.1.5
- Moved from [@techtronics/fstring](https://www.npmjs.com/package/@techtronics/fstring)
v0.1.4
- Added colon support to `toSentenceCase`
- Full parity with our python quality of life [qolpy](https://github.com/lewisjr/qolpy) packagev0.1.3
- Fixed missing build and type annotations
v0.1.2
- Added the option to have the abbreviation reverse or not before return
v0.1.1
- Type hint updates
- README restructuring
- toSentenceCase now supports custom delimiters 😎v0.1.0
- Initial release
- Sentence casing, title casing, and abrreviations added and typed