/**
 * Turn a callback function into a promise function.
 */ export default function run ( context , method , args ? ) { if ( ! Array . isArray ( args ) ) { args = [ args ] ; } return new Promise ( ( resolve , reject ) => { method . apply ( context , args . concat ( [ ( err , ... rest ) => { if ( err ) { reject ( err ) ; return ; } resolve . apply ( null , rest ) ; } , ] ) ) ; } ) ; } export function map ( context , method , items ) { return Promise . all ( items . map ( ( item ) => { return run ( context , method , item ) ; } ) ) ; }