Skip to content

Commit

Permalink
add table.rows.clear() method
Browse files Browse the repository at this point in the history
  • Loading branch information
ttemple06 authored and dhensby committed Nov 22, 2021
1 parent 275e6d7 commit 63ab77f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/table.js
Expand Up @@ -48,6 +48,13 @@ function Table (name) {
}
}
)

Object.defineProperty(this.rows, 'clear', {
value () {
return this.splice(0, this.length)
}
}
)
}

/*
Expand Down
3 changes: 3 additions & 0 deletions test/common/unit.js
Expand Up @@ -140,6 +140,9 @@ describe('Unit', () => {
assert.deepStrictEqual(t.rows[3], [12, 'XCXCDCDSCDSC'])
assert.strictEqual(t.temporary, false)

t.rows.clear()
assert.strictEqual(t.rows.length, 0)

t = new sql.Table('schm.MyTable')

assert.strictEqual(t.name, 'MyTable')
Expand Down

0 comments on commit 63ab77f

Please sign in to comment.