TinyType
|
TinyType |
wrapping a single value
|
- |
definition
|
TinyType |
can be a one-liner for TinyTypes representing a single value
|
TinyTypeOf |
prevents null and undefined when the single-line definition style is used
|
TinyTypeOf |
needs to extend the TinyType for types with more than one value
|
TinyType
TinyTypeOf |
can be mixed and matched
|
TinyType
TinyTypeOf |
::toString
|
TinyType#toString |
mentions the class and its properties
|
- |
mentions the class and its fields, but not the methods
|
- |
only cares about the fields, not the methods
|
- |
prints the array-type properties
|
- |
prints the object-type properties
|
- |
serialisation
|
TinyType#toJSON |
::toJSON
|
- |
should serialise a complex TinyType recursively
|
- |
spec/TinyType.spec.ts |
- |
spec/TinyType.spec.ts |
- |
spec/TinyType.spec.ts |
- |
spec/TinyType.spec.ts |
- |
spec/TinyType.spec.ts |
- |
spec/TinyType.spec.ts |
- |
should serialise a plain-old JavaScript object with nested complex types recursively
|
- |
should serialise null and undefined
|
- |
spec/TinyType.spec.ts |
- |
de-serialisation
|
TinyType |
custom fromJSON can de-serialise a serialised single-value TinyType
|
- |
custom fromJSON can recursively de-serialise a serialised complex TinyType
|
- |
JSON
|
- |
JSONArray
|
JSONArray |
spec/json.spec.ts |
- |
JSONObject
|
JSONObject |
spec/json.spec.ts |
- |
JSONPrimitive
|
JSONPrimitive |
spec/json.spec.ts |
- |
JSONValue
|
JSONValue |
describes any value that can be represented as JSON
|
- |
spec/match.spec.ts |
match |
default rules
|
match |
spec/match.spec.ts |
- |
spec/match.spec.ts |
- |
when selecting a matcher
|
- |
when working with TinyTypes
|
match
TinyType
TinyTypeOf |
deprecated
|
deprecated |
when used to annotate a class
|
- |
logs a warning when the class is constructed
|
- |
can provide additional suggestion on what other class should be used instead
|
- |
maintains the type and behaviour of the annotated class
|
- |
when used to annotate a method
|
- |
logs a warning when the method is used
|
- |
can provide additional suggestion on what other method should be used instead
|
- |
maintains the behaviour of the annotated method
|
- |
when used incorrectly
|
- |
complains
|
- |
equal
|
equal |
when used with primitives
|
- |
when used with TinyTypes
|
TinyType#equals |
compares public and private member fields
|
- |
when used with TinyTypes with optional fields
|
TinyType#equals |
returns true when the non-optional fields are equal
|
- |
when used with Dates
|
TinyType#equals |
is reflexive
|
- |
is symmetric
|
- |
is transitive
|
- |
returns false when subjects are not equal
|
- |
when used with Arrays
|
TinyType#equals |
returns false when arrays are of different length
|
- |
returns false when arrays contain different items
|
- |
returns true when both arrays contain equal items
|
- |
significantFields
|
significantFields |
returns the names of private and public member fields of an instantiated object
|
- |
spec/objects/significantFields.spec.ts |
- |
spec/objects/significantFields.spec.ts |
- |
pattern-matching
|
- |
IdentityMatcher
|
- |
matches a symbol
|
- |
pattern-matching
|
- |
ObjectMatcher
|
- |
when working with Tiny Types
|
- |
matches identical objects
|
- |
when working with regular classes
|
- |
pattern-matching
|
- |
StringMatcher
|
- |
pattern-matching
|
- |
rules
|
- |
MatchesAnything
|
- |
predicates
|
- |
::and
|
and |
ensures that all the predicates are met
|
- |
complains if there are no predicates specified
|
- |
stops evaluating the predicates upon the first failure
|
- |
predicates
|
- |
::endsWith
|
endsWith |
ensures that the argument ends with a given suffix
|
- |
predicates
|
- |
::hasLengthOf
|
hasLengthOf |
when used with strings
|
hasLengthOf |
ensures that the value has a correct length
|
- |
when used with arrays
|
hasLengthOf |
ensures that the value has a correct length
|
- |
predicates
|
- |
::isArray
|
isArray |
ensures that the argument is an array
|
- |
predicates
|
- |
::isBoolean
|
isBoolean |
ensures that the argument is a boolean value
|
- |
predicates
|
- |
::isDefined
|
isDefined |
ensures that the value is defined
|
- |
predicates
|
- |
::isEqualTo
|
isEqualTo |
when working with Tiny Types
|
isEqualTo |
ensures that objects are identical by value
|
- |
complains if the objects are not identical by value
|
- |
when working with primitive types
|
isEqualTo |
predicates
|
- |
::isFunction
|
isFunction |
ensures that the argument in a function
|
- |
predicates
|
- |
::isGreaterThan
|
isGreaterThan |
ensures that the argument is greater than a specified number
|
- |
complains if the argument is more than a specified number
|
- |
predicates
|
- |
::isGreaterThanOrEqualTo
|
isGreaterThanOrEqualTo |
complains if the argument is less than the lower bound
|
- |
predicates
|
- |
::isInRange
|
isInRange |
complains if the value is lower than the lower bound
|
- |
complains if the value is greater than the upper bound
|
- |
predicates
|
- |
::isInstanceOf
|
isInstanceOf |
ensures that the argument is an instance of Date
|
- |
predicates
|
- |
::isInteger
|
isInteger |
ensures that the argument in an integer
|
- |
predicates
|
- |
::isLessThan
|
isLessThan |
ensures that the argument is less than a specified number
|
- |
complains if the argument is more than a specified number
|
- |
predicates
|
- |
::isLessThanOrEqualTo
|
isLessThanOrEqualTo |
complains if the argument is greater than the upper bound
|
- |
predicates
|
- |
::isNotBlank
|
isBlank |
ensures that the argument in not blank
|
- |
predicates
|
- |
::isNumber
|
isNumber |
ensures that the argument in a number
|
- |
predicates
|
- |
::isOneOf
|
isOneOf |
complains if the value not one the allowed ones
|
- |
predicates
|
- |
::isPlainObject
|
isPlainObject |
is generic
|
- |
predicates
|
- |
::isString
|
isString |
ensures that the argument is a string
|
- |
predicates
|
- |
::matches
|
matches |
ensures that the argument matches a regular expression
|
- |
predicates
|
- |
::or
|
or |
complains if there are no predicates specified
|
- |
concatenates the error messages in a human-friendly way
|
- |
predicates
|
- |
::property
|
property |
shifts the focus from the value itself to its property
|
property |
ensures that the property meets the predicates
|
property |
predicates
|
- |
::startsWith
|
startsWith |
ensures that the argument starts with a given prefix
|
- |
Serialisation
|
- |
of single-value TinyTypes
|
- |
of TinyTypes wrapping several primitive values
|
- |
uses only the significant fields and retains their type
|
- |
of nested Tiny Types
|
- |
uses only the significant fields and retains the type of their respective values
|
- |
works both ways
|
- |