Skip to content

Instantly share code, notes, and snippets.

@mikemorris
Created April 11, 2013 19:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikemorris/5366632 to your computer and use it in GitHub Desktop.
Save mikemorris/5366632 to your computer and use it in GitHub Desktop.
return length of piped JSON array
#!/usr/bin/env node
var buffer = '';
process.stdin.on('data', function(data) {
buffer += data;
});
process.stdin.on('end', function() {
console.log(Array.prototype.slice.call(JSON.parse(buffer.toString())).length);
});
@neaumusic
Copy link

Why are you using Array.prototype.slice? Just curious

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment