@w6s/escape

1.0.2 • Public • Published

@w6s/escape

Toggle escape string and object for use in HTML.

Install

npm install --save @w6s/escape

Usage

import { 
    escapeString,
    unescapeString,
    escapeObject,
    unescapeObject 
} from '@w6s/escape';

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/escape.git

npm install

npm test

License

MIT

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.0.21latest

Version History

VersionDownloads (Last 7 Days)Published
1.0.21

Package Sidebar

Install

npm i @w6s/escape

Weekly Downloads

1

Version

1.0.2

License

MIT

Unpacked Size

173 kB

Total Files

12

Last publish

Collaborators

  • q106357
  • muzi23
  • hejx