Socket
Socket
Sign inDemoInstall

pip-services3-commons-node

Package Overview
Dependencies
3
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.0.5 to 3.0.6

6

obj/src/reflect/TypeMatcher.d.ts

@@ -29,2 +29,3 @@ import { TypeCode } from '../convert/TypeCode';

* @param actualType an actual type to match.
* @param actualValue an optional value to match its type to the expected one.
* @returns true if types are matching and false if they don't.

@@ -35,3 +36,3 @@ *

*/
static matchType(expectedType: any, actualType: TypeCode): boolean;
static matchType(expectedType: any, actualType: TypeCode, actualValue?: any): boolean;
/**

@@ -50,5 +51,6 @@ * Matches expected type to a type of a value.

* @param actualType an actual type to match defined by type code.
* @param actualValue an optional value to match its type to the expected one.
* @returns true if types are matching and false if they don't.
*/
static matchTypeByName(expectedType: string, actualType: TypeCode): boolean;
static matchTypeByName(expectedType: string, actualType: TypeCode, actualValue?: any): boolean;
}

@@ -8,2 +8,3 @@ "use strict";

var TypeConverter_1 = require("../convert/TypeConverter");
var convert_1 = require("../convert");
/**

@@ -44,2 +45,3 @@ * Helper class matches value types for equality.

* @param actualType an actual type to match.
* @param actualValue an optional value to match its type to the expected one.
* @returns true if types are matching and false if they don't.

@@ -50,3 +52,4 @@ *

*/
TypeMatcher.matchType = function (expectedType, actualType) {
TypeMatcher.matchType = function (expectedType, actualType, actualValue) {
if (actualValue === void 0) { actualValue = null; }
if (expectedType == null)

@@ -57,2 +60,5 @@ return true;

if (_.isInteger(expectedType)) {
if (expectedType == actualType)
return true;
// Special provisions for dynamic data
if (expectedType == TypeCode_1.TypeCode.Integer

@@ -70,6 +76,9 @@ && (actualType == TypeCode_1.TypeCode.Long || actualType == TypeCode_1.TypeCode.Float || actualType == TypeCode_1.TypeCode.Double))

return true;
return expectedType == actualType;
if (expectedType == TypeCode_1.TypeCode.DateTime
&& (actualType == TypeCode_1.TypeCode.String && convert_1.DateTimeConverter.toNullableDateTime(actualValue) != null))
return true;
return false;
}
if (_.isString(expectedType))
return TypeMatcher.matchTypeByName(expectedType, actualType);
return TypeMatcher.matchTypeByName(expectedType, actualType, actualValue);
return false;

@@ -96,5 +105,7 @@ };

* @param actualType an actual type to match defined by type code.
* @param actualValue an optional value to match its type to the expected one.
* @returns true if types are matching and false if they don't.
*/
TypeMatcher.matchTypeByName = function (expectedType, actualType) {
TypeMatcher.matchTypeByName = function (expectedType, actualType, actualValue) {
if (actualValue === void 0) { actualValue = null; }
if (expectedType == null)

@@ -109,13 +120,21 @@ return true;

return actualType == TypeCode_1.TypeCode.Integer
// Special provisions for dynamic data
|| actualType == TypeCode_1.TypeCode.Long;
}
else if (expectedType == "long") {
return actualType == TypeCode_1.TypeCode.Long;
return actualType == TypeCode_1.TypeCode.Long
// Special provisions for dynamic data
|| actualType == TypeCode_1.TypeCode.Integer;
}
else if (expectedType == "float") {
return actualType == TypeCode_1.TypeCode.Float
|| actualType == TypeCode_1.TypeCode.Double;
// Special provisions for dynamic data
|| actualType == TypeCode_1.TypeCode.Double
|| actualType == TypeCode_1.TypeCode.Integer
|| actualType == TypeCode_1.TypeCode.Long;
}
else if (expectedType == "double") {
return actualType == TypeCode_1.TypeCode.Double;
return actualType == TypeCode_1.TypeCode.Double
// Special provisions fro dynamic data
|| actualType == TypeCode_1.TypeCode.Float;
}

@@ -129,3 +148,5 @@ else if (expectedType == "string") {

else if (expectedType == "date" || expectedType == "datetime") {
return actualType == TypeCode_1.TypeCode.DateTime;
return actualType == TypeCode_1.TypeCode.DateTime
// Special provisions fro dynamic data
|| (actualType == TypeCode_1.TypeCode.String && convert_1.DateTimeConverter.toNullableDateTime(actualValue) != null);
}

@@ -132,0 +153,0 @@ else if (expectedType == "timespan" || expectedType == "duration") {

"use strict";
var __spreadArrays = (this && this.__spreadArrays) || function () {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -91,3 +98,3 @@ /** @module reflect */

throw new Error("Type contructor has to be a function");
return new (type.bind.apply(type, [void 0].concat(args)))();
return new (type.bind.apply(type, __spreadArrays([void 0], args)))();
};

@@ -115,3 +122,3 @@ /**

.withDetails("type", name).withDetails("library", library);
return TypeReflector.createInstanceByType.apply(TypeReflector, [type].concat(args));
return TypeReflector.createInstanceByType.apply(TypeReflector, __spreadArrays([type], args));
};

@@ -135,3 +142,3 @@ /**

throw new Error("Type descriptor cannot be null");
return TypeReflector.createInstance.apply(TypeReflector, [descriptor.getName(), descriptor.getLibrary()].concat(args));
return TypeReflector.createInstance.apply(TypeReflector, __spreadArrays([descriptor.getName(), descriptor.getLibrary()], args));
};

@@ -138,0 +145,0 @@ /**

@@ -174,3 +174,3 @@ "use strict";

// Match types
if (TypeMatcher_1.TypeMatcher.matchType(type, valueType))
if (TypeMatcher_1.TypeMatcher.matchType(type, valueType, value))
return;

@@ -177,0 +177,0 @@ results.push(new ValidationResult_1.ValidationResult(path, ValidationResultType_1.ValidationResultType.Error, "TYPE_MISMATCH", name + " type must be " + this.typeToString(type) + " but found " + this.typeToString(valueType), type, valueType.toString()));

{
"name": "pip-services3-commons-node",
"version": "3.0.5",
"version": "3.0.6",
"author": "Conceptual Vision Consulting LLC",

@@ -5,0 +5,0 @@ "description": "Portable abstractions and patterns for Pip.Services in Node.js",

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc