Skip to content

Commit 4a93553

Browse files
committed
Change to return undefined, not null
1 parent 770665b commit 4a93553

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

lib/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Get a definition by identifier.
99
* @param {string | null | undefined} [identifier]
1010
* Identifier of definition (optional).
11-
* @returns {Definition | null}
11+
* @returns {Definition | undefined}
1212
* Definition corresponding to `identifier` or `null`.
1313
*/
1414

@@ -48,7 +48,7 @@ export function definitions(tree) {
4848
function definition(identifier) {
4949
const id = clean(identifier)
5050
// To do: next major: return `undefined` when not found.
51-
return id && own.call(cache, id) ? cache[id] : null
51+
return id && own.call(cache, id) ? cache[id] : undefined
5252
}
5353
}
5454

readme.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ definition('example')
7373
// => {type: 'definition', 'title': 'Example', …}
7474

7575
definition('foo')
76-
// => null
76+
// => undefined
7777
```
7878

7979
## API
@@ -109,7 +109,7 @@ Get a definition by identifier (TypeScript type).
109109
###### Returns
110110

111111
Definition corresponding to `identifier` ([`Definition`][definition]) or
112-
`null`.
112+
`undefined`.
113113

114114
## Types
115115

test.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ test('definitions', async function (t) {
3838
)
3939
})
4040

41-
await t.test('should return null when not found', async function () {
41+
await t.test('should return `undefined` when not found', async function () {
4242
assert.equal(
4343
definitions(from('[example]: https://example.com "Example"'))('foo'),
44-
null
44+
undefined
4545
)
4646
})
4747

@@ -75,7 +75,7 @@ test('definitions', async function (t) {
7575
async function () {
7676
assert.deepEqual(
7777
definitions(from('[__proto__]: https://proto.com "Proto"'))('toString'),
78-
null
78+
undefined
7979
)
8080
}
8181
)
@@ -98,7 +98,7 @@ test('definitions', async function (t) {
9898
definitions(
9999
from('[example]: https://one.com\n[example]: https://two.com')
100100
)(''),
101-
null
101+
undefined
102102
)
103103
}
104104
)

0 commit comments

Comments
 (0)