mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-11-10 18:24:09 +03:00
Format undefined array values as null
This commit is contained in:
parent
f65e83fe2a
commit
84feaf369d
@ -58,6 +58,10 @@ describe "CSON", ->
|
||||
expect(CSON.stringify(a: ['b'])).toBe "'a': [\n 'b'\n]"
|
||||
expect(CSON.stringify(a: ['b', 4])).toBe "'a': [\n 'b'\n 4\n]"
|
||||
|
||||
describe "when the array has an undefined value", ->
|
||||
it "formats the undefined value as null", ->
|
||||
expect(CSON.stringify(['a', undefined, 'b'])).toBe "[\n 'a'\n null\n 'b'\n]"
|
||||
|
||||
describe "when formatting an object", ->
|
||||
describe "when the object is empty", ->
|
||||
it "returns the empty string", ->
|
||||
|
@ -28,7 +28,7 @@ module.exports =
|
||||
cson += @stringifyBoolean(value)
|
||||
else if _.isNumber(value)
|
||||
cson += @stringifyNumber(value)
|
||||
else if _.isNull(value)
|
||||
else if _.isNull(value) or value is undefined
|
||||
cson += @stringifyNull(value)
|
||||
else if _.isArray(value)
|
||||
cson += @stringifyArray(value, indentLevel + 2)
|
||||
|
Loading…
Reference in New Issue
Block a user