{"name":"slashes","description":"Add or remove backslashes (escape or unescape).","author":{"name":"Chris Ackerman","email":"chris@topher.land"},"repository":{"type":"git","url":"git+https://github.com/Shakeskeyboarde/slashes.git"},"license":"ISC","version":"3.0.11","directories":{"lib":"lib"},"keywords":["escape","unescape","encode","decode","strip","json","php"],"type":"module","types":"lib/types/index.d.ts","main":"lib/cjs/index.js","module":"lib/esm/index.js","exports":{".":{"types":"./lib/types/index.d.ts","require":"./lib/cjs/index.js","default":"./lib/esm/index.js"}},"sideEffects":false,"scripts":{"test":"rc npm-test -o","prepack":"del-cli *.tgz && rc npm-prepack","modernize":"npx npm-check-updates -i --format group"},"devDependencies":{"@types/jest":"^29.2.4","del-cli":"^5.0.0","eslint":"^8.30.0","eslint-config-rational":"^2.0.7","jest":"^29.3.1","jest-environment-jsdom":"^29.3.1","parallel-rc":"^1.0.12","prettier":"^2.8.1","ts-jest":"^29.0.3","typescript":"^4.9.4"},"bugs":{"url":"https://github.com/Shakeskeyboarde/slashes/issues"},"homepage":"https://github.com/Shakeskeyboarde/slashes#readme","_id":"slashes@3.0.11","_integrity":"sha512-1I94c6CA8NqNwcXtE7i5he/xvHKdF4RgKv/tdIFRTW62DaGFdsxrAEaRjOHtwSfS3Ids8H6sU6z+W0Zc2tOwcw==","_resolved":"/home/runner/work/slashes/slashes/slashes-3.0.11.tgz","_from":"file:slashes-3.0.11.tgz","_nodeVersion":"19.3.0","_npmVersion":"9.2.0","dist":{"integrity":"sha512-1I94c6CA8NqNwcXtE7i5he/xvHKdF4RgKv/tdIFRTW62DaGFdsxrAEaRjOHtwSfS3Ids8H6sU6z+W0Zc2tOwcw==","shasum":"9979147576dc77b890b740a7ecb422698b26f82a","tarball":"http://registry-npm.ywwl.com/slashes/download/slashes-3.0.11.tgz","fileCount":39,"unpackedSize":25722,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFip/cPrckx5QzSwOIyOtDM3oovmOYBZwZGh6x6k+nifAiBVq4KbIKqEtssAYetC82ZfwwzQkw32OvlqRGkPlf771g=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjnsewACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmo2nw//aDtRVC0eDCl1H35hmSpsHEJLRsMpuRmZhuyBsGuXD2jCWaq0\r\n9L6BiZ4RJbWMIQDoaKp0KuliXximV5A2L6coEQ6InzPvfkm1lJDfhUuZ5D/1\r\nLH4aBeNUhr0NRoLHvSJphulDRDY9Ie4lJZLHNo9EXzZqF3VLa7NhlWIOX32d\r\nbuPoGguUSoT0YOx6t6N2HkPyiU4cB3G7WjWJ4yc6I+QIUnvGOaD77L2qKz1y\r\nH4YFmvKBUTlWRTKymcO8F0vi2XEPB+lFKG2qv0KqKoUK6505gNDs9uFmzeYf\r\nGHqETtIIovQ49VvWP4GnpPLV1d3gAqA21EBSrwVML6EP4EqQQ9WpL2vXJIjm\r\ntRXIJJTnguzQOkDS6v3bzcJa83O4sMRWHO7lBKD/INNGRJMrUvuSy5UT4TAs\r\njFMyWwqtPfn4P+pH/OAdyCYCC13sXU5yrbiQMPEjyV1G4qNUtViNNfGTraKd\r\ne9nHOmzL2UPpH4XP+cneyKNoNEoapA3xTlze9BkPJtZgLTMZGHLnu1XZ5HlV\r\nt33wFTF0zpjaZ6ClHp8aPtz2OCpG1hz0BBXOK8aSSuYN7vJZdwos5pfBDFF+\r\nTz8Q2eAs9/h/XqBKXc0sHJasN4p7i9PWTQQJ3yhNtXu+9NwC8qzGwvpowzo5\r\nSP+ZJAilDoOW8R+azLBED4vMhdqSoe/iqtw=\r\n=F3Z9\r\n-----END PGP SIGNATURE-----\r\n","size":6585,"noattachment":false,"key":"/slashes/-/slashes-3.0.11.tgz"},"_npmUser":{"name":"chrisackerman","email":"chris@topher.land"},"maintainers":[{"name":"chrisackerman","email":"chris@topher.land"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/slashes_3.0.11_1671350191860_0.09567470923453358"},"_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":1671350192007,"_cnpm_publish_time":1671350192007,"dist-tags":{"latest":"3.0.12"}}