Transforms util.promisify
to a function definition
for node versions < 8, automatically detects if node version >= 8 and does nothing if so.
npm install babel-plugin-transform-util-promisify --save-dev
Add at the top of plugins in .babelrc
:
{
"plugins": [
"transform-util-promisify"
],
"presets": [
["env", {
"targets": {
"node": "current"
}
}]
]
}
The plugin currently transforms code only in these forms:
import { promisify } from 'util';
and
const { promisify } = require('promisify');