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

Class SingleItem

packages/@contentlayer/utils/src/single-item.ts:1–11  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1export class SingleItem<T> {
2 constructor(public item: T) {}
3
4 map<U>(fn: (item: T) => U): SingleItem<U> {
5 return new SingleItem(fn(this.item))
6 }
7
8 filter(fn: (item: T) => boolean): SingleItem<T | undefined> {
9 return fn(this.item) ? this : new SingleItem(undefined)
10 }
11}
12
13export const singleItem = <T>(item: T) => new SingleItem(item)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…