You can pipe into Node.js (#tilPost)

In July 2017 I wrote about ways to execute JavaScript snippets from your clipboard using process substitution. The snippet that I’m using since then to execute JavaScript snippets quickly is the following…
$ node <(pbpaste)

To…

In July 2017 I wrote about ways to execute JavaScript snippets from your clipboard using process substitution. The snippet that I’m using since then to execute JavaScript snippets quickly is the following…

$ node <(pbpaste)

Today I came across a tweet by Julian Gruber and it turns out you use the pipe operator with the Node.js binary directly.

$ pbpaste | node

The result is the same but it looks nicer and feels better that using process substituion (<(...)). I have no idea how I missed this Node.js detail and checked the previous versions of Node.js and it works going down to Node.js v4 (that’s what I have available on my machine). Good to know!



Reply to Stefan


Print Share Comment Cite Upload Translate
APA
Stefan Judis | Sciencx (2024-03-28T13:56:51+00:00) » You can pipe into Node.js (#tilPost). Retrieved from https://www.scien.cx/2018/09/22/you-can-pipe-into-node-js-tilpost/.
MLA
" » You can pipe into Node.js (#tilPost)." Stefan Judis | Sciencx - Saturday September 22, 2018, https://www.scien.cx/2018/09/22/you-can-pipe-into-node-js-tilpost/
HARVARD
Stefan Judis | Sciencx Saturday September 22, 2018 » You can pipe into Node.js (#tilPost)., viewed 2024-03-28T13:56:51+00:00,<https://www.scien.cx/2018/09/22/you-can-pipe-into-node-js-tilpost/>
VANCOUVER
Stefan Judis | Sciencx - » You can pipe into Node.js (#tilPost). [Internet]. [Accessed 2024-03-28T13:56:51+00:00]. Available from: https://www.scien.cx/2018/09/22/you-can-pipe-into-node-js-tilpost/
CHICAGO
" » You can pipe into Node.js (#tilPost)." Stefan Judis | Sciencx - Accessed 2024-03-28T13:56:51+00:00. https://www.scien.cx/2018/09/22/you-can-pipe-into-node-js-tilpost/
IEEE
" » You can pipe into Node.js (#tilPost)." Stefan Judis | Sciencx [Online]. Available: https://www.scien.cx/2018/09/22/you-can-pipe-into-node-js-tilpost/. [Accessed: 2024-03-28T13:56:51+00:00]
rf:citation
» You can pipe into Node.js (#tilPost) | Stefan Judis | Sciencx | https://www.scien.cx/2018/09/22/you-can-pipe-into-node-js-tilpost/ | 2024-03-28T13:56:51+00:00
https://github.com/addpipe/simple-recorderjs-demo