You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

18 lines
412 B

import predicates, {Predicates} from './predicates';
export interface Modifiers {
/**
* Make the following predicate optional so it doesn't fail when the value is `undefined`.
*/
readonly optional: Predicates;
}
export default <T>(object: T): T & Modifiers => {
Object.defineProperties(object, {
optional: {
get: () => predicates({}, {optional: true})
}
});
return object as T & Modifiers;
};