(value: unknown, labelOrPredicate: unknown, predicate?: BasePredicate<T>)
| 180 | : never; |
| 181 | |
| 182 | const ow = <T>(value: unknown, labelOrPredicate: unknown, predicate?: BasePredicate<T>): void => { |
| 183 | if (!isPredicate(labelOrPredicate) && typeof labelOrPredicate !== 'string') { |
| 184 | throw new TypeError(`Expected second argument to be a predicate or a string, got \`${typeof labelOrPredicate}\``); |
| 185 | } |
| 186 | |
| 187 | if (isPredicate(labelOrPredicate)) { |
| 188 | // If the second argument is a predicate, infer the label |
| 189 | const stackFrames = callsites(); |
| 190 | |
| 191 | test(value, () => inferLabel(stackFrames), labelOrPredicate); |
| 192 | |
| 193 | return; |
| 194 | } |
| 195 | |
| 196 | test(value, labelOrPredicate, predicate!); |
| 197 | }; |
| 198 | |
| 199 | Object.defineProperties(ow, { |
| 200 | isValid: { |
no test coverage detected