MCPcopy
hub / github.com/sindresorhus/ow / ow

Function ow

source/index.ts:182–197  ·  view source on GitHub ↗
(value: unknown, labelOrPredicate: unknown, predicate?: BasePredicate<T>)

Source from the content-addressed store, hash-verified

180 : never;
181
182const 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
199Object.defineProperties(ow, {
200 isValid: {

Callers 15

fnFunction · 0.85
absent.tsFile · 0.85
patchHotdogFunction · 0.85
nullable.tsFile · 0.85
iterable.tsFile · 0.85
array-buffer.tsFile · 0.85
test.tsFile · 0.85
validateAnimalFunction · 0.85
validateConfigFunction · 0.85
bigint.tsFile · 0.85
symbol.tsFile · 0.85

Calls 3

isPredicateFunction · 0.85
testFunction · 0.85
inferLabelFunction · 0.50

Tested by

no test coverage detected