Open ErgerSusha opened 3 years ago
If you set space parameter and call stringifyAsync nested object and arrays are not indented properly. Here is a test suite, that confirms such behavior:
'use strict'; const yj = require('../index'); const tap = require('tap'); const obj = { name: 'Jacqueline Poole', gender: 'female', age: { value: 40 }, agesArray: [ 10, 20, 30 ] }; yj.stringifyAsync(obj, null, ' ', (err, str) => { if (!err) tap.equal(str, '{\n "name": "Jacqueline Poole",\n "gender": "female",\n "age": ' + '{\n "value": 40\n },\n "agesArray": [\n 10,\n 20,\n 30\n ]\n}'); else tap.fail(err); });
Output:
not ok 1 - should be equal --- found: |- { "name": "Jacqueline Poole", "gender": "female", "age": { "value": 40 }, "agesArray": [ 10, 20, 30 ] } wanted: |- { "name": "Jacqueline Poole", "gender": "female", "age": { "value": 40 }, "agesArray": [ 10, 20, 30 ] }
thanks @ErgerSusha for reporting this bug. I will look into it; and meanwhile feel free to come up with a PR, if you have ideas on how to fix it!
If you set space parameter and call stringifyAsync nested object and arrays are not indented properly. Here is a test suite, that confirms such behavior:
Output: