S
S
Svyatoslav Khusamov2016-07-28 17:38:47
Node.js
Svyatoslav Khusamov, 2016-07-28 17:38:47

How to comment on a method that returns a promise?

How to post a comment?
The rules are to write it like this:

/**
   * Проверка файла. Возвращает true в промисе, если файл изменен.
   * @return {Promise} 
   */
  checkPageFileChangeTime() {
    let me = this;
    return new Promise((resolve, reject) => {
      if (!me._ctime) return resolve(true);
      fs.stat(me._filename, (err, stats) => {
        if (err) reject(err); else resolve(me._ctime < stats.ctime);
      });
    });
  }

But it was nice to specify the type of data that will be returned in the promise, in this case Boolean. And perhaps the name of the data, such as isChanged.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
napa3um, 2016-07-28
@khusamov

https://github.com/jsdoc3/jsdoc/issues/509

Z
Zakhar Orlov, 2016-07-28
@divalign

The data type can be specified like this:@return {Promise<boolean>}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question