Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/agustinsrg/text-transform
Simple library to build text transform web apps
https://github.com/agustinsrg/text-transform
Last synced: 24 days ago
JSON representation
Simple library to build text transform web apps
- Host: GitHub
- URL: https://github.com/agustinsrg/text-transform
- Owner: AgustinSRG
- License: mit
- Created: 2021-06-26T18:41:57.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-06-29T09:58:14.000Z (6 months ago)
- Last Synced: 2024-06-29T10:55:26.762Z (6 months ago)
- Language: JavaScript
- Size: 13.7 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Text Transform
Library to build simple text transform tools you can run in your browser.
# Usage
Import the style:
```html
```
Import the script:
```html
```
Define the transform algorithm:
```js
TextTransform.ready(function () {
// First argument: Element or selector to mount into
// Second argument: Array of input parsers.
// They parse the input text to intermediary unified format for formatters
// Set a parser to null if the input does not need any parsing
// Third argument: Array of formatters,
// they take the intermediary unified format
// and return the outout text
TextTransform.mount(
".text-transform",
[
{
name: "Input String",
parser: null,
}
],
[
{
name: "Uppercase",
formatter: function (arg) {
return arg.toUpperCase()
},
},
{
name: "Lowercase",
formatter: function (arg) {
return arg.toLowerCase()
},
}
],
);
});
```Parsers and formatters functions can return a `Promise` if you require async functionality.
# Examples
- [Basic example](https://agustinsrg.github.io/Text-Transform/example.html)
- [Example of base encoder](https://agustinsrg.github.io/Text-Transform/apps/base-encoder/)# Build from source code
Install dependencies:
```sh
npm install
```Build minified files:
```sh
npm run build
```