Comparing version 3.0.3 to 3.0.4
{ | ||
"name": "slashes", | ||
"description": "Add or remove backslashes (escape or unescape).", | ||
"version": "3.0.3", | ||
"version": "3.0.4", | ||
"license": "ISC", | ||
@@ -6,0 +6,0 @@ "author": { |
@@ -12,3 +12,3 @@ # Slashes | ||
# Getting Started | ||
# Getting started | ||
@@ -22,3 +22,3 @@ ```ts | ||
## Adding Slashes | ||
## Adding slashes | ||
@@ -47,2 +47,4 @@ By default, `addSlashes` will escape the following JSON-unsafe characters. | ||
### Custom encoding | ||
Escape encoding can be customized using the `getEscaped` option. | ||
@@ -63,4 +65,10 @@ | ||
## Removing Slashes | ||
A custom `getEscaped` receives one character (may be unicode) 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). | ||
```ts | ||
getEscaped(character: string): boolean | `\\${string}` | '' | ||
``` | ||
## Removing slashes | ||
The `removeSlashes` function will _always_ remove one layer of slashes. | ||
@@ -83,2 +91,4 @@ | ||
### Custom decoding | ||
Although it should generally not be necessary because all escapes are automatically handled, escape decoding can be customized using the `getUnescaped` option. | ||
@@ -94,2 +104,10 @@ | ||
The `getUnescapedAny` implementation is the only one included. | ||
Included `getUnescaped` implementations: | ||
- `getUnescapedAny` - Decode _ANY_ Javascript supported escape sequence. | ||
A 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 standard decoding, `false` to treat the sequence as invalid (only removes the leading backslash), or a string to provide a custom decoded value for the escape sequence. | ||
```ts | ||
getUnescaped(sequence: `\\${string}`, code: number | null): boolean | string | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
40878
108