Installation
Quick Take
Idea
A tiny (1.1KB) utility to calculate a position where to split a given the word (string) into two parts.
For example, it can be used to highlight one part of the string, to make it easier to read.
Features
- Super lightweight
- Extremely performant
- Multilingual, supports all Latin and Cyrillic alphabets
- No dependencies
- Source in TS
- Automatically-generated type definitions
- Supports native ES Modules
- Browser-Compatible
- 100% code coverage unit tests
API — split()
The main function split()
is imported like this:
It’s a function which takes two input arguments:
Input argument | Type | Obligatory | Description |
---|---|---|---|
str Type: String Obligatory: yes | |||
str | String | yes | A word string. |
opts Type: Plain object Obligatory: no | |||
opts | Plain object | no | Optional Options Object. |
The Optional Options Object has the following shape:
Key | Type | Default | Description |
---|---|---|---|
throwIfEdgeWhitespace Type: Boolean Default: true | |||
throwIfEdgeWhitespace | Boolean | true | Optionally, you can disable throw ing when there is a trailing whitespace detected. |
The function will return a number, a string index. It is a suggestion where exactly to slice the str
in two parts.
API — defaults
You can import defaults
:
It's a plain object:
The main function calculates the options to be used by merging the options you passed with these defaults.
API — version
You can import version
:
How different is it from the Bionic Reading®?
This program is not affiliated with Bionic Reading® in any way.
For starters, an aforementioned commercial product is a set of different APIs and services which use closed-source, commercial and very advanced algorithms to format text in various ways.
On the other hand, the humble string-bionic-split
processes one word at a time; it only suggests an index position, where to cut it into two pieces.