Changeset 0c6b92a for imaps-frontend/node_modules/jsesc
- Timestamp:
- 12/12/24 17:06:06 (5 weeks ago)
- Branches:
- main
- Parents:
- d565449
- Location:
- imaps-frontend/node_modules/jsesc
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
imaps-frontend/node_modules/jsesc/README.md
rd565449 r0c6b92a 1 # jsesc [![Build status](https://travis-ci.org/mathiasbynens/jsesc.svg?branch=master)](https://travis-ci.org/mathiasbynens/jsesc) [![Code coverage status](https://coveralls.io/repos/mathiasbynens/jsesc/badge.svg)](https://coveralls.io/r/mathiasbynens/jsesc) [![Dependency status](https://gemnasium.com/mathiasbynens/jsesc.svg)](https://gemnasium.com/mathiasbynens/jsesc)1 # jsesc [![Build status](https://travis-ci.org/mathiasbynens/jsesc.svg?branch=master)](https://travis-ci.org/mathiasbynens/jsesc) [![Code coverage status](https://coveralls.io/repos/mathiasbynens/jsesc/badge.svg)](https://coveralls.io/r/mathiasbynens/jsesc) 2 2 3 3 Given some data, _jsesc_ returns a stringified representation of that data. jsesc is similar to `JSON.stringify()` except: … … 203 203 * U+2029 `\u2029` 204 204 * whatever symbol is being used for wrapping string literals (based on [the `quotes` option](#quotes)) 205 * [lone surrogates](https://esdiscuss.org/topic/code-points-vs-unicode-scalar-values#content-14) 205 206 206 207 Note: with this option enabled, jsesc output is no longer guaranteed to be ASCII-safe. … … 249 250 #### `indent` 250 251 251 The `indent` option takes a string value, and defaults to `'\t'`. When the `compact` setting is enabled (`true`), the value of the `indent` option is used to format the output for arrays and objects.252 The `indent` option takes a string value, and defaults to `'\t'`. When the `compact` setting is disabled (`false`), the value of the `indent` option is used to format the output for arrays and objects. 252 253 253 254 ```js … … 407 408 ## Support 408 409 409 As of v 2.0.0, jsesc supports Node.js v4+ only.410 As of v3.0.0, jsesc supports Node.js v6+ only. 410 411 411 412 Older versions (up to jsesc v1.3.0) support Chrome 27, Firefox 3, Safari 4, Opera 10, IE 6, Node.js v6.0.0, Narwhal 0.3.2, RingoJS 0.8-0.11, PhantomJS 1.9.0, and Rhino 1.7RC4. **Note:** Using the `json` option on objects or arrays that contain non-string values relies on `JSON.parse()`. For legacy environments like IE ≤ 7, use [a `JSON` polyfill](https://bestiejs.github.io/json3/). -
imaps-frontend/node_modules/jsesc/jsesc.js
rd565449 r0c6b92a 29 29 }; 30 30 31 const fourHexEscape = (hex) => { 32 return '\\u' + ('0000' + hex).slice(-4); 33 } 34 35 const hexadecimal = (code, lowercase) => { 36 let hexadecimal = code.toString(16); 37 if (lowercase) return hexadecimal; 38 return hexadecimal.toUpperCase(); 39 }; 40 31 41 const toString = object.toString; 32 42 const isArray = Array.isArray; 33 const isBuffer = Buffer.isBuffer; 43 const isBuffer = (value) => { 44 return typeof Buffer === 'function' && Buffer.isBuffer(value); 45 }; 34 46 const isObject = (value) => { 35 47 // This is a very simple check, but it’s good enough for what we need. … … 58 70 // https://mathiasbynens.be/notes/javascript-escapes#single 59 71 const singleEscapes = { 60 '"': '\\"',61 '\'': '\\\'',62 72 '\\': '\\\\', 63 73 '\b': '\\b', … … 69 79 // '\v': '\\x0B' 70 80 }; 71 const regexSingleEscape = /[ "'\\\b\f\n\r\t]/;81 const regexSingleEscape = /[\\\b\f\n\r\t]/; 72 82 73 83 const regexDigit = /[0-9]/; 74 const regexWhitelist = /[ !#-&\(-\[\]-_a-~]/; 84 const regexWhitespace = /[\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/; 85 86 const escapeEverythingRegex = /([\uD800-\uDBFF][\uDC00-\uDFFF])|([\uD800-\uDFFF])|(['"`])|[^]/g; 87 const escapeNonAsciiRegex = /([\uD800-\uDBFF][\uDC00-\uDFFF])|([\uD800-\uDFFF])|(['"`])|[^ !#-&\(-\[\]-_a-~]/g; 75 88 76 89 const jsesc = (argument, options) => { … … 235 248 } 236 249 237 const string = argument; 238 // Loop over each code unit in the string and escape it 239 let index = -1; 240 const length = string.length; 241 result = ''; 242 while (++index < length) { 243 const character = string.charAt(index); 244 if (options.es6) { 245 const first = string.charCodeAt(index); 246 if ( // check if it’s the start of a surrogate pair 247 first >= 0xD800 && first <= 0xDBFF && // high surrogate 248 length > index + 1 // there is a next code unit 249 ) { 250 const second = string.charCodeAt(index + 1); 251 if (second >= 0xDC00 && second <= 0xDFFF) { // low surrogate 252 // https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae 253 const codePoint = (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000; 254 let hexadecimal = codePoint.toString(16); 255 if (!lowercaseHex) { 256 hexadecimal = hexadecimal.toUpperCase(); 257 } 258 result += '\\u{' + hexadecimal + '}'; 259 ++index; 260 continue; 261 } 262 } 263 } 264 if (!options.escapeEverything) { 265 if (regexWhitelist.test(character)) { 266 // It’s a printable ASCII character that is not `"`, `'` or `\`, 267 // so don’t escape it. 268 result += character; 269 continue; 270 } 271 if (character == '"') { 272 result += quote == character ? '\\"' : character; 273 continue; 274 } 275 if (character == '`') { 276 result += quote == character ? '\\`' : character; 277 continue; 278 } 279 if (character == '\'') { 280 result += quote == character ? '\\\'' : character; 281 continue; 282 } 283 } 250 const regex = options.escapeEverything ? escapeEverythingRegex : escapeNonAsciiRegex; 251 result = argument.replace(regex, (char, pair, lone, quoteChar, index, string) => { 252 if (pair) { 253 if (options.minimal) return pair; 254 const first = pair.charCodeAt(0); 255 const second = pair.charCodeAt(1); 256 if (options.es6) { 257 // https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae 258 const codePoint = (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000; 259 const hex = hexadecimal(codePoint, lowercaseHex); 260 return '\\u{' + hex + '}'; 261 } 262 return fourHexEscape(hexadecimal(first, lowercaseHex)) + fourHexEscape(hexadecimal(second, lowercaseHex)); 263 } 264 265 if (lone) { 266 return fourHexEscape(hexadecimal(lone.charCodeAt(0), lowercaseHex)); 267 } 268 284 269 if ( 285 char acter== '\0' &&270 char == '\0' && 286 271 !json && 287 272 !regexDigit.test(string.charAt(index + 1)) 288 273 ) { 289 result += '\\0'; 290 continue; 291 } 292 if (regexSingleEscape.test(character)) { 274 return '\\0'; 275 } 276 277 if (quoteChar) { 278 if (quoteChar == quote || options.escapeEverything) { 279 return '\\' + quoteChar; 280 } 281 return quoteChar; 282 } 283 284 if (regexSingleEscape.test(char)) { 293 285 // no need for a `hasOwnProperty` check here 294 result += singleEscapes[character]; 295 continue; 296 } 297 const charCode = character.charCodeAt(0); 298 if (options.minimal && charCode != 0x2028 && charCode != 0x2029) { 299 result += character; 300 continue; 301 } 302 let hexadecimal = charCode.toString(16); 303 if (!lowercaseHex) { 304 hexadecimal = hexadecimal.toUpperCase(); 305 } 306 const longhand = hexadecimal.length > 2 || json; 307 const escaped = '\\' + (longhand ? 'u' : 'x') + 308 ('0000' + hexadecimal).slice(longhand ? -4 : -2); 309 result += escaped; 310 continue; 286 return singleEscapes[char]; 287 } 288 289 if (options.minimal && !regexWhitespace.test(char)) { 290 return char; 291 } 292 293 const hex = hexadecimal(char.charCodeAt(0), lowercaseHex); 294 if (json || hex.length > 2) { 295 return fourHexEscape(hex); 296 } 297 298 return '\\x' + ('00' + hex).slice(-2); 299 }); 300 301 if (quote == '`') { 302 result = result.replace(/\$\{/g, '\\${'); 303 } 304 if (options.isScriptContext) { 305 // https://mathiasbynens.be/notes/etago 306 result = result 307 .replace(/<\/(script|style)/gi, '<\\/$1') 308 .replace(/<!--/g, json ? '\\u003C!--' : '\\x3C!--'); 311 309 } 312 310 if (options.wrap) { 313 311 result = quote + result + quote; 314 312 } 315 if (quote == '`') {316 result = result.replace(/\$\{/g, '\\\$\{');317 }318 if (options.isScriptContext) {319 // https://mathiasbynens.be/notes/etago320 return result321 .replace(/<\/(script|style)/gi, '<\\/$1')322 .replace(/<!--/g, json ? '\\u003C!--' : '\\x3C!--');323 }324 313 return result; 325 314 }; 326 315 327 jsesc.version = ' 2.5.2';316 jsesc.version = '3.0.2'; 328 317 329 318 module.exports = jsesc; -
imaps-frontend/node_modules/jsesc/package.json
rd565449 r0c6b92a 1 1 { 2 2 "name": "jsesc", 3 "version": " 2.5.2",3 "version": "3.0.2", 4 4 "description": "Given some data, jsesc returns the shortest possible stringified & ASCII-safe representation of that data.", 5 5 "homepage": "https://mths.be/jsesc", 6 6 "engines": { 7 "node": ">= 4"7 "node": ">=6" 8 8 }, 9 9 "main": "jsesc.js", … … 46 46 "coveralls": "^2.11.6", 47 47 "grunt": "^0.4.5", 48 "grunt-cli": "^1.3.2", 48 49 "grunt-template": "^0.2.3", 49 50 "istanbul": "^0.4.2", 50 "mocha": " *",51 "mocha": "^5.2.0", 51 52 "regenerate": "^1.3.0", 52 "requirejs": "^2.1.22" 53 "requirejs": "^2.1.22", 54 "unicode-13.0.0": "0.8.0" 53 55 } 54 56 }
Note:
See TracChangeset
for help on using the changeset viewer.