{"name":"slashes","version":"1.0.1","description":"Add or strip backslashes.","main":"slashes.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git://github.com:ChrisAckerman/node-slashes"},"keywords":["add","strip","remove","slash","backslash","escape","unescape","php"],"author":{"name":"Chris Ackerman","email":"bluejeansandrain@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/ChrisAckerman/node-slashes/issues"},"homepage":"https://github.com/ChrisAckerman/node-slashes","gitHead":"54229e23914a7267414aca26fce7334126b910f8","_id":"slashes@1.0.1","_shasum":"cb9971a53bf6f973ad09f1c071d62e88499fabd6","_from":".","_npmVersion":"1.4.23","_npmUser":{"name":"bluejeansandrain","email":"bluejeansandrain@gmail.com"},"maintainers":[{"name":"bluejeansandrain","email":"bluejeansandrain@gmail.com"}],"dist":{"shasum":"cb9971a53bf6f973ad09f1c071d62e88499fabd6","tarball":"http://registry-npm.ywwl.com/slashes/download/slashes-1.0.1.tgz","integrity":"sha512-5o4rnqvcnaOVz/ijxPAzLLzsuubz39+zmndsRQap2SqcY+Kh2jS1VWiuxczul9XYoc5k/JgEqZuXpZFyS2PjGA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHf0MuLNG/s8ilbtHrpJ/G8LBdhznucbWV2FLYdQC6xsAiAmWMIEzrtmppsCUf48HIdH9AYaH+fyg7Pr2Rr+R0NFNQ=="}],"size":2384,"noattachment":false,"key":"/slashes/-/slashes-1.0.1.tgz"},"directories":{},"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":1416956341669,"_cnpm_publish_time":1416956341669,"dist-tags":{"latest":"3.0.12"}}