{"name":"slashes","description":"Add or remove backslashes (escape or unescape).","version":"3.0.4","license":"ISC","author":{"name":"Chris Ackerman","email":"chris@topher.land"},"repository":{"type":"git","url":"git+https://github.com/Shakeskeyboarde/slashes.git"},"types":"lib/commonjs/index.d.ts","module":"./lib/module/index.js","main":"lib/commonjs/index.js","exports":{"types":"./lib/commonjs/index.d.ts","import":"./lib/module/index.js","default":"./lib/commonjs/index.js"},"sideEffects":false,"scripts":{"test":"del-cli out && tsc --noEmit && eslint --max-warnings=0 src && jest --no-cache","build":"del-cli lib && tsc -p tsconfig.build-commonjs.json && tsc -p tsconfig.build-module.json && tsc -p tsconfig.build-types.json && check-es-compat lib/commonjs","clean":"del-cli lib out","modernize":"npm-check-updates -u -x @types/node","coveralls":"cat ./out/coverage/lcov.info | coveralls"},"devDependencies":{"@babel/core":"^7.17.9","@babel/preset-env":"^7.16.11","@types/jest":"^27.4.1","check-es-compat":"^2.0.0","coveralls":"^3.1.1","del-cli":"^4.0.1","eslint":"^8.14.0","eslint-config-rational":"^0.1.7","jest":"^27.5.1","npm-check-updates":"^12.5.9","prettier":"^2.6.2","ts-jest":"^27.1.4","typescript":"^4.6.3"},"gitHead":"9c3864b67263b76ae727bde4124b1722c2ec05b1","bugs":{"url":"https://github.com/Shakeskeyboarde/slashes/issues"},"homepage":"https://github.com/Shakeskeyboarde/slashes#readme","_id":"slashes@3.0.4","_nodeVersion":"16.15.0","_npmVersion":"8.5.5","dist":{"integrity":"sha512-HMr95bVWizFn93tJsp7IjW/ti2naZMSvJ8xRdOPuxdFF3A4529ELQY9kKeC+DLBLSG7qvoUBs0GK+VOulePWXg==","shasum":"e8c47a466fc5eab9762deacf5f92ed28069294f6","tarball":"http://registry-npm.ywwl.com/slashes/download/slashes-3.0.4.tgz","fileCount":73,"unpackedSize":40878,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDYVEQOahTZmjTZsQJnxpYfKNNYKMU7UqMXKMg5X9sRBAiEAvM+dZwK/ruNA//+0+oV5UGW3M6gaQ1njQsezTISZMzY="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiaNinACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoiyxAAmYXZYFZ7rl5sizdLfnsr3QDgFIHovwe+Isw/Wij+d8pAcCOG\r\nFsQ9ZpIzIcleFMODOtUWt3HZ7wgtrE8LhH/snjZC6eVJ6JyVfqk7xLrtF6TT\r\nM6nE4xkAFxx9Y9rtYZboThbla9HmLUSPWxqvtPMRiK3QWVa6ENx8hdnK0ysq\r\nXFdk8PXFlMfjN0p978Wx52qu8xvVeDcLoJjoZ2VlrB227KgibHfjnNWisfCm\r\nPupgAYPHzvmR/P+nFySCMa8uXMKka0pURW52cWnr5KXJnJtlwuDrwTf+RHYV\r\nkHkxtIXYFeO17M8lnzRBBJI2PdQs63Zp9NaUZIS2OeCVaqx50smLBhzp5uQU\r\n1eR7geLAEZt8/UFsm7IsqO2MIaxxchH/+9qnbtSFJ3LFaz8g+GW9GZthc6CN\r\no6cRXUMwJ8CETL2x9Y3FCa2Wrbjg75ssWXGJrmSGFjMHpE7BWfPIJlKsr9cz\r\nmUXiu1sC92/ZAqSYW7lR3Rh+rQepoK1JY/MkRw6LgNs9YvUze0Otnb27k6ae\r\ncbKarwpXJ7q/P/+XQEqEkt9tpL2EOj8lCIC7vlHeNYEud5qFKmsadwtCXn4G\r\nsPo+IqmEafg77L/R5iF7xbYR88Zr+pMdLqQLaWh6bmWUBBSO5bUTTmIhTidu\r\nBathcX4gPAmj2kssfATDh6l7hWdKZo3UIjQ=\r\n=ZQbQ\r\n-----END PGP SIGNATURE-----\r\n","size":10701,"noattachment":false,"key":"/slashes/-/slashes-3.0.4.tgz"},"_npmUser":{"name":"chrisackerman","email":"chris@topher.land"},"directories":{},"maintainers":[{"name":"chrisackerman","email":"chris@topher.land"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/slashes_3.0.4_1651038375325_0.44535628450842646"},"_hasShrinkwrap":false,"readme":"# Slashes\n\nAdd or remove backslashes (escape or unescape).\n\n[![build](https://github.com/Shakeskeyboarde/slashes/actions/workflows/build.yml/badge.svg)](https://github.com/Shakeskeyboarde/slashes/actions/workflows/build.yml)\n[![codecov](https://codecov.io/gh/Shakeskeyboarde/slashes/branch/main/graph/badge.svg?token=E2VYI8XJLB)](https://codecov.io/gh/Shakeskeyboarde/slashes)\n\n# Getting started\n\n```ts\nimport { addSlashes, removeSlashes } from 'slashes';\n\naddSlashes(`foo\\nbar`); // \"foo\\\\nbar\"\nremoveSlashes(`foo\\\\nbar`); // \"foo\\nbar\"\n```\n\n## Adding slashes\n\nBy default, `addSlashes` will escape (encode) the following characters.\n\n- Backspace (`\\b`)\n- Form Feed (`\\f`)\n- Newline (`\\n`)\n- Carriage Return (`\\r`)\n- Horizontal Tab (`\\t`)\n- Vertical Tab (`\\v`)\n- Null (`\\0`)\n- Double Quote (`\"`)\n- Backslash (`\\`)\n\n```ts\nconst escaped = addSlashes(`\\n`); // \"\\\\n\"\n```\n\nThe default character set are characters which cannot be used between double quotes in a JSON string.\n\n```ts\nconst validJsonString = `{ \"key\": \"${escaped}\" }`;\n```\n\n### Custom encoding\n\nEscape encoding can be customized using the `getEscaped` option.\n\nThe following is the default, equivalent to not setting the `getEscaped` option.\n\n```ts\nimport { getEscapedJsonUnsafe } from 'slashes';\n\naddSlashes('...', { getEscaped: getEscapedJsonUnsafe });\n```\n\nIncluded `getEscaped` implementations:\n\n- `getEscapedJsonUnsafe` - (Default) Encode characters which cannot be used between double quotes in a JSON string.\n- `getEscapedAny` - Encode _ANY_ character to a single letter (eg. `\\n`) or an ES5 Unicode (eg. `\\u0100`) escape sequence.\n\nA custom `getEscaped` receives one character (may be Unicode > 2 bytes) at a time. It can return `true` to use the standard escape sequence, `false` to not escape the character, or a string to provide a custom escape sequence (must begin with a backslash and be at least 2 characters long).\n\n```ts\ngetEscaped(character: string): boolean | `\\\\${string}`\n```\n\n## Removing slashes\n\nBe default, `removeSlashes` will unescape (decode) all Javascript escape sequences.\n\n```ts\n// Handles letter escapes\nremoveSlashes(`\\\\n`); // \"\\n\"\n// Handles ES6 Unicode Code Point escapes\nremoveSlashes('\\\\u{a}'); // \"\\n\"\n// Handles ES5 Unicode escapes\nremoveSlashes('\\u000a'); // \"\\n\"\n// Handles hex escapes\nremoveSlashes('\\x0a'); // \"\\n\"\n// Handles octal escapes\nremoveSlashes('\\12'); // \"\\n\"\n// Handles any other backslash sequence by removing the leading slash\nremoveSlashes(`\\\\a`); // \"a\"\n```\n\n### Custom decoding\n\nAlthough it should generally not be necessary because all escapes are handled by default, escape decoding can be customized using the `getUnescaped` option.\n\nThe following is the default, equivalent to not setting the `getUnescaped` option.\n\n```ts\nimport { getUnescapedAny } from 'slashes';\n\nremoveSlashes('...', { getUnescaped: getUnescapedAny });\n```\n\nIncluded `getUnescaped` implementations:\n\n- `getUnescapedAny` - Decode _ANY_ Javascript supported escape sequence.\n\nA custom `getUnescaped` implementation receives the escape sequence as the first argument, and the escape sequence code point number or `null` (for single letter escape sequences) as the second argument. It can return `true` to use the standard decoding, `false` to treat the sequence as invalid (only removes the leading backslash), or a string (non-zero length) to provide a custom decoded value for the escape sequence.\n\n```ts\ngetUnescaped(sequence: `\\\\${string}`, code: number | null): boolean | string\n```\n","publish_time":1651038375529,"_cnpm_publish_time":1651038375529,"dist-tags":{"latest":"3.0.12"}}