MCPcopy Create free account
hub / github.com/freeCodeCamp/freeCodeCamp / createPoly

Function createPoly

packages/shared/src/utils/polyvinyl.ts:37–59  ·  view source on GitHub ↗
({
  name,
  ext,
  contents,
  history,
  ...rest
}: PolyProps & Rest)

Source from the content-addressed store, hash-verified

35};
36
37export 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
61export function isPoly(poly: unknown): poly is ChallengeFile {
62 function hasProperties(poly: unknown): poly is Record<string, unknown> {

Callers 3

polyvinyl.test.tsFile · 0.90
challengeFilesToPolysFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected