MCPcopy Create free account
hub / github.com/Easy-Editor/EasyEditor / removeDocument

Method removeDocument

packages/core/src/project/project.ts:151–170  ·  view source on GitHub ↗
(idOrDoc: string | Document)

Source from the content-addressed store, hash-verified

149
150 @action
151 removeDocument(idOrDoc: string | Document) {
152 let document: Document | undefined
153 if (typeof idOrDoc === 'string') {
154 document = this.documents.find(document => document.id === idOrDoc)
155 } else {
156 document = idOrDoc
157 }
158
159 if (!document) {
160 return logger.warn('document not found', idOrDoc)
161 }
162
163 const index = this.documents.indexOf(document)
164 if (index < 0) {
165 return logger.warn('document not found', idOrDoc)
166 }
167
168 this.documents.splice(index, 1)
169 this.documentsMap.delete(document.id)
170 }
171
172 getDocument(id: string) {
173 return this.documents.find(doc => doc.id === id)

Callers 2

destroyFunction · 0.80
removeMethod · 0.80

Calls 4

findMethod · 0.80
warnMethod · 0.80
indexOfMethod · 0.80
deleteMethod · 0.65

Tested by

no test coverage detected