ndjson-cli icon indicating copy to clipboard operation
ndjson-cli copied to clipboard

Support object spread syntax ({...d, }) in ndjson-map

Open stevage opened this issue 6 years ago • 2 comments

It would be really convenient if you could do this:

ndjson-map '{...d, newProp: 3}'

It currently throws an error:

ndjson-map:expression
({...d, newProp: 3})
^
SyntaxError: Unexpected token (1:3)

The current workaround is:

ndjson-map 'd.newProp = 3, d'

or

ndjson-map 'Object.assign(d, {newProp: 3})'

which feels less elegant.

stevage avatar Jan 17 '20 20:01 stevage

I think we’d just need to update the version of Acorn and configure the ecmaVersion to allow new language features.

mbostock avatar Jan 17 '20 21:01 mbostock

The currently used acorn version (^5.1.1, resolving to 5.7.4) already supports ECMAScript 9 a.k.a. ES2018. It doesn't make sense to parse expressions that the built-in vm module wouldn't be able to parse/run; What is the lowest Node.js version this package is supposed to support?

Node.js >= 8.3.0 support the spread operator in objects.

derhuerst avatar Jun 03 '20 23:06 derhuerst