mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-09-30 09:17:09 +08:00
This reverts commit 556d230a0e.
Reason for revert: Breaks the build on windows.
Original change's description:
> Update esbuild
>
> DISABLE_THIRD_PARTY_CHECK=DEPS needs to be updated together
>
> Bug: none
> Change-Id: I6af5660c313d5d998b320f688a36a1f3de5beb03
> Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/5025093
> Commit-Queue: Randolf Jung <jrandolf@chromium.org>
> Reviewed-by: Danil Somsikov <dsv@chromium.org>
Bug: none
Change-Id: I331613611d0b8bd56a96a5eff50e452213f6f14b
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/5033272
Reviewed-by: Danil Somsikov <dsv@chromium.org>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Danil Somsikov <dsv@chromium.org>
Auto-Submit: Philip Pfaffe <pfaffe@chromium.org>
universalify
Make a callback- or promise-based function support both promises and callbacks.
Uses the native promise implementation.
Installation
npm install universalify
API
universalify.fromCallback(fn)
Takes a callback-based function to universalify, and returns the universalified function.
Function must take a callback as the last parameter that will be called with the signature (error, result). universalify does not support calling the callback with three or more arguments, and does not ensure that the callback is only called once.
function callbackFn (n, cb) {
setTimeout(() => cb(null, n), 15)
}
const fn = universalify.fromCallback(callbackFn)
// Works with Promises:
fn('Hello World!')
.then(result => console.log(result)) // -> Hello World!
.catch(error => console.error(error))
// Works with Callbacks:
fn('Hi!', (error, result) => {
if (error) return console.error(error)
console.log(result)
// -> Hi!
})
universalify.fromPromise(fn)
Takes a promise-based function to universalify, and returns the universalified function.
Function must return a valid JS promise. universalify does not ensure that a valid promise is returned.
function promiseFn (n) {
return new Promise(resolve => {
setTimeout(() => resolve(n), 15)
})
}
const fn = universalify.fromPromise(promiseFn)
// Works with Promises:
fn('Hello World!')
.then(result => console.log(result)) // -> Hello World!
.catch(error => console.error(error))
// Works with Callbacks:
fn('Hi!', (error, result) => {
if (error) return console.error(error)
console.log(result)
// -> Hi!
})
License
MIT