js-fuzz
js-fuzz copied to clipboard
error running example. TypeError: content.getContent is not a function
When I try to run the example:
$ bin/js-fuzz ../fuzz.js
TypeError: content.getContent is not a function
at Log.List.add.List.addItem.List.appendItem (/Users/macbook/dev_fuzz/js-fuzz/node_modules/blessed/lib/widgets/list.js:297:61)
at Log.List.setItems (/Users/macbook/dev_fuzz/js-fuzz/node_modules/blessed/lib/widgets/list.js:384:12)
at Log.log (/Users/macbook/dev_fuzz/js-fuzz/node_modules/blessed-contrib/lib/widget/log.js:26:8)
at Stats.<anonymous> (/Users/macbook/dev_fuzz/js-fuzz/lib/src/Stats.js:203:66)
at emitOne (events.js:96:13)
at Stats.emit (events.js:191:7)
at Stats.log (/Users/macbook/dev_fuzz/js-fuzz/lib/src/Stats.js:76:14)
at Cluster.<anonymous> (/Users/macbook/dev_fuzz/js-fuzz/lib/src/Cluster.js:149:67)
at emitOne (events.js:96:13)
at Cluster.emit (events.js:191:7)
I assume this is about a parser error in the example. Try the following instead:
const JSON5 = require('json5')
exports.fuzz = input => {
input = input.toString('utf8') // we give you buffers by default
let isPlainJSON = true
let isJSON5 = true
try { JSON.parse(input) } catch (e) { isPlainJSON = false }
try { JSON5.parse(input) } catch (e) { isJSON5 = false }
// We catch and thrown errors and mark them as failures
if (isPlainJSON && !isJSON5) {
throw new Error('Found a string that was JSON but not JSON5');
}
return isPlainJSON ? 1 : 0
}