Skip to content

Returns empty string with invalid input #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = stringify
function stringify(value) {
/* Nothing. */
if (!value || typeof value !== 'object') {
return null
return ''
}

/* Node. */
Expand All @@ -26,7 +26,7 @@ function stringify(value) {
}

/* ? */
return null
return ''
}

function point(point) {
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ a node’s position.
`string?` — A range `ls:cs-le:ce` (when given `node` or
`position`) or a point `l:c` (when given `point`), where `l` stands
for line, `c` for column, `s` for `start`, and `e` for
end. `null` is returned if the given value is neither `node`,
end. Empty string (`''`), is returned if the given value is neither `node`,
`position`, nor `point`.

## Contribute
Expand Down
10 changes: 5 additions & 5 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ var test = require('tape')
var stringify = require('.')

test('stringifyPosition', function(t) {
t.equal(stringify(), null, 'should return `null` with `undefined`')
t.equal(stringify(null), null, 'should return `null` with `null`')
t.equal(stringify('foo'), null, 'should return `null` with `string`')
t.equal(stringify(5), null, 'should return `null` with `number`')
t.equal(stringify({}), null, 'should return `null` with `{}`')
t.equal(stringify(), '', 'should return empty `string` with `undefined`')
t.equal(stringify(null), '', 'should return empty `string` with `null`')
t.equal(stringify('foo'), '', 'should return empty `string` with `string`')
t.equal(stringify(5), '', 'should return empty `string` with `number`')
t.equal(stringify({}), '', 'should return empty `string` with `{}`')

t.equal(
stringify({type: 'text'}),
Expand Down