Skip to content

Instantly share code, notes, and snippets.

@tiagocpontesp
Created April 4, 2014 17:40
Show Gist options
  • Save tiagocpontesp/9979416 to your computer and use it in GitHub Desktop.
Save tiagocpontesp/9979416 to your computer and use it in GitHub Desktop.
readable variety
# wget https://raw.githubusercontent.com/variety/variety/master/variety.js
# i saved the json lines in file json_per_line, then:
# npm install JSONStream
# coffee this_file
# (sudo npm install -g coffee-script)
PERCENT = 50
console.log "\nExistent keys with at least present in at least #{PERCENT}% of docs:\n\n"
count = 0;
require('fs').createReadStream('./json_per_line').pipe(require('JSONStream').parse()).on('data', (line_object)->
parsed =
key: line_object._id.key
type: line_object.value.type
percent: line_object.percentContaining
if(parsed.percent >= PERCENT)
count++
console.log "#{Math.round(parsed.percent)}\t\t#{parsed.type}\t\t#{parsed.key}"
).on 'end', -> console.log "\n\nCOUNT: #{count}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment