Comparing version 3.4.10 to 3.4.11
@@ -5,4 +5,7 @@ import ts from "typescript"; | ||
function isArray(input: ts.Expression): ts.Expression; | ||
function isObject(input: ts.Expression, checkNull: boolean): ts.Expression; | ||
function isObject(input: ts.Expression, options: { | ||
checkNull: boolean; | ||
checkArray: boolean; | ||
}): ts.Expression; | ||
function isInstanceOf(input: ts.Expression, type: string): ts.Expression; | ||
} |
@@ -18,10 +18,13 @@ "use strict"; | ||
ExpressionFactory.isArray = isArray; | ||
function isObject(input, checkNull) { | ||
function isObject(input, options) { | ||
var conditions = [ | ||
typescript_1.default.factory.createStrictEquality(typescript_1.default.factory.createStringLiteral("object"), typescript_1.default.factory.createTypeOfExpression(input)), | ||
]; | ||
if (checkNull === true) | ||
if (options.checkNull === true) | ||
conditions.push(typescript_1.default.factory.createStrictInequality(typescript_1.default.factory.createNull(), input)); | ||
conditions.push(typescript_1.default.factory.createStrictEquality(typescript_1.default.factory.createFalse(), typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createIdentifier("Array.isArray"), undefined, [input]))); | ||
return conditions.reduce(function (x, y) { return typescript_1.default.factory.createLogicalAnd(x, y); }); | ||
if (options.checkArray === true) | ||
conditions.push(typescript_1.default.factory.createStrictEquality(typescript_1.default.factory.createFalse(), typescript_1.default.factory.createCallExpression(typescript_1.default.factory.createIdentifier("Array.isArray"), undefined, [input]))); | ||
return conditions.length === 1 | ||
? conditions[0] | ||
: conditions.reduce(function (x, y) { return typescript_1.default.factory.createLogicalAnd(x, y); }); | ||
} | ||
@@ -28,0 +31,0 @@ ExpressionFactory.isObject = isObject; |
@@ -268,3 +268,11 @@ "use strict"; | ||
{ | ||
expression: ExpressionFactory_1.ExpressionFactory.isObject(input, true), | ||
expression: ExpressionFactory_1.ExpressionFactory.isObject(input, { | ||
checkNull: true, | ||
checkArray: meta.objects.some(function (obj) { | ||
return obj.properties.every(function (prop) { | ||
return !prop.key.isSoleLiteral() || | ||
!prop.value.required; | ||
}); | ||
}), | ||
}), | ||
combined: false, | ||
@@ -271,0 +279,0 @@ }, |
@@ -77,3 +77,6 @@ "use strict"; | ||
if (obj._Is_simple()) | ||
return typescript_1.default.factory.createLogicalAnd(ExpressionFactory_1.ExpressionFactory.isObject(input, true), config.joiner.object((0, feature_object_entries_1.feature_object_entries)(config)(obj)(input))); | ||
return typescript_1.default.factory.createLogicalAnd(ExpressionFactory_1.ExpressionFactory.isObject(input, { | ||
checkNull: true, | ||
checkArray: false, | ||
}), config.joiner.object((0, feature_object_entries_1.feature_object_entries)(config)(obj)(input))); | ||
} | ||
@@ -80,0 +83,0 @@ return CheckerProgrammer_1.CheckerProgrammer.decode(project, config, importer)(input, target, explore, tags); |
@@ -315,3 +315,13 @@ "use strict"; | ||
type: "object", | ||
is: function () { return ExpressionFactory_1.ExpressionFactory.isObject(input, true); }, | ||
is: function () { | ||
return ExpressionFactory_1.ExpressionFactory.isObject(input, { | ||
checkNull: true, | ||
checkArray: meta.objects.some(function (obj) { | ||
return obj.properties.every(function (prop) { | ||
return !prop.key.isSoleLiteral() || | ||
!prop.value.required; | ||
}); | ||
}), | ||
}); | ||
}, | ||
value: function () { | ||
@@ -318,0 +328,0 @@ return meta.isParentResolved() === false && |
{ | ||
"name": "typia", | ||
"version": "3.4.10", | ||
"version": "3.4.11", | ||
"description": "Runtime type checkers and 5x faster JSON.stringify() function", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -21,3 +21,6 @@ import ts from "typescript"; | ||
input: ts.Expression, | ||
checkNull: boolean, | ||
options: { | ||
checkNull: boolean; | ||
checkArray: boolean; | ||
}, | ||
): ts.Expression { | ||
@@ -30,3 +33,3 @@ const conditions: ts.Expression[] = [ | ||
]; | ||
if (checkNull === true) | ||
if (options.checkNull === true) | ||
conditions.push( | ||
@@ -38,14 +41,17 @@ ts.factory.createStrictInequality( | ||
); | ||
conditions.push( | ||
ts.factory.createStrictEquality( | ||
ts.factory.createFalse(), | ||
ts.factory.createCallExpression( | ||
ts.factory.createIdentifier("Array.isArray"), | ||
undefined, | ||
[input], | ||
if (options.checkArray === true) | ||
conditions.push( | ||
ts.factory.createStrictEquality( | ||
ts.factory.createFalse(), | ||
ts.factory.createCallExpression( | ||
ts.factory.createIdentifier("Array.isArray"), | ||
undefined, | ||
[input], | ||
), | ||
), | ||
), | ||
); | ||
); | ||
return conditions.reduce((x, y) => ts.factory.createLogicalAnd(x, y)); | ||
return conditions.length === 1 | ||
? conditions[0]! | ||
: conditions.reduce((x, y) => ts.factory.createLogicalAnd(x, y)); | ||
} | ||
@@ -52,0 +58,0 @@ |
@@ -418,6 +418,12 @@ import ts from "typescript"; | ||
{ | ||
expression: ExpressionFactory.isObject( | ||
input, | ||
true, | ||
), | ||
expression: ExpressionFactory.isObject(input, { | ||
checkNull: true, | ||
checkArray: meta.objects.some((obj) => | ||
obj.properties.every( | ||
(prop) => | ||
!prop.key.isSoleLiteral() || | ||
!prop.value.required, | ||
), | ||
), | ||
}), | ||
combined: false, | ||
@@ -424,0 +430,0 @@ }, |
@@ -109,3 +109,6 @@ import ts from "typescript"; | ||
return ts.factory.createLogicalAnd( | ||
ExpressionFactory.isObject(input, true), | ||
ExpressionFactory.isObject(input, { | ||
checkNull: true, | ||
checkArray: false, | ||
}), | ||
config.joiner.object( | ||
@@ -112,0 +115,0 @@ feature_object_entries(config as any)(obj)( |
@@ -342,3 +342,13 @@ import ts from "typescript"; | ||
type: "object", | ||
is: () => ExpressionFactory.isObject(input, true), | ||
is: () => | ||
ExpressionFactory.isObject(input, { | ||
checkNull: true, | ||
checkArray: meta.objects.some((obj) => | ||
obj.properties.every( | ||
(prop) => | ||
!prop.key.isSoleLiteral() || | ||
!prop.value.required, | ||
), | ||
), | ||
}), | ||
value: () => | ||
@@ -345,0 +355,0 @@ meta.isParentResolved() === false && |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
1197496
21399