Re: Re: Null-coalescing default values in destructuring

2019-05-11 Thread guest271314
Slightly less code (still un-golfed as that does not appear to be the stated requirement described at OP) using the same/similar pattern. let input_json_string = `{"z":null}`; const convertJSONNullToUndefined = json => { const o = JSON.parse(json); for (const key in o) if (o[key] === null) o[k

Re: Re: Null-coalescing default values in destructuring

2019-05-10 Thread guest271314
The bytes used for code can be reduced. Used redundancy in the original code to handle both cases at the actual examples at OP. ```JSON.stringify()``` and ```replace()``` could be used. The original proposal mentions ```JSON```, though includes the case of ``` const { y =? 'a' } = { y: undefined }

Re: Re: Null-coalescing default values in destructuring

2019-05-10 Thread Oliver Dunk
> Given input valid JSON JSON.parse() or JSON.stringify() replacer function can > be utilized to substitute "undefined" for null. guest271314, that’s a lot of code! It feels like if anything, your example backs up the proposal. > `const { z =? 'a' } = { z: null };` I’m not sure I like the prop

Re: Null-coalescing default values in destructuring

2019-05-02 Thread guest271314
Given input valid JSON JSON.parse() or JSON.stringify() replacer function can be utilized to substitute "undefined" for null. ``` const convertJSONNullToUndefined = json => Object.assign({} // if input is valid JSON string omit JSON.stringify(), use JSON.parse() with same replacer function /

Null-coalescing default values in destructuring

2019-05-02 Thread Cyril Auburtin
Similarly to ```js const { x = 'a' } = {}; // z === 'a' const { y = 'a' } = { y: undefined }; // z === 'a' const { z = 'a' } = { z: null }; // z === null ``` I'd like to propose ```js const { x =? 'a' } = {}; // z === 'a' const { y =? 'a' } = { y: undefined }; // z === 'a' const { z =? 'a' } = {