<commit_before>// FIXME make API similar to Facet.attribute_buffer
Facet.element_buffer = function(vertex_array)
{
    var ctx = Facet._globals.ctx;
    var result = ctx.createBuffer();
    ctx.bindBuffer(ctx.ELEMENT_ARRAY_BUFFER, result);
    var typedArray = new Uint16Array(vertex_array);
    ctx.bufferData(ctx.ELEMENT_ARRAY_BUFFER, typedArray, ctx.STATIC_DRAW);
    result._shade_type = 'element_buffer';
    result.array = typedArray;
    result.itemSize = 1;
    result.numItems = vertex_array.length;

    //////////////////////////////////////////////////////////////////////////
    // These methods are only for internal use within Facet

    result.bind = function() {
        ctx.bindBuffer(ctx.ELEMENT_ARRAY_BUFFER, this);
    };<commit_msg>element buffer has set method like attribute buffer<commit_after>// FIXME make API similar to Facet.attribute_buffer
Facet.element_buffer = function(vertex_array)
{
    var ctx = Facet._globals.ctx;
    var result = ctx.createBuffer();
    var typedArray = new Uint16Array(vertex_array);
    result._ctx = ctx;
    result._shade_type = 'element_buffer';
    result.itemSize = 1;

    //////////////////////////////////////////////////////////////////////////
    // These methods are only for internal use within Facet

    result.set = function(vertex_array) {
        Facet.set_context(ctx);
        var typedArray;
        if (vertex_array.constructor.name === 'Array') {
            typedArray = new Uint16Array(vertex_array);
        } else {
            if (vertex_array.constructor !== Uint16Array) {
                throw "Facet.element_buffer.set requires either a plain list or a Uint16Array";
            }
            typedArray = vertex_array;
        }
        ctx.bindBuffer(ctx.ELEMENT_ARRAY_BUFFER, this);
        ctx.bufferData(ctx.ELEMENT_ARRAY_BUFFER, typedArray, ctx.STATIC_DRAW);
        this.array = typedArray;
        this.numItems = typedArray.length;
    };
    result.set(vertex_array);

    result.bind = function() {
        ctx.bindBuffer(ctx.ELEMENT_ARRAY_BUFFER, this);
    };
{'fraction_non_alphanumeric': 0.1623062015503876, 'fraction_numerical': 0.005813953488372093, 'mean_word_length': 2.2777777777777777, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4597345', 'n_tokens_mistral': 584, 'n_tokens_neox': 572, 'n_words': 127}