Skip to content

Commit 49d9747

Browse files
Rokt33rwooorm
authored andcommitted
Return empty string for missing input
Related to GH-4. Closes GH-5. Reviewed-by: Christian Murphy <christian.murphy.42@gmail.com> Reviewed-by: Titus Wormer <tituswormer@gmail.com>
1 parent ee207ab commit 49d9747

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

Diff for: index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module.exports = stringify
77
function stringify(value) {
88
/* Nothing. */
99
if (!value || typeof value !== 'object') {
10-
return null
10+
return ''
1111
}
1212

1313
/* Node. */
@@ -26,7 +26,7 @@ function stringify(value) {
2626
}
2727

2828
/* ? */
29-
return null
29+
return ''
3030
}
3131

3232
function point(point) {

Diff for: readme.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ a node’s position.
5656
`string?` — A range `ls:cs-le:ce` (when given `node` or
5757
`position`) or a point `l:c` (when given `point`), where `l` stands
5858
for line, `c` for column, `s` for `start`, and `e` for
59-
end. `null` is returned if the given value is neither `node`,
59+
end. Empty string (`''`), is returned if the given value is neither `node`,
6060
`position`, nor `point`.
6161

6262
## Contribute

Diff for: test.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ var test = require('tape')
44
var stringify = require('.')
55

66
test('stringifyPosition', function(t) {
7-
t.equal(stringify(), null, 'should return `null` with `undefined`')
8-
t.equal(stringify(null), null, 'should return `null` with `null`')
9-
t.equal(stringify('foo'), null, 'should return `null` with `string`')
10-
t.equal(stringify(5), null, 'should return `null` with `number`')
11-
t.equal(stringify({}), null, 'should return `null` with `{}`')
7+
t.equal(stringify(), '', 'should return empty `string` with `undefined`')
8+
t.equal(stringify(null), '', 'should return empty `string` with `null`')
9+
t.equal(stringify('foo'), '', 'should return empty `string` with `string`')
10+
t.equal(stringify(5), '', 'should return empty `string` with `number`')
11+
t.equal(stringify({}), '', 'should return empty `string` with `{}`')
1212

1313
t.equal(
1414
stringify({type: 'text'}),

0 commit comments

Comments
 (0)