Closed WillsterJohnson closed 1 year ago
Relevant: https://github.com/xDimGG/node-steamapi/blob/e900bc5cb746176744f5d81fe3bcd7f0547f5810/src/utils/objectify.js#L10
The example in the JSDoc states the following as an example
[{ name: 'a', value: 'b', other: 'c' }, { name: 'b', value: 'c', other: 'd' }] // To { a: { value: 'b', other: 'c' }, b: { value: 'c', other: 'd' } }
Using a copy-paste of the function to more easily dump this into the Node repl;
Welcome to Node.js v18.16.0. Type ".help" for more information. > const objectify = (arr, val = 'value', key = 'name', boolean = false) => { ... const object = {}; ... for (const obj of arr) ... object[obj[key]] = boolean ? Boolean(obj[val]) : obj[val]; ... ... return object; ... }; undefined > > objectify([{ name: 'a', value: 'b', other: 'c' }, { name: 'b', value: 'c', other: 'd' }]); { a: 'b', b: 'c' }
The stated output is
{ a: { value: 'b', other: 'c' }, b: { value: 'c', other: 'd' } }
The actual output is
{ a: 'b', b: 'c' }
Is the doccomment example incorrect, or is the function incorrectly implemented? Judging by the args I'd guess the example is incorrect, but it's difficult to tell without documentation.
Nice catch. Yeah it seems like the documentation is incorrect. I'll just remove that part. Thank you!
Relevant: https://github.com/xDimGG/node-steamapi/blob/e900bc5cb746176744f5d81fe3bcd7f0547f5810/src/utils/objectify.js#L10
The example in the JSDoc states the following as an example
Using a copy-paste of the function to more easily dump this into the Node repl;
The stated output is
The actual output is
Is the doccomment example incorrect, or is the function incorrectly implemented? Judging by the args I'd guess the example is incorrect, but it's difficult to tell without documentation.