summaryrefslogtreecommitdiff
path: root/bin/fuzz-functions.js
diff options
context:
space:
mode:
Diffstat (limited to 'bin/fuzz-functions.js')
-rwxr-xr-xbin/fuzz-functions.js27
1 files changed, 27 insertions, 0 deletions
diff --git a/bin/fuzz-functions.js b/bin/fuzz-functions.js
new file mode 100755
index 0000000000..26a079d6d8
--- /dev/null
+++ b/bin/fuzz-functions.js
@@ -0,0 +1,27 @@
+#!/usr/bin/env node
+'use strict';
+
+var through = require('through2');
+var fuzzer = require('fuzzer');
+fuzzer.seed(0);
+
+module.exports = function() {
+ return through.obj(function(chunk, env, callback) {
+ var json = JSON.parse(chunk.toString());
+
+ json.constants = Object.keys(json.constants).reduce(function(obj, key, index) {
+ var value = json.constants[key];
+ if (typeof value === 'object' && value.hasOwnProperty('fn')) {
+ var mutator = fuzzer.mutate.object(value);
+ obj[key] = mutator();
+ }
+ return obj;
+ }, {});
+
+ var data = JSON.stringify(json);
+ this.push(data);
+ callback();
+ });
+};
+
+if (!module.parent) process.stdin.pipe(module.exports()).pipe(process.stdout);