Skip to content

Commit 0067b0d

Browse files
committed
Add .type setter
1 parent 2347313 commit 0067b0d

File tree

3 files changed

+25
-9
lines changed

3 files changed

+25
-9
lines changed

index.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,15 @@ class Attribute {
7070
return this.#type
7171
}
7272

73+
/**
74+
* Set the attribute name.
75+
*
76+
* @param {string} name
77+
*/
78+
set type (name) {
79+
this.#type = name
80+
}
81+
7382
/**
7483
* The set of attribute values as strings.
7584
*

index.test.js

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,21 @@ tap.test('.buffers', t => {
160160
t.end()
161161
})
162162

163+
tap.test('.type', t => {
164+
t.test('gets and sets', async t => {
165+
const attr = new Attribute(({
166+
type: 'foo',
167+
values: ['bar']
168+
}))
169+
170+
t.equal(attr.type, 'foo')
171+
attr.type = 'bar'
172+
t.equal(attr.type, 'bar')
173+
})
174+
175+
t.end()
176+
})
177+
163178
tap.test('toBer', async t => {
164179
t.test('renders type with values', async t => {
165180
const attr = new Attribute({
@@ -328,14 +343,6 @@ tap.test('#isAttribute', t => {
328343
t.equal(Attribute.isAttribute(input), false)
329344
})
330345

331-
// const isA = Attribute.isAttribute
332-
// t.notOk(isA(null))
333-
// t.notOk(isA('asdf'))
334-
// t.ok(isA(new Attribute({
335-
// type: 'foobar',
336-
// values: ['asdf']
337-
// })))
338-
339346
t.end()
340347
})
341348

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"name": "@ldapjs/attribute",
88
"homepage": "https://github.com/ldapjs/attribute",
99
"description": "API for handling LDAP entry attributes",
10-
"version": "1.0.0-rc.2",
10+
"version": "1.0.0-rc.3",
1111
"license": "MIT",
1212
"repository": {
1313
"type": "git",

0 commit comments

Comments
 (0)