<commit_before>package ida.backend.idb;
import tannus.ds.*;
import tannus.html.Win;
import tannus.html.fs.*;

import js.html.idb.*;
import haxe.extern.EitherType in Either;

import ida.Utils;

using Lambda;

class IDBDatabase {
	/* Constructor Function */
	public function new(d : Database):Void {
		db = d;
	}

/* === Instance Methods === */

	/**
	  * Create and return a new ObjectStore
	  */
	public function createObjectStore(name:String, ?options:CreateObjectStoreOptions) {
		var _store = db.createObjectStore(name, options);
		return new IDBObjectStore( _store );
	}

	public inline function deleteObjectStore(name : String):Void {
	    db.deleteObjectStore( name );
	}

	public function hasObjectStore(name : String):Bool {
	    return objectStoreNames.has( name );
	}

	/**
	  * Create and return a new Transaction object
	  */
	public function transaction(stores:Either<String, Array<String>>, ?mode:TransactionMode):IDBTransaction {
		if (mode == null) mode = ReadOnly;
		return new IDBTransaction(db.transaction(stores, untyped mode));
	}

	/**
	  * Create and return a new MutableFile
	  */
	/*
	public function createMutableFile(name:String, ?type:String):Promise<Dynamic> {
		db.createMutableFile(name, type).fulfill();
	}
	*/

/* === Computed Instance Fields === */

    public var version(get, never):Int;
    private inline function get_version():Int return db.version;

/* === Instance Fields === */

	public var db : Database;

/* === Static Methods === */

	/**
	  * Attempt to open a database by name
	  */
	public static function open(name:String, version:Int, ?_build:IDBDatabase->Void):Promise<IDBDatabase> {
		var w = Win.current;
		return Promise.create({
			var request = w.indexedDB.open(name, version);
			request.onupgradeneeded = function(event) {
				if (_build != null) {<commit_msg>added 'objectStoreNames' field to ida.Database<commit_after>package ida.backend.idb;
import tannus.ds.*;
import tannus.html.Win;
import tannus.html.fs.*;

import js.html.idb.*;
import haxe.extern.EitherType in Either;

import ida.Utils;

using Lambda;

class IDBDatabase {
	/* Constructor Function */
	public function new(d : Database):Void {
		db = d;
	}

/* === Instance Methods === */

	/**
	  * Create and return a new ObjectStore
	  */
	public function createObjectStore(name:String, ?options:CreateObjectStoreOptions) {
		var _store = db.createObjectStore(name, options);
		return new IDBObjectStore( _store );
	}

	public inline function deleteObjectStore(name : String):Void {
	    db.deleteObjectStore( name );
	}

	public function hasObjectStore(name : String):Bool {
	    return objectStoreNames.has( name );
	}

	/**
	  * Create and return a new Transaction object
	  */
	public function transaction(stores:Either<String, Array<String>>, ?mode:TransactionMode):IDBTransaction {
		if (mode == null) mode = ReadOnly;
		return new IDBTransaction(db.transaction(stores, untyped mode));
	}

	/**
	  * Create and return a new MutableFile
	  */
	/*
	public function createMutableFile(name:String, ?type:String):Promise<Dynamic> {
		db.createMutableFile(name, type).fulfill();
	}
	*/

/* === Computed Instance Fields === */

    public var version(get, never):Int;
    private inline function get_version():Int return db.version;

    public var objectStoreNames(get, never):Array<String>;
    private function get_objectStoreNames():Array<String> {
        return (untyped (untyped __js__('Array.prototype.slice.call')(db.objectStoreNames, 0)));
    }

/* === Instance Fields === */

	public var db : Database;

/* === Static Methods === */

	/**
	  * Attempt to open a database by name
	  */
	public static function open(name:String, version:Int, ?_build:IDBDatabase->Void):Promise<IDBDatabase> {
		var w = Win.current;
		return Promise.create({
			var request = w.indexedDB.open(name, version);
			request.onupgradeneeded = function(event) {
				if (_build != null) {
{'fraction_non_alphanumeric': 0.1328365878725591, 'fraction_numerical': 0.00025693730729701953, 'mean_word_length': 4.102228047182176, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, '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': '1443431', 'n_tokens_mistral': 1286, 'n_tokens_neox': 1209, 'n_words': 304}