Comparing version 1.2.4 to 1.2.5
@@ -5,2 +5,8 @@ # Change Log | ||
## 1.2.5 | ||
- Fix minor inconsistencies | ||
- Improve JSDoc and type hints | ||
- Update dependencies | ||
## 1.2.4 | ||
@@ -7,0 +13,0 @@ - Add security policy |
@@ -23,6 +23,8 @@ /** | ||
/** | ||
* Parse a string as a base-16 number. This is more strict than parseInt as it | ||
* Parse a string as a base-16 number. This is more strict than `parseInt` as it | ||
* will not allow any other characters, including (for example) "+", "-", and | ||
* ".". | ||
* @param hex A string containing a hexadecimal number. | ||
* @returns The parsed integer, or `NaN` if the string is not a valid hex | ||
* number. | ||
*/ | ||
@@ -34,9 +36,10 @@ function parseHexToInt(hex) { | ||
/** | ||
* Check the validity and length of a four-digit hexadecimal code. | ||
* Check the validity and length of a hexadecimal code and optionally enforces | ||
* a specific number of hex digits. | ||
* @param hex The string to validate and parse. | ||
* @param errorName The name of the error message to throw a `SyntaxError` with | ||
* if `hex` is invalid. | ||
* @param enforcedLength If provided, will throw an error if `hex` is not this | ||
* long exactly. | ||
* @returns The parsed code. | ||
* if `hex` is invalid. This is used to index `errorMessages`. | ||
* @param enforcedLength If provided, will throw an error if `hex` is not | ||
* exactly this many characters. | ||
* @returns The parsed hex number as a normal number. | ||
* @throws {SyntaxError} If the code is not valid. | ||
@@ -47,3 +50,3 @@ */ | ||
if (Number.isNaN(parsedHex) || | ||
(enforcedLength && hex.length !== enforcedLength)) { | ||
(enforcedLength !== undefined && enforcedLength !== hex.length)) { | ||
throw new SyntaxError(errors_1.errorMessages.get(errorName)); | ||
@@ -54,5 +57,6 @@ } | ||
/** | ||
* Parse a hexadecimal escape code. | ||
* @param code The two-character hex code that represents the character to | ||
* Parse a two-digit hexadecimal character escape code. | ||
* @param code The two-digit hexadecimal number that represents the character to | ||
* output. | ||
* @returns The single character represented by the code. | ||
* @throws {SyntaxError} If the code is not valid hex or is not the right | ||
@@ -66,7 +70,8 @@ * length. | ||
/** | ||
* Parse a Unicode escape code. | ||
* Parse a four-digit Unicode character escape code. | ||
* @param code The four-digit unicode number that represents the character to | ||
* output. | ||
* @param surrogateCode The four-digit unicode surrogate that represents the | ||
* character to output. | ||
* @param surrogateCode Optional four-digit unicode surrogate that represents | ||
* the other half of the character to output. | ||
* @returns The single character represented by the code. | ||
* @throws {SyntaxError} If the codes are not valid hex or are not the right | ||
@@ -92,5 +97,6 @@ * length. | ||
/** | ||
* Parse a Unicode code point escape code. | ||
* @param codePoint A unicode escape code, including the surrounding curly | ||
* Parse a Unicode code point character escape code. | ||
* @param codePoint A unicode escape code point, including the surrounding curly | ||
* braces. | ||
* @returns The single character represented by the code. | ||
* @throws {SyntaxError} If the code is not valid hex or does not have the | ||
@@ -114,2 +120,4 @@ * surrounding curly braces. | ||
} | ||
// Have to give overload that takes boolean for when compiler doesn't know if | ||
// true or false | ||
function parseOctalCode(code, error = false) { | ||
@@ -149,3 +157,3 @@ if (error) { | ||
* All capture groups (described below) are unique (only one will match), except | ||
* for 3 and 4 which always match together. | ||
* for 4, which can only potentially match if 3 does. | ||
* | ||
@@ -152,0 +160,0 @@ * **Capture Groups:** |
@@ -1,1 +0,1 @@ | ||
!function(r){if("object"==typeof module&&"object"==typeof module.exports){var e=r(require,exports);void 0!==e&&(module.exports=e)}else"function"==typeof define&&define.amd&&define(["require","exports","./errors"],r)}(function(r,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});const o=r("./errors");function t(r,e,t){const n=function(r){return r.match(/[^a-f0-9]/i)?NaN:parseInt(r,16)}(r);if(Number.isNaN(n)||t&&r.length!==t)throw new SyntaxError(o.errorMessages.get(e));return n}function n(r,e){const n=t(r,o.ErrorType.MalformedUnicode,4);if(void 0!==e){const r=t(e,o.ErrorType.MalformedUnicode,4);return String.fromCharCode(n,r)}return String.fromCharCode(n)}e.ErrorType=o.ErrorType,e.errorMessages=o.errorMessages;const i=new Map([["b","\b"],["f","\f"],["n","\n"],["r","\r"],["t","\t"],["v","\v"],["0","\0"]]);const s=/\\(?:(\\)|x([\s\S]{0,2})|u(\{[^}]*\}?)|u([\s\S]{4})\\u([^{][\s\S]{0,3})|u([\s\S]{0,4})|([0-3]?[0-7]{1,2})|([\s\S])|$)/g;function f(r,e=!1){return r.replace(s,function(r,s,f,a,u,c,d,g,p){if(void 0!==s)return"\\";if(void 0!==f)return function(r){const e=t(r,o.ErrorType.MalformedHexadecimal,2);return String.fromCharCode(e)}(f);if(void 0!==a)return function(r){if("{"!==(e=r).charAt(0)||"}"!==e.charAt(e.length-1))throw new SyntaxError(o.errorMessages.get(o.ErrorType.MalformedUnicode));var e;const n=t(r.slice(1,-1),o.ErrorType.MalformedUnicode);try{return String.fromCodePoint(n)}catch(r){throw r instanceof RangeError?new SyntaxError(o.errorMessages.get(o.ErrorType.CodePointLimit)):r}}(a);if(void 0!==u)return n(u,c);if(void 0!==d)return n(d);if("0"===g)return"\0";if(void 0!==g)return function(r,e=!1){if(e)throw new SyntaxError(o.errorMessages.get(o.ErrorType.OctalDeprecation));const t=parseInt(r,8);return String.fromCharCode(t)}(g,!e);if(void 0!==p)return y=p,i.get(y)||y;var y;throw new SyntaxError(o.errorMessages.get(o.ErrorType.EndOfString))})}e.unraw=f,e.default=f}); | ||
!function(r){if("object"==typeof module&&"object"==typeof module.exports){var e=r(require,exports);void 0!==e&&(module.exports=e)}else"function"==typeof define&&define.amd&&define(["require","exports","./errors"],r)}(function(r,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});const o=r("./errors");function t(r,e,t){const n=function(r){return r.match(/[^a-f0-9]/i)?NaN:parseInt(r,16)}(r);if(Number.isNaN(n)||void 0!==t&&t!==r.length)throw new SyntaxError(o.errorMessages.get(e));return n}function n(r,e){const n=t(r,o.ErrorType.MalformedUnicode,4);if(void 0!==e){const r=t(e,o.ErrorType.MalformedUnicode,4);return String.fromCharCode(n,r)}return String.fromCharCode(n)}e.ErrorType=o.ErrorType,e.errorMessages=o.errorMessages;const i=new Map([["b","\b"],["f","\f"],["n","\n"],["r","\r"],["t","\t"],["v","\v"],["0","\0"]]);const s=/\\(?:(\\)|x([\s\S]{0,2})|u(\{[^}]*\}?)|u([\s\S]{4})\\u([^{][\s\S]{0,3})|u([\s\S]{0,4})|([0-3]?[0-7]{1,2})|([\s\S])|$)/g;function f(r,e=!1){return r.replace(s,function(r,s,f,a,u,c,d,g,p){if(void 0!==s)return"\\";if(void 0!==f)return function(r){const e=t(r,o.ErrorType.MalformedHexadecimal,2);return String.fromCharCode(e)}(f);if(void 0!==a)return function(r){if("{"!==(e=r).charAt(0)||"}"!==e.charAt(e.length-1))throw new SyntaxError(o.errorMessages.get(o.ErrorType.MalformedUnicode));var e;const n=t(r.slice(1,-1),o.ErrorType.MalformedUnicode);try{return String.fromCodePoint(n)}catch(r){throw r instanceof RangeError?new SyntaxError(o.errorMessages.get(o.ErrorType.CodePointLimit)):r}}(a);if(void 0!==u)return n(u,c);if(void 0!==d)return n(d);if("0"===g)return"\0";if(void 0!==g)return function(r,e=!1){if(e)throw new SyntaxError(o.errorMessages.get(o.ErrorType.OctalDeprecation));const t=parseInt(r,8);return String.fromCharCode(t)}(g,!e);if(void 0!==p)return y=p,i.get(y)||y;var y;throw new SyntaxError(o.errorMessages.get(o.ErrorType.EndOfString))})}e.unraw=f,e.default=f}); |
{ | ||
"name": "unraw", | ||
"version": "1.2.4", | ||
"version": "1.2.5", | ||
"description": "Convert raw escape sequences to their respective characters (undo String.raw).", | ||
@@ -29,21 +29,21 @@ "main": "dist/index.js", | ||
"devDependencies": { | ||
"@node-minify/cli": "^4.1.2", | ||
"@node-minify/core": "^4.1.2", | ||
"@node-minify/uglify-es": "^4.1.2", | ||
"@node-minify/core": "^5.2.1", | ||
"@node-minify/cli": "^5.2.1", | ||
"@node-minify/uglify-es": "^5.2.0", | ||
"@types/mocha": "^5.2.7", | ||
"@types/node": "^12.7.2", | ||
"@typescript-eslint/eslint-plugin": "^2.0.0", | ||
"@typescript-eslint/parser": "^2.0.0", | ||
"@types/node": "^12.12.9", | ||
"@typescript-eslint/eslint-plugin": "^2.8.0", | ||
"@typescript-eslint/parser": "^2.8.0", | ||
"cross-var": "^1.1.0", | ||
"eslint": "^6.2.1", | ||
"eslint-config-google": "^0.13.0", | ||
"eslint-plugin-jsdoc": "^15.8.3", | ||
"eslint-plugin-mocha": "^6.0.0", | ||
"mocha": "^6.2.0", | ||
"eslint": "^6.6.0", | ||
"eslint-config-google": "^0.14.0", | ||
"eslint-plugin-jsdoc": "^18.0.1", | ||
"eslint-plugin-mocha": "^6.2.1", | ||
"mocha": "^6.2.2", | ||
"mocha-junit-reporter": "^1.23.1", | ||
"nyc": "^14.1.1", | ||
"prettier": "^1.18.2", | ||
"source-map-support": "^0.5.13", | ||
"prettier": "^1.19.1", | ||
"source-map-support": "^0.5.16", | ||
"ts-mocha": "^6.0.0", | ||
"typescript": "^3.5.3" | ||
"typescript": "^3.7.2" | ||
}, | ||
@@ -87,3 +87,22 @@ "dependencies": {}, | ||
"decode" | ||
] | ||
], | ||
"greenkeeper": { | ||
"commitMessages": { | ||
"initialBadge": "Add Greenkeeper badge", | ||
"initialDependencies": "Update dependencies", | ||
"initialBranches": "Whitelist greenkeeper branches", | ||
"dependencyUpdate": "Update ${dependency} to version ${version}", | ||
"devDependencyUpdate": "Update ${dependency} to version ${version}", | ||
"dependencyPin": "Pin ${dependency} to ${oldVersion}", | ||
"devDependencyPin": "Pin ${dependency} to ${oldVersion}" | ||
}, | ||
"prTitles": { | ||
"initialPR": "Update dependencies to enable Greenkeeper", | ||
"initialPrBadge": "Add badge to enable Greenkeeper", | ||
"initialPrBadgeOnly": "Add Greenkeeper badge", | ||
"initialSubgroupPR": "Update dependencies for ${group}", | ||
"basicPR": "Update ${dependency} to the latest", | ||
"groupPR": "Update ${dependency} in group ${group} to the latest" | ||
} | ||
} | ||
} |
@@ -7,4 +7,5 @@ # `unraw` | ||
[![npm](https://img.shields.io/npm/v/unraw)](https://www.npmjs.com/package/unraw) | ||
[![David](https://img.shields.io/david/iansan5653/unraw)](https://david-dm.org/iansan5653/unraw) | ||
[![David](https://img.shields.io/david/dev/iansan5653/unraw)](https://david-dm.org/iansan5653/unraw?type=dev) | ||
[![David](https://david-dm.org/iansan5653/unraw.svg)](https://david-dm.org/iansan5653/unraw) | ||
[![David](https://david-dm.org/iansan5653/unraw/dev-status.svg)](https://david-dm.org/iansan5653/unraw?type=dev) | ||
[![Greenkeeper badge](https://badges.greenkeeper.io/iansan5653/unraw.svg)](https://greenkeeper.io/) | ||
@@ -11,0 +12,0 @@ ```ts |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
35274
343
177