Skip to content

Commit bd87841

Browse files
committed
Added JSDoc TS definition
1 parent d05921b commit bd87841

File tree

5 files changed

+46
-6
lines changed

5 files changed

+46
-6
lines changed

cjs/index.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ const esca = {
3636
};
3737
const pe = m => esca[m];
3838

39+
/**
40+
* Safely escape HTML entities such as `&`, `<`, `>`, `"`, and `'`.
41+
* @param {string|number|boolean} es the input to safely escape
42+
* @returns {string} the escaped input, and it throws an error if
43+
* the input type is unexpected
44+
*/
3945
const escape = es => replace.call(es, ca, pe);
4046
exports.escape = escape;
4147

@@ -55,5 +61,12 @@ const unes = {
5561
};
5662
const cape = m => unes[m];
5763

64+
/**
65+
* Safely unescape previously escaped entities such as `&`, `<`, `>`, `"`,
66+
* and `'`.
67+
* @param {string} un a previously escaped string
68+
* @returns {string} the unescaped input, and it throws an error if
69+
* the input type is unexpected
70+
*/
5871
const unescape = un => replace.call(un, es, cape);
5972
exports.unescape = unescape;

esm/index.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ const esca = {
3535
};
3636
const pe = m => esca[m];
3737

38+
/**
39+
* Safely escape HTML entities such as `&`, `<`, `>`, `"`, and `'`.
40+
* @param {string|number|boolean} es the input to safely escape
41+
* @returns {string} the escaped input, and it throws an error if
42+
* the input type is unexpected
43+
*/
3844
export const escape = es => replace.call(es, ca, pe);
3945

4046

@@ -53,4 +59,11 @@ const unes = {
5359
};
5460
const cape = m => unes[m];
5561

62+
/**
63+
* Safely unescape previously escaped entities such as `&`, `<`, `>`, `"`,
64+
* and `'`.
65+
* @param {string} un a previously escaped string
66+
* @returns {string} the unescaped input, and it throws an error if
67+
* the input type is unexpected
68+
*/
5669
export const unescape = un => replace.call(un, es, cape);

index.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ var html = (function (exports) {
3838
};
3939
const pe = m => esca[m];
4040

41+
/**
42+
* Safely escape HTML entities such as `&`, `<`, `>`, `"`, and `'`.
43+
* @param {string|number|boolean} es the input to safely escape
44+
* @returns {string} the escaped input, and it throws an error if
45+
* the input type is unexpected
46+
*/
4147
const escape = es => replace.call(es, ca, pe);
4248

4349

@@ -56,6 +62,13 @@ var html = (function (exports) {
5662
};
5763
const cape = m => unes[m];
5864

65+
/**
66+
* Safely unescape previously escaped entities such as `&`, `<`, `>`, `"`,
67+
* and `'`.
68+
* @param {string} un a previously escaped string
69+
* @returns {string} the unescaped input, and it throws an error if
70+
* the input type is unexpected
71+
*/
5972
const unescape = un => replace.call(un, es, cape);
6073

6174
exports.escape = escape;

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
"scripts": {
88
"build": "npm run cjs && npm run rollup && npm run minify && npm test && npm run size",
99
"cjs": "ascjs esm cjs",
10-
"coveralls": "cat ./coverage/lcov.info | coveralls",
10+
"coveralls": "c8 report --reporter=text-lcov | coveralls",
1111
"minify": "uglifyjs index.js --comments=/^!/ --compress --mangle -o min.js",
1212
"rollup": "rollup --config rollup.config.js",
1313
"size": "cat index.js | wc -c;cat min.js | wc -c;gzip -c min.js | wc -c",
14-
"test": "istanbul cover ./test/index.js"
14+
"test": "c8 node ./test/index.js"
1515
},
1616
"module": "./esm/index.js",
1717
"type": "module",
@@ -38,10 +38,10 @@
3838
},
3939
"homepage": "https://github.com/WebReflection/html-escaper",
4040
"devDependencies": {
41-
"ascjs": "^3.1.2",
42-
"coveralls": "^3.0.11",
43-
"istanbul": "^0.4.5",
44-
"rollup": "^2.2.0",
41+
"ascjs": "^5.0.1",
42+
"c8": "^7.6.0",
43+
"coveralls": "^3.1.0",
44+
"rollup": "^2.39.0",
4545
"uglify-es": "^3.3.9"
4646
}
4747
}

rollup.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
export default {
22
input: 'esm/index.js',
33
output: {
4+
esModule: false,
45
exports: 'named',
56
file: 'index.js',
67
format: 'iife',

0 commit comments

Comments
 (0)