({
name,
ext,
contents,
history,
...rest
}: PolyProps & Rest)
| 35 | }; |
| 36 | |
| 37 | export function createPoly<Rest>({ |
| 38 | name, |
| 39 | ext, |
| 40 | contents, |
| 41 | history, |
| 42 | ...rest |
| 43 | }: PolyProps & Rest): PolyProps & AddedProperties & Rest { |
| 44 | if (typeof name !== 'string') throw new TypeError('name must be a string'); |
| 45 | if (typeof ext !== 'string') throw new TypeError('ext must be a string'); |
| 46 | if (typeof contents !== 'string') |
| 47 | throw new TypeError('contents must be a string'); |
| 48 | |
| 49 | return { |
| 50 | ...rest, |
| 51 | history: Array.isArray(history) ? history : [name + '.' + ext], |
| 52 | name, |
| 53 | ext, |
| 54 | path: name + '.' + ext, |
| 55 | fileKey: name + ext, |
| 56 | contents, |
| 57 | error: null |
| 58 | } as PolyProps & AddedProperties & Rest; |
| 59 | } |
| 60 | |
| 61 | export function isPoly(poly: unknown): poly is ChallengeFile { |
| 62 | function hasProperties(poly: unknown): poly is Record<string, unknown> { |
no outgoing calls
no test coverage detected