From a7b184dabed08ab7830056a4d641ee0f412c0670 Mon Sep 17 00:00:00 2001 From: Junyoung Choi Date: Fri, 4 Jan 2019 23:48:49 +0900 Subject: [PATCH 1/3] Returns empty string with invalid input --- index.js | 4 ++-- test.js | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index 3be1e14..17a02da 100644 --- a/index.js +++ b/index.js @@ -7,7 +7,7 @@ module.exports = stringify function stringify(value) { /* Nothing. */ if (!value || typeof value !== 'object') { - return null + return '' } /* Node. */ @@ -26,7 +26,7 @@ function stringify(value) { } /* ? */ - return null + return '' } function point(point) { diff --git a/test.js b/test.js index 6f64f4b..84d32e4 100644 --- a/test.js +++ b/test.js @@ -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'}), From 06a85134316026d8173b21961d0986da677935b0 Mon Sep 17 00:00:00 2001 From: Junyoung Choi Date: Sat, 5 Jan 2019 05:12:15 +0900 Subject: [PATCH 2/3] Update readme.md --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 973534d..12ed164 100644 --- a/readme.md +++ b/readme.md @@ -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 From c40f0dc1938c9053f1f4a5d0ecca348074544cfe Mon Sep 17 00:00:00 2001 From: Titus Date: Sat, 5 Jan 2019 06:11:23 +0900 Subject: [PATCH 3/3] Update readme.md Co-Authored-By: Rokt33r --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 12ed164..1866400 100644 --- a/readme.md +++ b/readme.md @@ -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. empty string, `''`, 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