JSPM

@locustjs/htmlencode

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q26342F
  • License MIT

This library provides htmlencode/htmldecode functions

Package Exports

  • @locustjs/htmlencode
  • @locustjs/htmlencode/index.cjs.js
  • @locustjs/htmlencode/index.esm.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@locustjs/htmlencode) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

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));  // &lt;p&gt;Plan &amp; Business &equals; &dollar;&lt;&sol;p&gt;

Example 2: htmlEncode + custom ignore character list

import { htmlEncode } from '@locustjs/htmlencode'

const str = '<p>Plan & Business = $</p>';

console.log(htmlEncode(str, ['/', '=', '$']));  // &lt;p&gt;Plan &amp; Business = $&lt;/p&gt;

Example 3: htmlDecode

import { htmlDecode } from '@locustjs/htmlencode'

const str = '&lt;p&gt;Plan &amp; Business&lt;&sol;p&gt;';

console.log(htmlDecode(str));  // <p>Plan & Business</p>