function readShortPagesIndex() {
  return fs.readJson(shortIndexFile)
    .then((idx) => {
      shortIndex = idx;
      return shortIndex;
    })
    .catch(() => {
      // File is not present; we need to create the index.
      return buildShortPagesIndex().then((idx) => {
        if (Object.keys(idx).length <= 0) {
          return idx;
        }
        shortIndex = idx;
        return fs.writeJson(shortIndexFile, shortIndex).then(() => {
          return shortIndex;
        });
      });
    });
}
// and load it into memory.
and load it into memory.
and load it into memory .
function readShortPagesIndex() {
  return fs.readJson(shortIndexFile)
    .then((idx) => {
      shortIndex = idx;
      return shortIndex;
    })
    .catch(() => {
      return buildShortPagesIndex().then((idx) => {
        if (Object.keys(idx).length <= 0) {
          return idx;
        }
        shortIndex = idx;
        return fs.writeJson(shortIndexFile, shortIndex).then(() => {
          return shortIndex;
        });
      });
    });
}
function readShortPagesIndex ( ) { return fs . readJson ( shortIndexFile ) . then ( ( idx ) => { shortIndex = idx ; return shortIndex ; } ) . catch ( ( ) => { return buildShortPagesIndex ( ) . then ( ( idx ) => { if ( Object . keys ( idx ) . length <= 0 ) { return idx ; } shortIndex = idx ; return fs . writeJson ( shortIndexFile , shortIndex ) . then ( ( ) => { return shortIndex ; } ) ; } ) ; } ) ; }
and load it into memory.
and load it into memory .
// File is not present; we need to create the index.