@locustjs/htmlencode
v1.0.1
Published
This library provides htmlencode/htmldecode functions
Downloads
6
Maintainers
Readme
locustjs-htmlencode
This library provides htmlencode/htmldecode functions.
Install
npm i @locustjs/htmlencode
Import
CommonJs
var { htmlEncode } = require('@locustjs/htmlencode');
ES6
import { htmlEncode } from '@locustjs/htmlencode'
Usage
Example 1: htmlEncode
import { htmlEncode } from '@locustjs/htmlencode'
const str = '<p>Plan & Business = $</p>';
console.log(htmlEncode(str)); // <p>Plan & Business = $</p>
Example 2: htmlEncode + custom ignore character list
import { htmlEncode } from '@locustjs/htmlencode'
const str = '<p>Plan & Business = $</p>';
console.log(htmlEncode(str, ['/', '=', '$'])); // <p>Plan & Business = $</p>
Example 3: htmlDecode
import { htmlDecode } from '@locustjs/htmlencode'
const str = '<p>Plan & Business</p>';
console.log(htmlDecode(str)); // <p>Plan & Business</p>