<commit_before>//
// Flambe - Rapid game development
// https://github.com/aduros/flambe/blob/master/LICENSE.txt

package flambe.platform.html;

import flambe.platform.Storage;

class HtmlStorage
    implements Storage
{
    public function new (storage :Dynamic)
    {
        _storage = storage;
    }

    public function set (key :String, value :String) :Bool
    {
        try {
            _storage.setItem(key, value);
        } catch (error :Dynamic) {
            // Browser may throw QUOTA_EXCEEDED_ERR
            return false;
        }
        return true;
    }

    public function get (key :String) :String
    {
        return _storage.getItem(key);
    }

    public function remove (key :String)
    {
        _storage.removeItem(key);
    }

    public function clear ()
    {
        _storage.clear();
    }

    private var _storage :Dynamic;
}<commit_msg>Prefix localStorage keys to prevent collisions with external JS.<commit_after>//
// Flambe - Rapid game development
// https://github.com/aduros/flambe/blob/master/LICENSE.txt

package flambe.platform.html;

import flambe.platform.Storage;

class HtmlStorage
    implements Storage
{
    public function new (storage :Dynamic)
    {
        _storage = storage;
    }

    public function set (key :String, value :String) :Bool
    {
        try {
            _storage.setItem(PREFIX + key, value);
        } catch (error :Dynamic) {
            // Browser may throw QUOTA_EXCEEDED_ERR
            return false;
        }
        return true;
    }

    public function get (key :String) :String
    {
        return _storage.getItem(PREFIX + key);
    }

    public function remove (key :String)
    {
        _storage.removeItem(PREFIX + key);
    }

    public function clear ()
    {
        _storage.clear();
    }

    // Prefix localStorage keys to prevent collisions with other JS on the page
    private static inline var PREFIX = "flambe:";

    private var _storage :Dynamic;
}
{'fraction_non_alphanumeric': 0.09516539440203563, 'fraction_numerical': 0.0, 'mean_word_length': 2.1556982343499196, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '5987577', 'n_tokens_mistral': 584, 'n_tokens_neox': 566, 'n_words': 159}