MCPcopy Create free account
hub / github.com/contentlayerdev/contentlayer / is

Function is

packages/@contentlayer/client/src/guards.ts:31–42  ·  view source on GitHub ↗
(typeName: N, _?: any)

Source from the content-addressed store, hash-verified

29function is<N extends TypeNameOneOrMany>(typeName: N, _: any): _ is TypeForTypeNameOneOrMany<N>
30function is<N extends TypeNameOneOrMany>(typeName: N): (_: any) => _ is TypeForTypeNameOneOrMany<N>
31function is<N extends TypeNameOneOrMany>(typeName: N, _?: any): any {
32 if (_) {
33 if (Array.isArray(typeName)) {
34 // TODO make type field name dynamic (probably will require to code-gen the guard function)
35 return typeName.some((typeName_) => _?.type === typeName_)
36 } else {
37 return typeName === _?.type
38 }
39 } else {
40 return (_: any) => is(typeName, _)
41 }
42}
43
44export const isType = is
45

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected