MCPcopy
hub / github.com/remarkjs/react-markdown / deferPlugin

Function deferPlugin

test.jsx:1245–1269  ·  view source on GitHub ↗

* Create an async unified plugin that waits until a promise is resolved or * rejected from the outside. * * @returns {DeferredPlugin} * Deferred plugin object.

()

Source from the content-addressed store, hash-verified

1243 * Deferred plugin object.
1244 */
1245function deferPlugin() {
1246 /** @type {(error: Error) => void} */
1247 let hoistedReject
1248 /** @type {() => void} */
1249 let hoistedResolve
1250 /** @type {Promise<void>} */
1251 const promise = new Promise(function (resolve, reject) {
1252 hoistedResolve = resolve
1253 hoistedReject = reject
1254 })
1255
1256 return {
1257 plugin() {
1258 return function () {
1259 return promise
1260 }
1261 },
1262 reject(error) {
1263 hoistedReject(error)
1264 },
1265 resolve() {
1266 hoistedResolve()
1267 }
1268 }
1269}
1270
1271/**
1272 * Basic error boundary.

Callers 1

test.jsxFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…