sindresorhus / npm-keyword

Get a list of npm packages with keywords
MIT License
52 stars 8 forks source link

`.count` crashes for a non-existent keyword #4

Closed tomek-he-him closed 9 years ago

tomek-he-him commented 9 years ago

Hi, while working at https://github.com/studio-b12/keyword-popularity/pull/1 I noticed that npmKeyword.count() chokes on a keyword that doesn’t exist.

Here’s what my REPL shouts:

npmKeyword.count('äąâ')
// …after a while:
TypeError: Cannot read property 'value' of undefined
    at …/node_modules/npm-keyword/index.js:64:19
    at …/node_modules/npm-keyword/index.js:24:3
    at …/node_modules/npm-keyword/node_modules/got/index.js:99:4
    at BufferStream.<anonymous> (…/node_modules/npm-keyword/node_modules/got/node_modules/read-all-stream/index.js:64:3)
    at BufferStream.emit (events.js:129:20)
    at finishMaybe (…/node_modules/npm-keyword/node_modules/got/node_modules/read-all-stream/node_modules/readable-stream/lib/_stream_writable.js:502:14)
    at afterWrite (…/node_modules/npm-keyword/node_modules/got/node_modules/read-all-stream/node_modules/readable-stream/lib/_stream_writable.js:381:3)
    at afterTick (…/node_modules/npm-keyword/node_modules/got/node_modules/read-all-stream/node_modules/readable-stream/node_modules/process-nextick-args/index.js:11:8)
    at process._tickDomainCallback (node.js:381:11)