UNPKG

@serenity-js/core

Version:

The core Serenity/JS framework, providing the Screenplay Pattern interfaces, as well as the test reporting and integration infrastructure

27 lines 866 B
/** * Checks if the `candidate` value "quacks like a duck". * In particular, it checks if the `candidate`: * - is not `null` * - is not `undefined` * - has expected methods or fields (evaluated via [`typeof`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof)) * * ```ts * const looksLikeADuck = has({ * name: 'string', * quack: 'function', * }) * * const daisy = { * name: 'Daisy', * quack: () => 'quack', * } * * looksLikeADuck(daisy) // true * ``` * * @param api * An object where the keys are names of member fields and methods expected on the `candidate`, * and values are the names of their types, i.e. `function`, `object`, etc. */ export declare function has<T>(api: Record<keyof T, string>): (candidate: unknown) => candidate is T; //# sourceMappingURL=has.d.ts.map