File tree Expand file tree Collapse file tree 1 file changed +28
-1
lines changed
Expand file tree Collapse file tree 1 file changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -54,7 +54,8 @@ package.json:
5454``` js
5555const {
5656 parse ,
57- stringify
57+ stringify ,
58+ assign
5859} = require (' comment-json' )
5960const fs = require (' fs' )
6061
@@ -311,6 +312,32 @@ console.log(stringify(result)) // {"a":1}
311312console .log (stringify (result , null , 2 )) // is the same as `code`
312313` ` `
313314
315+ ## assign(target: object, source?: object, keys?: Array<string>)
316+
317+ - **target** ` object ` the target object
318+ - **source?** ` object ` the source object. This parameter is optional but it is silly to not pass this argument.
319+ - **keys?** ` Array <string >` If not specified, all enumerable own properties of ` source ` will be used.
320+
321+ This method is used to copy the enumerable own properties and their corresponding comment symbol properties to the target object.
322+
323+ ` ` ` js
324+ const parsed = parse (` {
325+ // This is a comment
326+ "foo": "bar"
327+ } ` )
328+
329+ const obj = assign ({
330+ bar: ' baz'
331+ }, parsed )
332+
333+ stringify (obj , null , 2 )
334+ // {
335+ // "bar": "baz",
336+ // // This is a comment
337+ // "foo": "bar"
338+ // }
339+ ` ` `
340+
314341## License
315342
316343[MIT](LICENSE)
You can’t perform that action at this time.
0 commit comments