Created
October 30, 2011 07:21
-
-
Save luk-/1325646 to your computer and use it in GitHub Desktop.
Small script used to convert text list of JS events to JSON
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fs = require('fs'); | |
var file; | |
var obj = new Object; | |
fs.readFile('events.txt', 'utf8', function (err, data) { | |
if (err) { | |
return console.log(err); | |
} | |
file = data.split("\n"); | |
for (i in file) { | |
var arr = file[i].split(' '); | |
var localObj = { | |
name: arr[0], | |
bubbles: arr[1], | |
cancel: arr[2] | |
}; | |
obj[localObj.name] = { | |
bubbles: localObj.bubbles, | |
cancel: localObj.cancel | |
}; | |
} | |
console.log(JSON.stringify(obj)); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Text file was formatted like:
etc