{"name":"slashes","description":"Add or strip backslashes.","version":"2.0.1","license":"ISC","author":{"name":"Chris Ackerman","email":"chris@topher.land"},"repository":{"type":"git","url":"git://github.com:ChrisAckerman/slashes"},"main":"lib-commonjs/index.js","module":"lib/index.js","scripts":{"start":"run-script build:commonjs && node ./lib-commonjs/repl.js","test":"run-script eslint && run-script tsc --noEmit && run-script jest","clean":"del-cli lib lib-commonjs dist css coverage && jest --clearCache","build":"run-script clean && run-script build:js && run-script build:commonjs && run-script build:d.ts && run-script build:cleanup","build:cleanup":"del-cli \"lib?(-*)/**/@(__demo__|__snapshots__|?(*.)test.@(ts|tsx|js|jsx))\"","build:commonjs":"cross-env NODE_ENV=production BABEL_MODULES=cjs babel src --out-dir lib-commonjs --extensions .ts,.tsx,.js,.jsx --copy-files --source-maps","build:d.ts":"run-script tsc --emitDeclarationOnly && run-script tsc --emitDeclarationOnly --outDir lib-commonjs","build:js":"cross-env NODE_ENV=production BABEL_MODULES=false babel src --out-dir lib --extensions .ts,.tsx,.js,.jsx --copy-files --source-maps","eslint":"eslint \"src/**/*.{js,jsx,ts,tsx}\" --ignore-pattern \"/__demo__/\" --no-error-on-unmatched-pattern","jest":"cross-env NODE_ENV=test jest --passWithNoTests","prepack":"run-script build","reformat":"run-script eslint --fix --quiet","tsc":"tsc"},"devDependencies":{"@babel/cli":"^7.8.4","@babel/core":"^7.8.4","@babel/generator":"^7.8.4","@babel/plugin-proposal-class-properties":"^7.8.3","@babel/plugin-proposal-decorators":"^7.8.3","@babel/plugin-proposal-object-rest-spread":"^7.8.3","@babel/plugin-transform-typescript":"^7.8.3","@babel/preset-env":"^7.8.4","@types/jest":"^25.1.3","@types/node":"^13.7.4","@typescript-eslint/eslint-plugin":"^2.21.0","@typescript-eslint/parser":"^2.21.0","@xornot/run-script":"^0.1.2","babel-core":"^7.0.0-bridge.0","babel-jest":"^25.1.0","babel-plugin-const-enum":"^0.0.5","cross-env":"^7.0.0","del-cli":"^3.0.0","eslint":"^6.8.0","eslint-config-prettier":"^6.10.0","eslint-plugin-prettier":"^3.1.2","eslint-plugin-react":"^7.18.3","jest":"^25.1.0","prettier":"^1.19.1","typescript":"^3.8.2"},"keywords":["escape","unescape","slashes","php","strip","sequence","encode","decode","backslash","slash","unicode","ascii","utf8","utf16","control","char","character","unprintable","printable","codepoint","codeblock","supplemental","supplementary"],"_id":"slashes@2.0.1","dist":{"shasum":"21214fa7780478b3b9d68b2e84d32bdafc78b478","integrity":"sha512-joc/nsBbazoBlJxv9mVOLnAPPDN04H3v8bx6rChkNfDITMpYeX4FbzNsbND3bemK+OtLiv/b59Oj7yIRbq3gbw==","tarball":"http://registry-npm.ywwl.com/slashes/download/slashes-2.0.1.tgz","fileCount":41,"unpackedSize":77306,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeWBHOCRA9TVsSAnZWagAAl1oQAIWTRNNIN/KRDepNyP5i\nc3D96C9Y1Q3K5eLFewn5VuRS8trA+pGo6B8/Q5h2Y+AmIVbProwSp1MZh6Ti\nmHMjo1fkQgzsq/Pfu/2qcLKFdlRG5XD2wPR2ws7dahipkHW1lZMLWoXDmAk1\nZ1fkNCPxovgxrk9h1HYXoIXnpnHd4nzBZzklE/zezRDUSp+J8ZMy4NyDOfbZ\nvkC0V+dFI9KLFwybv2EN4TdPHLRieSHQlZ6HsD+qNv+lt67m7pH1s53avU8g\nRo3c7uOUlX5zLLGz4oT7OIMTsxeCpKvoiMqUQOcioFUmrJ1xNzjcGcJZ22kA\nyqpSFwAkvH0z9tyo0SunoRgT2gbNcrdzVyD2nxrwZYCqm/4o5yGA02q9qOnr\n+CMloRYf8bZpBClfyHsU29lZD/UleXLZn3P52SRP9SPYq7wyT2kc1qPSVbQW\nohmvfGY0ZnFtejQEc+qstP8onIRktaVumXAjbIwhNN+nnXYiKh1gnOWMNLK9\n19h0J15YbwCAvFs6oAijyMtkNrWLNlbPsWuBLpa6ucDYlsInZgPuKLVauvwk\nYfUpSOVZcThFiBMK25Kp0C6H9OkH81v0a5OH3zIyPbhwN67r75xT3zWAwkvK\nat/Y7mHu4xQyE1otvga0DuMI5xUvYe4QZHto3W6gXiEDbByq5D+TNUkVEZ56\nelQf\r\n=rQIg\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC/oiZmc4fOrnxwuIfzrr0ZoNI68DFdyVAGF99ymdvYRwIgf+Xvua6EGqwa+Vkz2U4ND8m3eaJ8fih/eMTvmK6z0Co="}],"size":19127,"noattachment":false,"key":"/slashes/-/slashes-2.0.1.tgz"},"maintainers":[{"email":"chris+npm.staging@topher.land","name":"bluejeansandrain"}],"_npmUser":{"name":"chrisackerman","email":"chris@topher.land"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/slashes_2.0.1_1582830029815_0.3259767582609936"},"_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":1582830029938,"_cnpm_publish_time":1582830029938,"dist-tags":{"latest":"3.0.12"}}