stryle
v1.0.4
Published
str[ing] [st]yle; A JavaScript package for ease of string manipulation; with styling per character for HTML documents
Downloads
6
Readme
Str[ing] [st]yle
List of contents:
- Brief Introduction
- Installation
- Exemplar
- Legal (MIT license)
Brief Introduction
A JavaScript package for ease of manipulating strings, with CSS styling for each character and basic methods.
Installation
Install Node.js if not already.
Verify npm installation with npm -v
, which should return the installed version. If not refer to prior step.
To install the stryle package, use the command npm install stryle
Exemplar
For each of the following examples the code snippet below is required to satisfy the importing of the modules, and initialization of the stryle class.
var Stryle = require('stryle');
var range = require('stryle/src/range');
string = new Stryle('Hello, World!');
console.log(
string.export()
);
Hello, World!
string.import(
string.slice(
0, 6
) + 'Stryle!'
);
console.log(
string.export()
);
Hello, Stryle!
console.log(
string.length()
);
13
string.replace(12, ';');
console.log(
string.export();
);
Hello, World;
console.log(
string.slice(7, 12)
);
World
Styling
string.style(
'font-size: 10px;',
[12, 0, 1, 2, 3, 4]
);
console.log(
string.export()
);
<span style="font-size: 10px;">He</span>llo</span>, World<span style="font-size: 10px;">!</span>
string.unstyle(
'font-size: 10px;'
);
console.log(
string.export()
);
Hello, World!
console.log(
range(5, 10)
);
[ 5, 6, 7, 8, 9, 10 ]
Coloring
string.color(
'blue',
range(0, 4)
);
console.log(
string.export()
);
<span style="color:blue;">Hello</span>, World!
string.uncolor(
'blue'
);
console.log(
string.export()
);
Hello, World!
License (MIT)
|Permissions|Conditions|Limitations| |---|---|---| |Commercial use|License and copyright notice|Liability| |Distribution||Warranty| |Modification||| |Private use|||
MIT License
Copyright (c) 2022 Ivan (GitHub: ivanl-exe, E-Mail: [email protected])
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.