UNPKG

2.79 kBSource Map (JSON)View Raw
1{"version":3,"file":"array.js","sourceRoot":"","sources":["../../../../src/lib/models/types/array.ts"],"names":[],"mappings":";;AAAA,mCAA4D;AAS5D,MAAa,SAAU,SAAQ,YAAI;IAiB/B,YAAY,WAAiB;QACzB,KAAK,EAAE,CAAC;QARH,SAAI,GAAW,OAAO,CAAC;QAS5B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACnC,CAAC;IAOD,KAAK;QACD,OAAO,IAAI,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAC3C,CAAC;IAQD,MAAM,CAAC,IAAU;QACb,IAAI,CAAC,CAAC,IAAI,YAAY,SAAS,CAAC,EAAE;YAC9B,OAAO,KAAK,CAAC;SAChB;QACD,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACrD,CAAC;IAMD,QAAQ;QACJ,MAAM,MAAM,GAAQ,KAAK,CAAC,QAAQ,EAAE,CAAC;QACrC,MAAM,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC;QAEjD,OAAO,MAAM,CAAC;IAClB,CAAC;IAKD,QAAQ;QACJ,MAAM,cAAc,GAAG,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC;QACnD,IAAI,IAAI,CAAC,WAAW,YAAY,iBAAS,IAAI,IAAI,CAAC,WAAW,YAAY,wBAAgB,EAAE;YACvF,OAAO,GAAG,GAAG,cAAc,GAAG,KAAK,CAAC;SACvC;aAAM;YACH,OAAO,cAAc,GAAG,IAAI,CAAC;SAChC;IACL,CAAC;CACJ;AAlED,8BAkEC","sourcesContent":["import { Type, UnionType, IntersectionType } from './index';\n\n/**\n * Represents an array type.\n *\n * ~~~\n * let value: string[];\n * ~~~\n */\nexport class ArrayType extends Type {\n\n /**\n * The type of the array elements.\n */\n elementType: Type;\n\n /**\n * The type name identifier.\n */\n readonly type: string = 'array';\n\n /**\n * Create a new TupleType instance.\n *\n * @param elementType The type of the array's elements.\n */\n constructor(elementType: Type) {\n super();\n this.elementType = elementType;\n }\n\n /**\n * Clone this type.\n *\n * @return A clone of this type.\n */\n clone(): Type {\n return new ArrayType(this.elementType);\n }\n\n /**\n * Test whether this type equals the given type.\n *\n * @param type The type that should be checked for equality.\n * @returns TRUE if the given type equals this type, FALSE otherwise.\n */\n equals(type: Type): boolean {\n if (!(type instanceof ArrayType)) {\n return false;\n }\n return type.elementType.equals(this.elementType);\n }\n\n /**\n * Return a raw object representation of this type.\n * @deprecated Use serializers instead\n */\n toObject(): any {\n const result: any = super.toObject();\n result.elementType = this.elementType.toObject();\n\n return result;\n }\n\n /**\n * Return a string representation of this type.\n */\n toString() {\n const elementTypeStr = this.elementType.toString();\n if (this.elementType instanceof UnionType || this.elementType instanceof IntersectionType) {\n return '(' + elementTypeStr + ')[]';\n } else {\n return elementTypeStr + '[]';\n }\n }\n}\n"]}
\No newline at end of file