cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

Quick-add: + add another resource

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              <head>
  <style>
    body { background-color: black; }
  </style>
</head>
<body>
</body>
            
          
!
            
              describe('Generators', function() {
  it('do we have to check for iterator.next().done?', function(done) {

    runGenerator(function* main() {
      var result1 = yield GetAsyncMethod1();
      console.log(result1);
      var result2 = yield GetAsyncMethod2();
      
      console.log("completed running");
    });
    expect(1).toBe(1);
    done()

  });

});

function GetAsyncMethod1() {
  return new Promise(function(resolve, reject) {
    setTimeout(function() {
      resolve("returned values from GetAsyncMethod1");
    }, 30)
  })
}

function GetAsyncMethod2() {
  return new Promise(function(resolve, reject) {
    setTimeout(function() {
      resolve();
    }, 30)
  })
}

function runGenerator(g) {
  var it = g(),
    ret;

  // asynchronously iterate over generator
  (function iterate(val) {
    ret = it.next(val);

    if (!ret.done) {
      // poor man's "is it a promise?" test
      if ("then" in ret.value) {
        // wait on the promise
        ret.value.then(iterate);
      }
      // immediate value: just send right back in
      else {
        // avoid synchronous recursion
        setTimeout(function() {
          iterate(ret.value);
        }, 0);
      }
    }
  })();
}
            
          
!
999px
Loading ..................

Console