httongue
v3.1.0
Published
Hypertext tongue
Downloads
72
Maintainers
Readme
Hypertext Tongue
Hypertext and other web-related codecs.
HTML and XML
escapeXML(string): string
- Replaces XML-unsafe characters with corresponding predefined XML entities.escapeHTML(string): string
is an alias of escapeXML.
CSS
escapeCSS(string): string
- Escapes CSS identifier accordingly to the rules defined for CSS.escape() utility method.escapeCSSVal(string): string
- Escapes CSS value to be included into CSS string.hyphenateCSS(string): string
- Hyphenates camel-cased CSS property name.Handles
ms
vendor prefix and caches the results.
JavaScript
escapeJsString(string): string
- Escapes a string to be included into JavaScript string literal.Handles all kinds of quotes (
'
,"
, and ```) and special chars. Converts non-ASCII chars to corresponding Unicode escapes.jsPropertyAccessor(string, quote?): string
- Creates JavaScript property accessor expression.If accessed property
key
is valid JavaScript identifier, then creates a.${key}
accessor. Otherwise, creates an accessor like['${key}']
withkey
properly quoted.jsStringLiteral(string, quote?): string
- Creates JavaScript string literal.Encloses the string into quotes and properly escapes it.
quoteJsKey(string, quote?): string
- Conditionally quotes JavaScript key.If the given
key
is valid JavaScript identifier, then leaves it as is. Otherwise, encloses it into quotes and properly escapes if necessary.
URI
decodeURISearchPart(string): string
- Decodes part of URI search string, i.e. either search parameter name or value.In contrast to standard decodeURIComponent function, this one treats plus signs (
"+" (U+002B)
) as spaces. I.e. decodes the same way as URLSearchParams do.encodeURIPart(string | number | boolean): string
- Encodes part of URI.In contrast to standard encodeURIComponent function, this one follows RFC3869 requirements and percent-encodes all URI reserved characters.
Standard decodeURIComponent function can be used to decode URI.
encodeURISearchPart(string | number | boolean): string
- Encodes part of URI search string, i.e. either search parameter name or value.In contrast to standard encodeURIComponent function, this one encodes spaces as plus signs
"+" (U+002B)
. In addition, percent-encodes all URI reserved characters according to RFC3869.
Other
capitalize(string): string
- Capitalizes input string.Converts the first Unicode code point of input string to upper case.
decapitalize(string): string
- De-capitalizes input string.Converts the first Unicode code point of input string to lower case.
hyphenate(string): string
- Hyphenates a camel-cased string.