mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-15 14:43:46 +01:00
Merge pull request #2089 from overleaf/em-mailchimp-unsubscribe
Handle error on Mailchimp unsubscribe when deleting users GitOrigin-RevId: 8923480e6d50de45003fd7741610f995753a412b
This commit is contained in:
committed by
sharelatex
parent
3791b8d288
commit
869fcf7952
@@ -0,0 +1,31 @@
|
||||
const { promisify } = require('util')
|
||||
|
||||
module.exports = { promisifyAll }
|
||||
|
||||
/**
|
||||
* Promisify all functions in a module.
|
||||
*
|
||||
* This is meant to be used only when all functions in the module are async
|
||||
* callback-style functions.
|
||||
*
|
||||
* It's very much tailored to our current module structure. In particular, it
|
||||
* binds `this` to the module when calling the function in order not to break
|
||||
* modules that call sibling functions using `this`.
|
||||
*
|
||||
* This will not magically fix all modules. Special cases should be promisified
|
||||
* manually.
|
||||
*/
|
||||
function promisifyAll(module, opts = {}) {
|
||||
const { without = [] } = opts
|
||||
const promises = {}
|
||||
for (const propName of Object.getOwnPropertyNames(module)) {
|
||||
if (without.includes(propName)) {
|
||||
continue
|
||||
}
|
||||
const propValue = module[propName]
|
||||
if (typeof propValue === 'function') {
|
||||
promises[propName] = promisify(propValue).bind(module)
|
||||
}
|
||||
}
|
||||
return promises
|
||||
}
|
||||
Reference in New Issue
Block a user