Comparing version 0.6.0 to 0.6.3
import { ObjectType } from "./object-type"; | ||
export declare class IntersectionType extends ObjectType { | ||
constructor(types: ObjectType[]); | ||
constructor(...types: ObjectType[]); | ||
} |
@@ -10,3 +10,4 @@ export { Type } from "./type"; | ||
export { OptionalType } from "./optional-type"; | ||
export { MalformedObjectError } from "./malformed-object-error"; | ||
export { IntersectionType, IntersectionType as MultiType, IntersectionType as AndType } from "./intersection-type"; | ||
export { UnionType, UnionType as OrType } from "./union-type"; |
@@ -5,3 +5,3 @@ import { Type } from "./type"; | ||
protected acceptableTypes: Type[]; | ||
constructor(types: Type[]); | ||
constructor(...types: Type[]); | ||
getTypeName(): string; | ||
@@ -8,0 +8,0 @@ checkConformity(input: any): boolean; |
@@ -13,3 +13,3 @@ "use strict"; | ||
class IntersectionType extends object_type_1.ObjectType { | ||
constructor(types) { | ||
constructor(...types) { | ||
super(Merj.merge(types.map((type) => type.getObjectTypeDefinition())), ""); | ||
@@ -16,0 +16,0 @@ this.typeName = ""; |
@@ -19,2 +19,4 @@ "use strict"; | ||
exports.OptionalType = optional_type_1.OptionalType; | ||
var malformed_object_error_1 = require("./malformed-object-error"); | ||
exports.MalformedObjectError = malformed_object_error_1.MalformedObjectError; | ||
var intersection_type_1 = require("./intersection-type"); | ||
@@ -27,2 +29,15 @@ exports.IntersectionType = intersection_type_1.IntersectionType; | ||
exports.OrType = union_type_1.UnionType; | ||
const main_1 = require("./main"); | ||
let typeDef = { | ||
name: main_1.StandardType.STRING, | ||
age: main_1.StandardType.NUMBER, | ||
alive: new main_1.OrType(main_1.StandardType.BOOLEAN, main_1.SpecialType.UNDEFINED) | ||
}; | ||
let obj = { | ||
name: 12, | ||
age: "Yes", | ||
alive: true | ||
}; | ||
let type = new main_1.ObjectType(typeDef); | ||
console.log("Conforms: " + type.checkConformity(obj)); | ||
//# sourceMappingURL=main.js.map |
@@ -5,3 +5,3 @@ "use strict"; | ||
class UnionType extends type_1.Type { | ||
constructor(types) { | ||
constructor(...types) { | ||
super(); | ||
@@ -8,0 +8,0 @@ this.acceptableTypes = types; |
{ | ||
"name": "typit", | ||
"version": "0.6.0", | ||
"version": "0.6.3", | ||
"description": "Fully recursive runtime typechecking.", | ||
@@ -9,4 +9,4 @@ "main": "js/main", | ||
"build": "rm -rf .d.ts/ js/ && tsc -p ts/tsconfig.json", | ||
"main": "node js/main", | ||
"test": "jest" | ||
"main": "npm run build && node js/main", | ||
"test": "npm run build && jest" | ||
}, | ||
@@ -13,0 +13,0 @@ "repository": { |
@@ -12,2 +12,9 @@ # typit | ||
$ npm install --save typit | ||
``` | ||
``` | ||
## License | ||
typit is made available under the GNU General Public License v3. | ||
Copyright (C) 2019 Trevor Sears | ||
Find the full license [here](https://github.com/T99/typit/blob/master/license.md). |
@@ -44,3 +44,3 @@ /* | ||
*/ | ||
public constructor(types: ObjectType[]) { | ||
public constructor(...types: ObjectType[]) { | ||
@@ -47,0 +47,0 @@ super(Merj.merge(types.map((type: ObjectType) => type.getObjectTypeDefinition())), ""); |
@@ -24,2 +24,3 @@ /* | ||
export { OptionalType } from "./optional-type"; | ||
export { MalformedObjectError } from "./malformed-object-error"; | ||
@@ -35,2 +36,33 @@ export { | ||
UnionType as OrType | ||
} from "./union-type"; | ||
} from "./union-type"; | ||
import { | ||
ObjectType, | ||
ObjectTypeDefinition, | ||
// MalformedObjectError, | ||
OrType, | ||
SpecialType, | ||
StandardType | ||
} from "./main"; | ||
let typeDef: ObjectTypeDefinition = { | ||
name: StandardType.STRING, | ||
age: StandardType.NUMBER, | ||
alive: new OrType(StandardType.BOOLEAN, SpecialType.UNDEFINED) | ||
}; | ||
let obj: any = { | ||
name: 12, | ||
age: "Yes", | ||
alive: true | ||
}; | ||
let type: ObjectType = new ObjectType(typeDef); | ||
console.log("Conforms: " + type.checkConformity(obj)); | ||
// let nonConformities: any[] = type.listNonConformities(obj).map((error: MalformedObjectError): any => error.toJSON()); | ||
// console.log(nonConformities); |
@@ -33,3 +33,3 @@ /* | ||
*/ | ||
public constructor(types: Type[]) { | ||
public constructor(...types: Type[]) { | ||
@@ -36,0 +36,0 @@ super(); |
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
150111
2244
19