<commit_before>const assert = require('assert')
const Cursor = require('../')
const pg = require('pg')

const text = 'SELECT generate_series as num FROM generate_series(0, 50)'
describe('close', function() {
  beforeEach(function(done) {
    const client = (this.client = new pg.Client())
    client.connect(done)
    client.on('drain', client.end.bind(client))
  })

  it('can close a finished cursor without a callback', function(done) {
    const cursor = new Cursor(text)
    this.client.query(cursor)
    this.client.query('SELECT NOW()', done)
    cursor.read(100, function (err, res) {
      assert.ifError(err)
      cursor.close()
    })
  })


  it('closes cursor early', function(done) {
    const cursor = new Cursor(text)
    this.client.query(cursor)
    this.client.query('SELECT NOW()', done)
    cursor.read(25, function(err) {
      assert.ifError(err)
      cursor.close()
    })
  })

  it('works with callback style', function(done) {
    const cursor = new Cursor(text)
    const client = this.client
    client.query(cursor)
    cursor.read(25, function(err) {
      assert.ifError(err)
      cursor.close(function(err) {
        assert.ifError(err)
        client.query('SELECT NOW()', done)
      })
    })<commit_msg>fix lint issues<commit_after>const assert = require('assert')
const Cursor = require('../')
const pg = require('pg')

const text = 'SELECT generate_series as num FROM generate_series(0, 50)'
describe('close', function() {
  beforeEach(function(done) {
    const client = (this.client = new pg.Client())
    client.connect(done)
    client.on('drain', client.end.bind(client))
  })

  it('can close a finished cursor without a callback', function(done) {
    const cursor = new Cursor(text)
    this.client.query(cursor)
    this.client.query('SELECT NOW()', done)
    cursor.read(100, function(err) {
      assert.ifError(err)
      cursor.close()
    })
  })

  it('closes cursor early', function(done) {
    const cursor = new Cursor(text)
    this.client.query(cursor)
    this.client.query('SELECT NOW()', done)
    cursor.read(25, function(err) {
      assert.ifError(err)
      cursor.close()
    })
  })

  it('works with callback style', function(done) {
    const cursor = new Cursor(text)
    const client = this.client
    client.query(cursor)
    cursor.read(25, function(err) {
      assert.ifError(err)
      cursor.close(function(err) {
        assert.ifError(err)
        client.query('SELECT NOW()', done)
      })
    })
{'fraction_non_alphanumeric': 0.1479242241031842, 'fraction_numerical': 0.008061265618702136, 'mean_word_length': 3.2354948805460753, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '2827050', 'n_tokens_mistral': 803, 'n_tokens_neox': 775, 'n_words': 178}