1.0.0 • Published 7 years ago

liststyletype-formatter v1.0.0

Weekly downloads
6
License
-
Repository
github
Last release
7 years ago

liststyletype-formatter

Synopsis and Usage

This library formats (ordinal) numbers with JavaScript as CSS would do when using an ordered list or CSS counters.

For instance, to format a number as in lower case Roman format (corresponding to the CSS declaration list-style-type: lower-roman), use

// Node.js
var ListStyleTypeFormatter = require('liststyletype-formatter');
console.log(ListStyleTypeFormatter.format(1234, 'lower-roman'));
<!-- Browser -->
<script src="liststyletype-formatter.js"></script>
<script>
	console.log(ListStyleTypeFormatter.format(1234, 'lower-roman'));
</script>

The following formats are supported:

FormatDescription
arabic-indicEastern arabic numerals
armenian, upper-armenianTraditional Armenian numbering
bengaliBengali numerals
cambodian, khmerKhmer numerals
circleA hollow circle (for any number)
cjk-earthly-branchNumbering used in a Chinese system for reckoning time based on the Chinese zodiac
cjk-decimalHan decimal numbers
cjk-heavenly-stemChinese system of ordinals based on the ten days of the week
cjk-ideographicCJK (Chinese-Japanese-Korean) ideographic numbering
decimalDecimal numbers
decimal-leading-zeroDecimal numbers with a leading zero if there is only one digit
devanagariDevanagari numerals
discA filled disc (for any number)
ethiopic-numericEthiopic numbering
georgianTraditional Georgian numbering
gujaratiGujarati numerals
gurmukhiGurmuhki numerals
hebrewTraditional Hebrew numbering
hiraganaHiragana letters
hiragana-irohaHiragana letters in the old Japanese ordering
japanese-formalJapanese formal numbering to be used in legal or financial document
japanese-informalJapanese informal numbering
kannadaKannada numerals
katakanaKatakana letters
katakana-irohaKatakana letters in the old Japanese ordering
khmerKhmer numerals
korean-hangul-formalKorean hangul numbering
korean-hanja-formalFormal Korean Han numbering
korean-hanja-informalKorean Hanja numbering
laoLao numerals
lower-alpha, lower-latinLowercase ASCII letters
lower-armenianTraditional Armenian numbering with lowercase letters
lower-greekLowercase classical Greek
lower-romanLowercase Roman numerals
malayalamMalayalam numerals
mongolianMongolian numerals
myanmarBurmese numerals
noneNothing, returns an empty string
oriyaOriya (Odia) numerals
persianPersian numerals
simp-chinese-formalSimplified Chinese formal numbering
simp-chinese-informalSimplified Chinese informal numbering
squareA filled square (for any number)
tamilTamil numerals
teluguTelugu numerals
thaiThai numerals
tibetanTibetan numerals
trad-chinese-formalTraditional Chinese formal numbering
trad-chinese-informalTraditional Chinese informal numbering
upper-alpha, upper-latinUppercase ASCII letters
upper-armenian, armenianTraditional Armenian numbering
upper-romanUppercase Roman numerals

For more information, see https://developer.mozilla.org/en/docs/Web/CSS/list-style-type.

Installing

liststyletype-formatter can be installed with npm:

npm install liststyletype-formatter

Building and Testing

To build a browser version of the library, type

npm run build

To run the tests, type

npm test

License

MIT License

Copyright (c) 2017 Matthias Christen

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.