Open
Conversation
- Converts CommonJS module.exports to ESM export using a Rollup plugin - Adds an ESM import to the example in README.md - Adds the change in HISTORY.md - Adds "exports" key in package.json to detect proper export automatically
|
I have confirmed that the new file only contains gluing and formatting changes (if you add semicolons, the differences go away). This means that the functionality is the same. diff@@ -6,19 +6,21 @@
* MIT Licensed
*/
+'use strict'
+
/**
* Module variables.
* @private
*/
-var matchHtmlRegExp = /["'&<>]/;
+var matchHtmlRegExp = /["'&<>]/
/**
* Module exports.
* @public
*/
-var oss = escapeHtml;
+module.exports = escapeHtml
/**
* Escape special characters in the given string of text.
@@ -29,50 +31,48 @@ var oss = escapeHtml;
*/
function escapeHtml (string) {
- var str = '' + string;
- var match = matchHtmlRegExp.exec(str);
+ var str = '' + string
+ var match = matchHtmlRegExp.exec(str)
if (!match) {
return str
}
- var escape;
- var html = '';
- var index = 0;
- var lastIndex = 0;
+ var escape
+ var html = ''
+ var index = 0
+ var lastIndex = 0
for (index = match.index; index < str.length; index++) {
switch (str.charCodeAt(index)) {
case 34: // "
- escape = '"';
+ escape = '"'
break
case 38: // &
- escape = '&';
+ escape = '&'
break
case 39: // '
- escape = ''';
+ escape = '''
break
case 60: // <
- escape = '<';
+ escape = '<'
break
case 62: // >
- escape = '>';
+ escape = '>'
break
default:
continue
}
if (lastIndex !== index) {
- html += str.substring(lastIndex, index);
+ html += str.substring(lastIndex, index)
}
- lastIndex = index + 1;
- html += escape;
+ lastIndex = index + 1
+ html += escape
}
return lastIndex !== index
? html + str.substring(lastIndex, index)
: html
-}
-
-export { oss as default };
\ No newline at end of file
+}
\ No newline at end of file |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi, I've added ESM support to this package. Things done in this commit:
- Converts CommonJS module.exports to ESM export using a Rollup plugin
- Adds an ESM import to the example in README.md
- Adds the change in HISTORY.md
- Adds "exports" key in package.json to detect proper export automatically
I don't know Travis CI though, that should probably be updated too so that index.mjs will not be ignored when installing the package using NPM. Thank you.