typescript-dotnet-core
Version:
A the core classes and utilities of a JavaScript-Friendly .NET Based TypeScript Library.
7 lines (6 loc) • 1.55 kB
JavaScript
"use strict";
/*!
* @author electricessence / https://github.com/electricessence/
* Licensing: MIT
*/Object.defineProperty(exports,"__esModule",{value:!0});var tslib_1=require("tslib"),Types_1=require("./Types"),Compare_1=require("./Compare"),TypeInfoHelper=function(e){function r(r){return e.call(this,r,function(e){return e._value=r})||this}return tslib_1.__extends(r,e),r.prototype.contains=function(e){var r=this._value;if(r===e)return!0;switch(e){case Function:return this.isFunction;case Object:return this.isObject;case Array:return this.isArray;case String:return this.isString;case Number:return this.isNumber;case Boolean:return this.isBoolean}if(this.type!=typeof e||this.isPrimitive&&!Compare_1.areEqual(r,e))return!1;if(this.isArray&&Types_1.default.isArrayLike(e)){for(var t=Math.min(e.length,r.length),i=0;i<t;i++)if(areInvalid(r[i],e[i]))return!1;return!0}if(this.isObject){var n=Object.keys(r),s=Object.keys(e);if(s.length>n.length)return!1;for(var a=0,u=s;a<u.length;a++){var o=u[a];if(-1==n.indexOf(o))return!1}for(var p=0,f=s;p<f.length;p++){if(areInvalid(r[o=f[p]],e[o]))return!1}}return!0},r}(Types_1.TypeInfo);function areInvalid(e,r){if(!Compare_1.areEqual(e,r)&&!new TypeInfoHelper(e).contains(r))return!0;return!1}exports.TypeInfoHelper=TypeInfoHelper;var TypeValidator=function(){function e(e){this._typeDescriptor=e,Object.freeze(this)}return e.prototype.isSubsetOf=function(e){return new TypeInfoHelper(e).contains(this._typeDescriptor)},e}();exports.default=TypeValidator;
//# sourceMappingURL=TypeValidator.js.map