MCPcopy Index your code
hub / github.com/atomicdata-dev/atomic-data-browser / addResource

Method addResource

lib/src/store.ts:58–71  ·  view source on GitHub ↗

* Adds a Resource to the store and notifies subscribers. Replaces existing * resources, unless this new resource is explicitly incomplete.

(resource: Resource)

Source from the content-addressed store, hash-verified

56 * resources, unless this new resource is explicitly incomplete.
57 */
58 addResource(resource: Resource): void {
59 // Incomplete resources may miss some properties
60 if (resource.get(urls.properties.incomplete)) {
61 // If there is a resource with the same subject, we won't overwrite it with an incomplete one
62 const existing = this.resources.get(resource.getSubject());
63 if (existing && !existing.loading) {
64 return;
65 }
66 }
67
68 this.resources.set(resource.getSubject(), resource);
69 // We clone
70 this.notify(resource.clone());
71 }
72
73 /** Checks if a subject is free to use */
74 async checkSubjectTaken(subject: string): Promise<boolean> {

Callers 8

getResourceLoadingMethod · 0.95
fetchResourceFunction · 0.80
uploadFilesFunction · 0.80
saveMethod · 0.80
parseAndApplyFunction · 0.80
parseJsonADResourceFunction · 0.80
store.test.tsFile · 0.80
addElementFunction · 0.80

Calls 5

notifyMethod · 0.95
getMethod · 0.80
getSubjectMethod · 0.80
setMethod · 0.80
cloneMethod · 0.45

Tested by

no test coverage detected