<commit_before>"use strict"

var fs = require('fs')
var slice = require('sliced')
var createShader = require('gl-shader')
var createContext = require('gl-context')
var ndarray = require('ndarray')
var display = require('gl-texture2d-display')
var createTexture = require("gl-texture2d")
var unpackFloat = require("glsl-read-float")

var draw = require('a-big-triangle')
var canvasPixels = require('canvas-pixels')

var fragSource = fs.readFileSync(__dirname + '/index.frag', 'utf8')
var vertSource = fs.readFileSync(__dirname + '/index.vert', 'utf8')

module.exports = function (a, b, c, d, operation) {
  var args = slice(arguments)
  return SaltMine(args.slice(0, -1), args.pop())
}

function SaltMine(datasets, operation) {
  var size = Math.ceil(datasets[0].length / 2)

  // setup canvas
  var canvas = document.createElement('canvas')
  canvas.height = size
  canvas.width = size

  // setup gl context
  var gl = createContext(canvas)

  gl.disable(gl.DEPTH_TEST)
  gl.disable(gl.CULL_FACE)

  enableFloatTextures(gl)

  // add body to fragment shader operation
  var updatedFragSource = replaceOperation(datasets, operation)

  var shader = createShader(gl, vertSource, updatedFragSource)

  var buffer = new Float32Array(size * size * 4)
  datasets.forEach(function(data, index) {
    loadChannel(buffer, data, index)
  })

  // load
  var texture = createTexture(gl, size, size, gl.RGBA, gl.FLOAT)
  texture.setPixels(ndarray(buffer, [size, size, 4]))
<commit_msg>Refactor operation order.<commit_after>"use strict"

var fs = require('fs')
var slice = require('sliced')
var createShader = require('gl-shader')
var createContext = require('gl-context')
var ndarray = require('ndarray')
var display = require('gl-texture2d-display')
var createTexture = require("gl-texture2d")
var unpackFloat = require("glsl-read-float")

var draw = require('a-big-triangle')
var canvasPixels = require('canvas-pixels')

var fragSource = fs.readFileSync(__dirname + '/index.frag', 'utf8')
var vertSource = fs.readFileSync(__dirname + '/index.vert', 'utf8')

module.exports = function (a, b, c, d, operation) {
  var args = slice(arguments)
  return SaltMine(args.slice(0, -1), args.pop())
}

function SaltMine(datasets, operation) {
  var size = Math.ceil(datasets[0].length / 2)

  // setup canvas
  var canvas = document.createElement('canvas')
  canvas.height = size
  canvas.width = size

  // setup gl context
  var gl = createContext(canvas)

  gl.disable(gl.DEPTH_TEST)
  gl.disable(gl.CULL_FACE)

  enableFloatTextures(gl)

  // add body to fragment shader operation
  var updatedFragSource = replaceOperation(datasets, operation)

  var shader = createShader(gl, vertSource, updatedFragSource)
  var texture = createTexture(gl, size, size, gl.RGBA, gl.FLOAT)

  var buffer = new Float32Array(size * size * 4)

  for (var i = 0, l = datasets.length; i < l; i ++) {
    var data = datasets[i];
    loadChannel(buffer, data, i)
  }

  // load
  texture.setPixels(ndarray(buffer, [size, size, 4]))

{'fraction_non_alphanumeric': 0.1375626043405676, 'fraction_numerical': 0.008347245409015025, 'mean_word_length': 4.568773234200743, 'pattern_counts': {'":': 0, '<': 4, '<?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': '5535807', 'n_tokens_mistral': 999, 'n_tokens_neox': 965, 'n_words': 250}