workplus-escape

1.0.2 • Public • Published

workplus-escape npm

Toggle escape string and object for use in HTML.

Install

npm install --save workplus-escape

Usage

import { 
    escapeString,
    unescapeString,
    escapeObject,
    unescapeObject 
} from 'workplus-query-string';
 
const str = escapeString('<h1></h1>"');
// str => '&lt;h1&gt;&lt;/h1&gt;&quot;'
 
const rts = unescapeString('&lt;h2&gt;&lt;/h2&gt;');
// rts => '<h2></h2>'
 
let someObject = {
    a: '<h1></h1>',
    b: "'",
    c: {
        x: '""'
    }
};
let obj = escapeObject(someObject);
// obj.a => '&lt;h1&gt;&lt;/h1&gt;'
// ibj.b => '&#39;'
// obj.c.x => '&quot;&quot;'
 
let jbo = unescapeObject(obj);
// jbo.a => '<h1></h1>'
 

Why not use "&apos;"

Development

git clone https://github.com/WorkPlusFE/workplus-escape.git
 
npm install
 
npm test

License

MIT

Package Sidebar

Install

npm i workplus-escape

Weekly Downloads

3

Version

1.0.2

License

MIT

Last publish

Collaborators

  • hejx