{"name":"slashes","description":"Add or strip backslashes.","version":"2.0.0","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.0","dist":{"shasum":"7beb2fab53c8cc7768013320b476dd28362a71e3","integrity":"sha512-mVqFieOpMTyxw00fadNql79jgZviLhECubZ9mprbipyiY38ughdq4sYlE7CYleotmo8YgwEDK0nOI0MHlH2qiw==","tarball":"http://registry-npm.ywwl.com/slashes/download/slashes-2.0.0.tgz","fileCount":41,"unpackedSize":77255,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeWBEUCRA9TVsSAnZWagAA6i8QAI+DClsm/Wio5GXwvixE\n+rZkh8Jhv3NjZejN9XHNs9nGcYQEWBBpqMqLvFbfBiBfocB8EkCxbCE0nwjl\nKfzwPt3D+t0ZTqgDCvd2oPJ0lubzlWe4qNEsX+aipjvj7XJ8aLtD3QbtEY5J\nSdsYFhhvgp4ynluaMvFj3Q3ZOwdiCxUXFBWYRGPd/z10EyzrZ1mXhcpzo8uj\nuM/Mh1xvz6NIAn3m9/xfUYC1hJEMyDHy2mGXoOSFVzBdTIDg4Y79c0kFryVn\nd25FIl0OyIb977IHGL+prqLvRZ1TwZjB/UUA3CxE0kH9c6I2uq/3n1/oKof7\nB/UoJZqIgj0GZyu+Fc1FSsgflXStRrYU6cl0ZSJQBubi8wZ4ofLDFYQuZG1k\nygKHRYOVevcfjaFjbBG9pvzUtt7zrHYPg93ZRnPnCxMQEz76fgQtor8xDRTP\nyAnDUMKIudCiHlk2pda7pNjB5SovyEwv2pl4ObOF5kXSoDKXS3M8DCt6DcvT\nlzE5NNT/rOQ5Z+D4EcPSYy4SdX3dg2Z4lFuYXLJ7ypyaF44MmrE3/OI6Mlrl\npEPixOe7oxlIF13zuEzH6ROfKojwcRQbr2rn8ND01HBsa5MsFHzj28RKUwiA\nEssYm5WLScpcKmQ6z/yUhvsu+OzMm4cmgDA8lm24qVh0V6ncUsQyk2MOFGPU\n/wG2\r\n=bB7o\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIG9/ZggKLlYFcDaOB2KSv6H1gmLHn3ZcQ4poJ8vYD0SZAiA5Qd78FZCLJ8i/DB/hm2kIUe9t+3t3/3IoalXoLHulKA=="}],"size":19108,"noattachment":false,"key":"/slashes/-/slashes-2.0.0.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.0_1582829843656_0.31829743510727226"},"_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":1582829843770,"_cnpm_publish_time":1582829843770,"dist-tags":{"latest":"3.0.12"}}