Skip to content
This repository has been archived by the owner on Aug 23, 2022. It is now read-only.

Resolve strict comparison issue #2

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion index.js
Expand Up @@ -7,7 +7,8 @@ const CRLF = '\r\n'
const LF = '\n'

function stringifyPackage (data, indent, newline) {
const json = JSON.stringify(data, null, indent || DEFAULT_INDENT)
indent = indent || (indent === 0 ? 0 : DEFAULT_INDENT)
const json = JSON.stringify(data, null, indent)

if (newline === CRLF) {
return json.replace(/\n/g, CRLF) + CRLF
Expand Down
11 changes: 11 additions & 0 deletions test/nonformatted.js
@@ -0,0 +1,11 @@
'use strict'

const stringifyPackage = require('../index')
const test = require('tap').test

const dummy = { name: 'dummy' }

test('stringify-package', function (t) {
t.equal(stringifyPackage(dummy, 0).split(/\r\n|\r|\n/).length, 2, '0 works')
t.end()
})