awesome-pretty
Group up all available pretty modules in one
IMPORTANT
Big changes from last version, All functions are now nested in String,Number,Object except the Error
Install
npm install --save awesome-pretty
TODO
- [Bytes
- Millisecondes
- Error
- JSON
- String
- Number
- Currency
- Date
- Url
- Variable Name
- Phone Number
Use
const awesome_pretty = ;
Bytes
let size_in_bytes = 30000000; // Numbersize_in_bytes;// => '30 MB'let size_in_bytes_iec = 30000000; // Numbersize_in_bytes_iec;// => '28.61 MiB' let size_in_human = '30 MB'; // Stringsize_in_human;// => 30000000let size_in_human_iec = '30 MB'; // Stringsize_in_human_iec;// => 31457280
Millisecondes
let milliseconds = 6546546116541 ;milliseconds;// => '207 years, 5 months, 1 week, 4 days, 6 hours, 31 minutes, 57 seconds' let milliseconds_fr = 6546546116541 ;milliseconds_fr;// => '207 ans, 5 mois, 1 semaine, 4 jours, 6 heures, 31 minutes, 57 secondes' let milliseconds = 1517415909000 ;milliseconds;// => '2018-01-31 05:25:09' let milliseconds_custom = 1517415909000 ;milliseconds_custom;// => 'Wed 01/31/2018 17:09' let milliseconds_custom_fr = 1517415909000 ;milliseconds_custom_fr;// => 'mer. 01/31/2018 17:09'
Error
const awesome_pretty = ;awesome_pretty;// console.log it and you will have a beautiful Error
JSON
const obj = foo: 'bar' 'arr': 1 2 3;obj;/*{ "foo": "bar", "arr": [1,2,3]}*/ obj; // default ('\t',1)/*{ "foo": "bar", "arr": [1,2,3]}*/
String
'Hey hOw_are-yoU'; // this function will use slug() then humanize() then capitalize()// => 'Hey how are you' 'Hey hOw_are-yoU';// => 'heyHowAreYou' 'Hey hOw_are-yoU';// => 'heyHOwAreYoU' 'hey how are you';// => 'Hey how are you' 'hey how are you';// => 'Hey How Are You' 'heyHow_are-you';// => 'Hey how are you' 'Héy hôw äre you';// => 'Hey how are you' ' Hey how \t are \r\n\r\n you';// => 'Hey how are you' '<span>Hey how are you</span>';// => '<span>Hey how are you</span>' '<span>Hey how are you</span>';// => '<span>Hey how are you</span>' 'Hey how\r\nare\nyou';// => ['Hey how','are','you']); 'Hey how are you';// => ' Hey how are you ' 'Hey';// => ' Hey' 'Hey';// => '--Hey' 'Hey';// => ' Hey' 'Hey';// => 'Hey ' 'Hey';// => 'Hey--' 'Hey';// => 'Hey ' 'Hey how are you';// => 'Hey how a...' 'Hey how are you';// => 'Hey how a---' 'hey';// => 'heyheyhey' 'Hey how are you';// => 'Lol how are you' 'Hey how hey you Hey';// => 'Lol how hey you Lol' 'heyHow_are-you';// => 'heyhow-are-you' '<span>Hey how <strong>are</strong> you</span>';// => 'Hey how are you' '<span>Hey how <strong>are</strong> you</span>';// => '<span>Hey how are you</span>' 'Hey how are you';// => '<span>Hey how are you</span>' 'Hey how are you';// => '<div>Hey how are you</div>'
Currency
654132654;// => '$654,132,654.00' 987632465;// => 'د.ت. 987,632,465.000' 2132488945;// => '2 132 488 945,00 €' 548765324;// => '548^765^324*0 @' '$654,132,654.00';// => 654132654 //as you can see, I removed the Arabic sign "د.ت." to make it work'987,632,465.000';// => 987632465 '2 132 488 945,00 €';// => 2132488945 '548^765^324*0 @';// => 548765324
Number
let nbr = 15 ;nbr;// => '15' nbr = 7585547 ;nbr;// => '7,585.547' nbr = 2727272728 ;nbr;// => '2^727^272^728' nbr = 17272554425 ;nbr;// => 1,727,255.442 nbr = 17272554425 ;nbr;// => 1^727^255*44
Phone Number
let nbr = 632418652 ;nbr;// => '+33 6 32 41 86 52' let nbr = 632418652 ;nbr;// => '06 32 41 86 52'// International(is default) | National | E.164 | RFC3966
Variable Name
'foo-bar'; //'fooBar''foo_bar'; //'fooBar''Foo-Bar'; //'fooBar''--foo.bar'; //'fooBar''__foo__bar__'; //'fooBar''foo bar'; //'fooBar' 'foo-bar'; //'foo_bar''foo_bar'; //'foo_bar''Foo-Bar'; //'foo_bar''--foo.bar'; //'foo_bar''__foo__bar__'; //'foo_bar''foo bar'; //'foo_bar' 'foo-bar'; //'FooBar''foo_bar'; //'FooBar''Foo-Bar'; //'FooBar''--foo.bar'; //'FooBar''__foo__bar__'; //'FooBar''foo bar'; //'FooBar' 'foo-bar'; //'FOO_BAR''foo_bar'; //'FOO_BAR''Foo-Bar'; //'FOO_BAR''--foo.bar'; //'FOO_BAR''__foo__bar__'; //'FOO_BAR''foo bar'; //'FOO_BAR' 'foo-bar'; //'foo-bar''foo_bar'; //'foo-bar''Foo-Bar'; //'foo-bar''--foo.bar'; //'foo-bar''__foo__bar__'; //'foo-bar''foo bar'; //'foo-bar' 'foo-bar'; //'foo.bar''foo_bar'; //'foo.bar''Foo-Bar'; //'foo.bar''--foo.bar'; //'foo.bar''__foo__bar__'; //'foo.bar''foo bar'; //'foo.bar' 'foo-bar'; //'foo/bar''foo_bar'; //'foo/bar''Foo-Bar'; //'foo/bar''--foo.bar'; //'foo/bar''__foo__bar__'; //'foo/bar''foo bar'; //'foo/bar' 'foo-bar'; //'Foo-Bar''foo_bar'; //'Foo-Bar''Foo-Bar'; //'Foo-Bar''--foo.bar'; //'Foo-Bar''__foo__bar__'; //'Foo-Bar''foo bar'; //'Foo-Bar' 'foo-bar'; //'foo bar''foo_bar'; //'foo bar''Foo-Bar'; //'foo bar''--foo.bar'; //'foo bar''__foo__bar__'; //'foo bar''foo bar'; //'foo bar' 'foo-bar'; //'Foo bar''foo_bar'; //'Foo bar''Foo-Bar'; //'Foo bar''--foo.bar'; //'Foo bar''__foo__bar__'; //'Foo bar''foo bar'; //'Foo bar' 'foo-bar'; //'FOO-BAR''foo_bar'; //'FOO_BAR''Foo-Bar'; //'fOO-bAR''--foo.bar'; //'--FOO.BAR''__foo__bar__'; //'__FOO__BAR__''foo bar'; //'FOO BAR' 'foo-bar'; //'Foo Bar''foo_bar'; //'Foo Bar''Foo-Bar'; //'Foo Bar''--foo.bar'; //'Foo Bar''__foo__bar__'; //'Foo Bar''foo bar'; //'Foo Bar' 'foo-bar'; //'foo-bar''foo_bar'; //'foo_bar''Foo-Bar'; //'foo-bar''--foo.bar'; //'--foo.bar''__foo__bar__'; //'__foo__bar__''foo bar'; //'foo bar' 'foo-bar'; //'foo-bar''foo_bar'; //'foo_bar''Foo-Bar'; //'foo-Bar''--foo.bar'; //'--foo.bar''__foo__bar__'; //'__foo__bar__''foo bar'; //'foo bar' 'foo-bar'; //'FOO-BAR''foo_bar'; //'FOO_BAR''Foo-Bar'; //'FOO-BAR''--foo.bar'; //'--FOO.BAR''__foo__bar__'; //'__FOO__BAR__''foo bar'; //'FOO BAR' 'foo-bar'; //'Foo-bar''foo_bar'; //'Foo_bar''Foo-Bar'; //'Foo-Bar''--foo.bar'; //'--foo.bar''__foo__bar__'; //'__foo__bar__''foo bar'; //'Foo bar'