7 use File::Slurp 'read_file';
11 my $source = readline;
13 for ($source) { # cleanup
14 s/\A\(// and s/\);?\s*\Z//; # empty callback
15 next if /^\{/; # valid json
17 # convert seperate variables to hash keys
19 s/^caniuse\.(\w+) *= */"$1":/gm;
22 # fractions not supported by barekey
23 s/(?<=[,{\n]) (\d*\.\d) (?=:['"])/"$1"/gx;
24 # escapes not supported in singlequote
25 s{: *\K'((?:[^\\']+|\\.)*)'}{
33 my $data = from_json($source, {
34 allow_singlequote => 1,
44 convert-caniuse - Turn Javascript data into an equivalent Perl structure
48 curl http://caniuse.com/jsonp.php |
49 tools/convert-caniuse.pl > browser-support.inc.pl