jsesc/000755 001751 000177 0000000000 14522325161013643 5ustar00runner000000 000000 1452232516114522325161jsesc/LICENSE000644 001751 000177 0000002165 14522325161014654 0ustar00runner000000 000000 1452232516114522325161 MIT License Copyright (c) Microsoft Corporation. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE jsesc/README.md000644 001751 000177 0000001143 14522325161015125 0ustar00runner000000 000000 1452237444014522325161# Installation > `npm install --save @types/jsesc` # Summary This package contains type definitions for jsesc (https://github.com/mathiasbynens/jsesc). # Details Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/jsesc. ### Additional Details * Last updated: Tue, 07 Nov 2023 03:09:37 GMT * Dependencies: none # Credits These definitions were written by [Bart van der Schoor](https://github.com/Bartvds), [Lyanbin](https://github.com/Lyanbin), [Colin Reeder](https://github.com/vpzomtrrfrt), and [BendingBender](https://github.com/BendingBender). jsesc/index.d.ts000644 001751 000177 0000034051 14522325161015547 0ustar00runner000000 000000 1452232516114522325161export = jsesc; /** * This function takes a value and returns an escaped version of the value where any characters * that are not printable ASCII symbols are escaped using the shortest possible (but valid) * escape sequences for use in JavaScript strings. The first supported value type is strings. * Instead of a string, the value can also be an array, an object, a map, a set, or a buffer. * In such cases, jsesc returns a stringified version of the value where any characters that * are not printable ASCII symbols are escaped in the same way. * * @example * import jsesc = require('jsesc'); * * jsesc('Ich ♥ Bücher'); * // → 'Ich \\u2665 B\\xFCcher' * * jsesc('foo 𝌆 bar'); * // → 'foo \\uD834\\uDF06 bar' * * // Escaping an array * jsesc([ * 'Ich ♥ Bücher', 'foo 𝌆 bar' * ]); * // → '[\'Ich \\u2665 B\\xFCcher\',\'foo \\uD834\\uDF06 bar\']' * * // Escaping an object * jsesc({ * 'Ich ♥ Bücher': 'foo 𝌆 bar' * }); * // → '{\'Ich \\u2665 B\\xFCcher\':\'foo \\uD834\\uDF06 bar\'}' */ declare function jsesc(argument: any, opts?: jsesc.Opts): string; declare namespace jsesc { /** * A string representing the semantic version number. */ const version: string; interface Opts { /** * The value `'single'` for the `quotes` option means that any occurrences of `'` in the input string are * escaped as `\'`, so that the output can be used in a string literal wrapped in single quotes. If you want * to use the output as part of a string literal wrapped in double quotes, set the `quotes` option to * `'double'`. If you want to use the output as part of a template literal (i.e. wrapped in backticks), set * the `quotes` option to `'backtick'`. * * @default 'single' * * @example * import jsesc = require('jsesc'); * * jsesc('`Lorem` ipsum "dolor" sit \'amet\' etc.'); * // → 'Lorem ipsum "dolor" sit \\\'amet\\\' etc.' * * jsesc('`Lorem` ipsum "dolor" sit \'amet\' etc.', { * quotes: 'single' * }); * // → '`Lorem` ipsum "dolor" sit \\\'amet\\\' etc.' * // → "`Lorem` ipsum \"dolor\" sit \\'amet\\' etc." * * jsesc('`Lorem` ipsum "dolor" sit \'amet\' etc.', { * quotes: 'double' * }); * // → '`Lorem` ipsum \\"dolor\\" sit \'amet\' etc.' * // → "`Lorem` ipsum \\\"dolor\\\" sit 'amet' etc." * * jsesc('`Lorem` ipsum "dolor" sit \'amet\' etc.', { * quotes: 'backtick' * }); * // → '\\`Lorem\\` ipsum "dolor" sit \'amet\' etc.' * // → "\\`Lorem\\` ipsum \"dolor\" sit 'amet' etc." * // → `\\\`Lorem\\\` ipsum "dolor" sit 'amet' etc.` * * // This setting also affects the output for arrays and objects: * jsesc({ 'Ich ♥ Bücher': 'foo 𝌆 bar' }, { * quotes: 'double' * }); * // → '{"Ich \\u2665 B\\xFCcher":"foo \\uD834\\uDF06 bar"}' * * jsesc([ 'Ich ♥ Bücher', 'foo 𝌆 bar' ], { * quotes: 'double' * }); * // → '["Ich \\u2665 B\\xFCcher","foo \\uD834\\uDF06 bar"]' */ quotes?: "single" | "double" | "backtick" | undefined; /** * The value `'decimal'` for the `numbers` option means that any numeric values are represented using decimal * integer literals. Other valid options are `binary`, `octal`, and `hexadecimal`, which result in binary * integer literals, octal integer literals, and hexadecimal integer literals, respectively. * * @default 'decimal' * * @example * import jsesc = require('jsesc'); * * jsesc(42, { * numbers: 'binary' * }); * // → '0b101010' * * jsesc(42, { * numbers: 'octal' * }); * // → '0o52' * * jsesc(42, { * numbers: 'decimal' * }); * // → '42' * * jsesc(42, { * numbers: 'hexadecimal' * }); * // → '0x2A' */ numbers?: "binary" | "octal" | "decimal" | "hexadecimal" | undefined; /** * When enabled, the output is a valid JavaScript string literal wrapped in quotes. The type of quotes can be * specified through the `quotes` setting. * * @default false (disabled) * * @example * import jsesc = require('jsesc'); * * jsesc('Lorem ipsum "dolor" sit \'amet\' etc.', { * quotes: 'single', * wrap: true * }); * // → '\'Lorem ipsum "dolor" sit \\\'amet\\\' etc.\'' * // → "\'Lorem ipsum \"dolor\" sit \\\'amet\\\' etc.\'" * * jsesc('Lorem ipsum "dolor" sit \'amet\' etc.', { * quotes: 'double', * wrap: true * }); * // → '"Lorem ipsum \\"dolor\\" sit \'amet\' etc."' * // → "\"Lorem ipsum \\\"dolor\\\" sit \'amet\' etc.\"" */ wrap?: boolean | undefined; /** * When enabled, any astral Unicode symbols in the input are escaped using * [ECMAScript 6 Unicode code point escape sequences](https://mathiasbynens.be/notes/javascript-escapes#unicode-code-point) * instead of using separate escape sequences for each surrogate half. If backwards compatibility with ES5 * environments is a concern, don’t enable this setting. If the `json` setting is enabled, the value for the * `es6` setting is ignored (as if it was `false`). * * @default false (disabled) * * @example * import jsesc = require('jsesc'); * * // By default, the `es6` option is disabled: * jsesc('foo 𝌆 bar 💩 baz'); * // → 'foo \\uD834\\uDF06 bar \\uD83D\\uDCA9 baz' * * // To explicitly disable it: * jsesc('foo 𝌆 bar 💩 baz', { * es6: false * }); * // → 'foo \\uD834\\uDF06 bar \\uD83D\\uDCA9 baz' * * // To enable it: * jsesc('foo 𝌆 bar 💩 baz', { * es6: true * }); * // → 'foo \\u{1D306} bar \\u{1F4A9} baz' */ es6?: boolean | undefined; /** * When enabled, all the symbols in the output are escaped — even printable ASCII symbols. * This setting also affects the output for string literals within arrays and objects. * * @default false (disabled) * * @example * import jsesc = require('jsesc'); * * jsesc('lolwat"foo\'bar', { * escapeEverything: true * }); * // → '\\x6C\\x6F\\x6C\\x77\\x61\\x74\\"\\x66\\x6F\\x6F\\\'\\x62\\x61\\x72' * // → "\\x6C\\x6F\\x6C\\x77\\x61\\x74\\\"\\x66\\x6F\\x6F\\'\\x62\\x61\\x72" */ escapeEverything?: boolean | undefined; /** * When enabled, only a limited set of symbols in the output are escaped: * * - U+0000 `\0` * - U+0008 `\b` * - U+0009 `\t` * - U+000A `\n` * - U+000C `\f` * - U+000D `\r` * - U+005C `\\` * - U+2028 `\u2028` * - U+2029 `\u2029` * - whatever symbol is being used for wrapping string literals (based on the `quotes` option) * - [lone surrogates](https://esdiscuss.org/topic/code-points-vs-unicode-scalar-values#content-14) * * Note: with this option enabled, jsesc output is no longer guaranteed to be ASCII-safe. * * @default false (disabled) * * @example * import jsesc = require('jsesc'); * * jsesc('foo\u2029bar\nbaz©qux𝌆flops', { * minimal: false * }); * // → 'foo\\u2029bar\\nbaz©qux𝌆flops' */ minimal?: boolean | undefined; /** * When enabled, occurrences of [`` or `