MCPcopy
hub / github.com/imcuttle/mometa / toString

Method toString

packages/fs-handler/src/utils/line-contents.ts:118–145  ·  view source on GitHub ↗
(normalize = true)

Source from the content-addressed store, hash-verified

116 }
117
118 toString(normalize = true) {
119 const content = this.contents
120 .filter((x) => x.content !== EMPTY)
121 .map((x) => x.toString())
122 .join('\n')
123 if (!normalize) {
124 return content
125 }
126
127 const name = this.options.filename || 'index.js'
128 const isTs = /\.tsx?$/.test(name)
129
130 try {
131 return format(content, {
132 ...config,
133 filepath: this.options.filename,
134 parser: isTs ? 'typescript' : 'babel',
135 plugins: [isTs ? parserTs : parserBabel]
136 })
137 .replace(/^;/, '')
138 .trim()
139 } catch (err) {
140 err.message = `${content}
141
142${err.message}`
143 throw err
144 }
145 }
146}
147
148export function createLineContentsByContent(content: string, options?: ContentParserOptions) {

Callers

nothing calls this directly

Calls 1

toStringMethod · 0.45

Tested by

no test coverage detected