MCPcopy Index your code
hub / github.com/simstudioai/sim / processComments

Function processComments

apps/sim/tools/reddit/get_comments.ts:145–172  ·  view source on GitHub ↗
(comments: any[])

Source from the content-addressed store, hash-verified

143 const commentsData = data[1]?.data?.children || []
144
145 const processComments = (comments: any[]): any[] => {
146 return comments
147 .map((comment) => {
148 const commentData = comment.data
149
150 if (!commentData || comment.kind !== 't1') {
151 return null
152 }
153
154 const replies = commentData.replies?.data?.children
155 ? processComments(commentData.replies.data.children)
156 : []
157
158 return {
159 id: commentData.id ?? '',
160 name: commentData.name ?? '',
161 author: commentData.author || '[deleted]',
162 body: commentData.body ?? '',
163 created_utc: commentData.created_utc ?? 0,
164 score: commentData.score ?? 0,
165 permalink: commentData.permalink
166 ? `https://www.reddit.com${commentData.permalink}`
167 : '',
168 replies: replies.filter(Boolean),
169 }
170 })
171 .filter(Boolean)
172 }
173
174 const comments = processComments(commentsData)
175

Callers 1

get_comments.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected