Take the 2-minute tour ×
Code Review Stack Exchange is a question and answer site for peer programmer code reviews. It's 100% free, no registration required.

I have something roughly like this:

# define a function to operate on `Post` queries
Post.defineStatic "postListing", (options) ->
  query = @


  query = query.orderBy args

  if options.condition
    query = query.filter args

  query = query.splice args
  query = query.getJoin args


  # return the in-progress query
  query

I wanted to do it like this, but the library I'm using won't let me:

Post.defineStatic "postListing", (options) ->
  @orderBy args

  if options.condition
    @filter args

  @splice args
  @getJoin args
  # the above line would implicitly return the query

Is there a way to write the first snippet in a cleaner way, maybe with es6 generators? I've tried using a shorter variable name like q but that just makes it messy.

share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.