Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add onEnd handler or then promise #73

Open
a-x- opened this issue Jul 4, 2016 · 1 comment
Open

Add onEnd handler or then promise #73

a-x- opened this issue Jul 4, 2016 · 1 comment

Comments

@a-x-
Copy link

a-x- commented Jul 4, 2016

I use estraverse look for a specific node and I return the promise.
I cannot throw reject on traverse complete without workarounds.

function retrieveBemEntity (fileContent, offset) {
  return new Promise(function (res, err) {
    var ast = parse.parseExpressionAt(fileContent.substr(offset));
    traverse.traverse(ast, {enter: function (node) {
      var bemEntity = _onNode(node);
      if (bemEntity) res(bemEntity), this.break();
    }});
    setTimeout(()=>err('not found'), 100); // todo add traverse.traverse on end handler
  });
}
@a-x-
Copy link
Author

a-x- commented Jul 10, 2017

ping

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant