@sinclair/typebox
Advanced tools
@@ -24,2 +24,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 { | ||
@@ -26,0 +33,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"); | ||
@@ -85,2 +85,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 | ||
@@ -107,3 +121,3 @@ // ------------------------------------------------------------------ | ||
| function EscapeHyphen(key) { | ||
| return key.replace(/'/g, "\\'"); | ||
| return StringUtil.EscapeSingleQuote(key); | ||
| } | ||
@@ -141,3 +155,3 @@ function Encode(object, key) { | ||
| function Escape(content) { | ||
| return content.replace(/'/g, "\\'"); | ||
| return StringUtil.EscapeSingleQuote(content); | ||
| } | ||
@@ -144,0 +158,0 @@ LiteralString.Escape = Escape; |
@@ -24,2 +24,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 { | ||
@@ -26,0 +33,0 @@ readonly schema: TSchema; |
@@ -80,2 +80,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 | ||
@@ -102,3 +116,3 @@ // ------------------------------------------------------------------ | ||
| function EscapeHyphen(key) { | ||
| return key.replace(/'/g, "\\'"); | ||
| return StringUtil.EscapeSingleQuote(key); | ||
| } | ||
@@ -136,3 +150,3 @@ function Encode(object, key) { | ||
| function Escape(content) { | ||
| return content.replace(/'/g, "\\'"); | ||
| return StringUtil.EscapeSingleQuote(content); | ||
| } | ||
@@ -139,0 +153,0 @@ LiteralString.Escape = Escape; |
+2
-2
| { | ||
| "name": "@sinclair/typebox", | ||
| "version": "0.32.35", | ||
| "version": "0.32.36", | ||
| "description": "Json Schema Type Builder with Static Type Resolution for TypeScript", | ||
@@ -15,3 +15,3 @@ "keywords": [ | ||
| "type": "git", | ||
| "url": "https://github.com/sinclairzx81/typebox" | ||
| "url": "https://github.com/sinclairzx81/sinclair-typebox" | ||
| }, | ||
@@ -18,0 +18,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
23362
0.15%1376033
-0.01%