{"name":"slashes","description":"Add or strip backslashes.","version":"2.0.2","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","prepublishOnly":"run-script test","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.2","dist":{"shasum":"c149dd3555bd236fdc3b43ec56e748e924425613","integrity":"sha512-68p+QkFAQQRetIUzNXAdktNJr8AYLxJukjBegYQz8F7VATsBJG621UYtY/vS2j9jerxdJ1k6Tc25K4DXEw1d5w==","tarball":"http://registry-npm.ywwl.com/slashes/download/slashes-2.0.2.tgz","fileCount":41,"unpackedSize":77347,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeWBJfCRA9TVsSAnZWagAAS0YP/1lxjTYAwDSol7R7fHTC\nk1AxMmgtup3EVVJE00Ctpg2TZFVf6QxXJavFhzbLAejfmEx3hc0Yv7E+1hTy\nh9z9Xrd0didUSx7d2ooNpdqcahDXmbxuSiBr+/LbSK24RLvHL3YRkRHUdg2E\nupXHKfK5Uyhq5XnzJT+gz9J6eEjZaU2pxNND8tJszfKwujc+2UzYs0uCJ1rn\nUm0NHhKlf1zL0xmefTTUGUmLusn4WMO990sVSkGWJf7vEmpbpJSSy0Opbqv7\nFEC61F8Eg/S5zU12SmMvQVkshQfm0FYl17bsFwLrZ2VD4XhpjQSAq4GZPlLD\nMrBadYmJK3JfKT+1s4xYJX0vZKNjLGl8y0GyVTB2KsV3h5U3i+aoapflqDMM\njpiYK0D3eRPNmBX9ti06vKrp5w0LbDQBeCpnKTrgTUhMIf5EP7iFLo5SqGhC\nS5Vmpr7M8+09gLu/34BrzvVGzlJrd2CkBPtmiAiB8yXHcqnkmmmWIyc+Zvr/\nHk3oXsWv6vKouPwEbtTbwCpk4a9nNifFaJ5D1TvXeQuq+ZmHlG+0OnD+08zA\nDYin4oabqnupvjUYZPqN+ofV7VjxS0CGT8i0+0rbpCYi9dLEWbL82gqwHd5Q\nzwDJ496A+/nzNXQffC6PR09prYhsLpxez8T9CE1o1BtWMSb3tPcvHtRualCR\n3ikM\r\n=aEd2\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBce9yoxayc9C1yw1KJTcxIPAYt7rxuoKydiOW0iGe6gAiA6frrSM8JHINAAJeI1HibnSQx9T68u3oyErMYwCYkBXw=="}],"size":19130,"noattachment":false,"key":"/slashes/-/slashes-2.0.2.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.2_1582830175458_0.014875691192381302"},"_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":1582830175579,"_cnpm_publish_time":1582830175579,"dist-tags":{"latest":"3.0.12"}}