Skip to content

WorkPlusFE/escape

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@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

About

Toggle escape string and object for use in HTML.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published