trufflesuite/truffle

View on GitHub
packages/preserve/lib/targets/sources/types.ts

Summary

Maintainability
A
0 mins
Test Coverage
import type { Content } from "./contents";

export interface Entry {
  path: string;
  source: Source;
}

export interface Container {
  entries: Iterable<Entry> | AsyncIterable<Entry>;
}

export type Source = Content | Container;

export const isContainer = (source: Source): source is Container =>
  source &&
  typeof source === "object" &&
  "entries" in source &&
  typeof source.entries === "object";

export const isContent = (source: Source): source is Content =>
  !isContainer(source);