* Gets the file content synchronously. * Throws if the content provider returns a Promise. * @returns {Buffer} The file content
()
| 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. |
no test coverage detected