format-fast
Hi, I'm Yoni Calsin
, I'd love you to give format-fast a chance, to shine inside your project, and to format a text string in a wonderful way, and of course with less code.
Format-fast
is a function that allows you to replace certain words to make a string dynamically, and very easily !
🍉 Installation
First we will have to install, in order to use this wonderful package.
# Using npm npm install --save format-fast # Using yarn yarn add format-fast
🌎 Usage
Format-fast
use is-all-utils
to validate the format of different characteristics !
First we import the function, as follows !
To use format-fast
you can use the formatFast
or f
function, they are practically the same, only f
is very short !
// For Typescript;// Or; // Javascript;// or;
Individually
If you want to send just one piece of information !
;fmsg, 20;//=> Hello, I'm '20' years old
Array
The time has come to use format-parse, using an array
const msg = "The '$0' of user '$1' is not defined within the object '$2"; ;//=> The 'name' of user '20' is not defined within the object 'users
Object
Soon we will use it with an object !
; fmsg, ;//=> The 'name' of the user '20' is not defined within the object 'users'
Iteration function!
Function to modify the value, and the key when each object is iterated !
; ; f msg, , iterateItem,;// => Hi, I'm '🎉 Yoni Calsin', I'm '40' years old f msg, , iterateItem,;// => Hi, I'm '🎉 Samuel Calsin', I'm '5' years old
Returning the iterateItem
function, as an array, if you return an array of two values, you will be replacing the key, and the
;
Brackets
%s
is the value of the key
; fmsg, , '{%s}'; // => Hi, I'm 'Yoni Calsin'.
Otro ejemplo
; fmsg, , '[[%s]]'; // => Hi, I'm 'Yoni Calsin'.
fmsg, replaces, brackets;// Orfmsg, replaces, iterateFunction, brackets;
⭐ Support for
format-fast
is an open source project licensed by MIT. You can grow thanks to the sponsors and the support of the amazing sponsors. If you want to join them, contact me here.
🎩 Stay in touch
- Github @yonicalsin
- Twitter @yonicalsin
- Instagram @yoni_calsin
- Medium @yonicalsin
- Dev @yonicalsin
🚀 Contributors
Thanks to the wonderful people who collaborate with me !
📜 License
format-fast
under License MIT.