MCPcopy Create free account
hub / github.com/nodejs/node / getContentSync

Method getContentSync

lib/internal/vfs/providers/memory.js:139–149  ·  view source on GitHub ↗

* Gets the file content synchronously. * Throws if the content provider returns a Promise. * @returns {Buffer} The file content

()

Source from the content-addressed store, hash-verified

137 * @returns {Buffer} The file content
138 */
139 getContentSync() {
140 if (this.contentProvider !== null) {
141 const result = this.contentProvider();
142 if (isPromise(result)) {
143 // It's a Promise - can't use sync API
144 throw new ERR_INVALID_STATE('cannot use sync API with async content provider');
145 }
146 return typeof result === 'string' ? Buffer.from(result) : result;
147 }
148 return this.content;
149 }
150
151 /**
152 * Gets the file content asynchronously.

Callers 2

contentMethod · 0.80
#createStatsMethod · 0.80

Calls 1

fromMethod · 0.45

Tested by

no test coverage detected