<commit_before><commit_msg>added battery support<commit_after>import js.Browser;
import js.html.BatteryManager;
import js.html.Navigator;

@:expose @:keep class BatterySupport {

    public var isSupported:Bool;
    public var battery:BatteryManager;

    var _navigator:Navigator;

    public function new(?ready:Void -> Void) {
        _navigator = Browser.navigator;
        battery = _navigator.battery;
        if (battery == null) battery = Reflect.field(_navigator, "webkitBattery");
        if (battery == null) battery = Reflect.field(_navigator, "mozBattery");
        isSupported = (battery != null);
        if (battery == null && Reflect.field(_navigator, "getBattery") != null) {
            untyped __js__("window.navigator").getBattery().then(function(b) {
                battery = b;
                isSupported = true;
                if (ready != null) ready();
            });
        }
        else {
            if (ready != null) ready();
        }
    }
}
{'fraction_non_alphanumeric': 0.12448979591836734, 'fraction_numerical': 0.0, 'mean_word_length': 2.454225352112676, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7448315', 'n_tokens_mistral': 291, 'n_tokens_neox': 282, 'n_words': 64}