<html>
    <head>
        <script src="https://www.promisejs.org/polyfills/promise-7.0.1.min.js"></script>
        <script src="http://requirejs.org/docs/release/2.1.2/minified/require.js"></script>
    </head>

    <body>
        <h1>Open the console</h1>
        <script>
        
////        Here is a deferred approach using the Bluebird Promisify wrapper
            // callback is provided by the promisfy wrapper and data is provided by the call to the promisified function.
            function funcToPromisify( data, callback ) {
                //do something with data
                console.log('running:', data);
                callback( { foo: 1 } , data );
            }

            require(['https://cdnjs.cloudflare.com/ajax/libs/bluebird/2.10.1/bluebird.js'], function( Promise ) {

                var testPromisify = Promise.promisify( funcToPromisify );

                testPromisify(( { foobar: 1 } ))
                .then( function( data ) {
                    console.log( 'then', data );
                }).catch(function(e) {
                    console.log("Error:", e);
                });

            });

        </script>

    </body>
</html>