<commit_before>import Promise from 'bluebird'
import { Evernote } from 'evernote'

Promise.promisifyAll(Evernote.UserStoreClient.prototype)
Promise.promisifyAll(Evernote.NoteStoreClient.prototype)

const debug = require('debug')('evernote')

export default class EvernoteClient {
  constructor({ token, china = true, sandbox = false } = { china: true, sandbox: false }) {
    if (!token) {
      throw new Error('Missing developer token')
    }

    let serviceHost = china ? 'app.yinxiang.com' : 'www.evernote.com'
    serviceHost = sandbox ? 'sandbox.evernote.com' : serviceHost

    const options = { token, sandbox, serviceHost }
    debug('options: %o', options)
    this.options = options

    const client = new Evernote.Client(options)
    this.userStore = client.getUserStore()
    this.noteStore = client.getNoteStore()
  }

  listNotebooks() {
    return this.noteStore.listNotebooksAsync()
  }

  createNotebook(name) {
    const notebook = new Evernote.Notebook()
    notebook.name = name
    return this.noteStore.createNotebookAsync(notebook)
  }

  createNote(note) {
    return this.noteStore.createNoteAsync(note)
  }

  updateNote(note) {
    return this.noteStore.updateNoteAsync(note)
  }
}<commit_msg>fix: fix the promisify code of noteStore<commit_after>import Promise from 'bluebird'
import { Evernote } from 'evernote'

const debug = require('debug')('evernote')

export default class EvernoteClient {
  constructor({ token, china = true, sandbox = false } = { china: true, sandbox: false }) {
    if (!token) {
      throw new Error('Missing developer token')
    }

    let serviceHost = china ? 'app.yinxiang.com' : 'www.evernote.com'
    serviceHost = sandbox ? 'sandbox.evernote.com' : serviceHost

    const options = { token, sandbox, serviceHost }
    debug('options: %o', options)
    this.options = options

    const client = new Evernote.Client(options)
    this.noteStore = client.getNoteStore()

    if (!this.noteStore.listNotebooksAsync) {
      Promise.promisifyAll(this.noteStore)
    }
  }

  listNotebooks() {
    return this.noteStore.listNotebooksAsync()
  }

  createNotebook(name) {
    const notebook = new Evernote.Notebook()
    notebook.name = name
    return this.noteStore.createNotebookAsync(notebook)
  }

  createNote(note) {
    return this.noteStore.createNoteAsync(note)
  }

  updateNote(note) {
    return this.noteStore.updateNoteAsync(note)
  }
}
{'fraction_non_alphanumeric': 0.11406055578598093, 'fraction_numerical': 0.0, 'mean_word_length': 3.81437125748503, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3573858', 'n_tokens_mistral': 771, 'n_tokens_neox': 747, 'n_words': 163}