@sinclair/typebox
Advanced tools
@@ -28,2 +28,9 @@ import { ValueErrorIterator } from '../errors/index'; | ||
| } | ||
| export declare namespace StringUtil { | ||
| /** | ||
| * Unquoted string values are embedded into single-quote string. This | ||
| * function ensures that embedded string cannot be escaped. | ||
| */ | ||
| function EscapeSingleQuote(value: string): string; | ||
| } | ||
| export declare class TypeCompilerUnknownTypeError extends TypeBoxError { | ||
@@ -30,0 +37,0 @@ readonly schema: TSchema; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.TypeCompiler = exports.Policy = exports.TypeCompilerTypeGuardError = exports.TypeCompilerUnknownTypeError = exports.TypeCheck = void 0; | ||
| exports.TypeCompiler = exports.Policy = exports.TypeCompilerTypeGuardError = exports.TypeCompilerUnknownTypeError = exports.StringUtil = exports.TypeCheck = void 0; | ||
| const index_1 = require("../value/transform/index"); | ||
@@ -94,2 +94,16 @@ const index_2 = require("../errors/index"); | ||
| // ------------------------------------------------------------------ | ||
| // StringUtil | ||
| // ------------------------------------------------------------------ | ||
| var StringUtil; | ||
| (function (StringUtil) { | ||
| /** | ||
| * Unquoted string values are embedded into single-quote string. This | ||
| * function ensures that embedded string cannot be escaped. | ||
| */ | ||
| function EscapeSingleQuote(value) { | ||
| return JSON.stringify(value).slice(1, -1).replace(/'/g, "\\'"); | ||
| } | ||
| StringUtil.EscapeSingleQuote = EscapeSingleQuote; | ||
| })(StringUtil || (exports.StringUtil = StringUtil = {})); | ||
| // ------------------------------------------------------------------ | ||
| // MemberExpression | ||
@@ -116,3 +130,3 @@ // ------------------------------------------------------------------ | ||
| function EscapeHyphen(key) { | ||
| return key.replace(/'/g, "\\'"); | ||
| return StringUtil.EscapeSingleQuote(key); | ||
| } | ||
@@ -150,3 +164,3 @@ function Encode(object, key) { | ||
| function Escape(content) { | ||
| return content.replace(/'/g, "\\'"); | ||
| return StringUtil.EscapeSingleQuote(content); | ||
| } | ||
@@ -153,0 +167,0 @@ LiteralString.Escape = Escape; |
@@ -28,2 +28,9 @@ import { ValueErrorIterator } from '../errors/index.mjs'; | ||
| } | ||
| export declare namespace StringUtil { | ||
| /** | ||
| * Unquoted string values are embedded into single-quote string. This | ||
| * function ensures that embedded string cannot be escaped. | ||
| */ | ||
| function EscapeSingleQuote(value: string): string; | ||
| } | ||
| export declare class TypeCompilerUnknownTypeError extends TypeBoxError { | ||
@@ -30,0 +37,0 @@ readonly schema: TSchema; |
@@ -89,2 +89,16 @@ import { TransformEncode, TransformDecode, HasTransform, TransformDecodeCheckError, TransformEncodeCheckError } from '../value/transform/index.mjs'; | ||
| // ------------------------------------------------------------------ | ||
| // StringUtil | ||
| // ------------------------------------------------------------------ | ||
| export var StringUtil; | ||
| (function (StringUtil) { | ||
| /** | ||
| * Unquoted string values are embedded into single-quote string. This | ||
| * function ensures that embedded string cannot be escaped. | ||
| */ | ||
| function EscapeSingleQuote(value) { | ||
| return JSON.stringify(value).slice(1, -1).replace(/'/g, "\\'"); | ||
| } | ||
| StringUtil.EscapeSingleQuote = EscapeSingleQuote; | ||
| })(StringUtil || (StringUtil = {})); | ||
| // ------------------------------------------------------------------ | ||
| // MemberExpression | ||
@@ -111,3 +125,3 @@ // ------------------------------------------------------------------ | ||
| function EscapeHyphen(key) { | ||
| return key.replace(/'/g, "\\'"); | ||
| return StringUtil.EscapeSingleQuote(key); | ||
| } | ||
@@ -145,3 +159,3 @@ function Encode(object, key) { | ||
| function Escape(content) { | ||
| return content.replace(/'/g, "\\'"); | ||
| return StringUtil.EscapeSingleQuote(content); | ||
| } | ||
@@ -148,0 +162,0 @@ LiteralString.Escape = Escape; |
+1
-1
| { | ||
| "name": "@sinclair/typebox", | ||
| "version": "0.34.50", | ||
| "version": "0.34.51", | ||
| "description": "Json Schema Type Builder with Static Type Resolution for TypeScript", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
1910743
0.09%29432
0.12%