<commit_before>"use strict"

const expect = require('expect')
const createVerge2VspLoader = require('./createVerge2VspLoader')
const fill = require('lodash/fill')

const vspVersion = 3
const vspPalette = fill(Array(256 * 3), 77)
const vspNumTiles = 3
const vspImageData = [
  ...fill(Array(128), 44), ...fill(Array(128), 55),
  ...fill(Array(128), 66), ...fill(Array(128), 77),
  ...fill(Array(128), 88), ...fill(Array(128), 99),
]

const vspAnimationList = fill(Array(100), {
  start: 4,
  finish: 3,
  delay: 2,
  mode: 1,
})

{
  // can read vsp
  const loader = createVerge2VspLoader({
    data: Buffer.concat([
      Buffer.from(new Uint16Array([vspVersion]).buffer),
      Buffer.from(vspPalette),
      Buffer.from(new Uint16Array([vspNumTiles]).buffer),
      // compressed image data
      Buffer.from(new Uint32Array([6 * 3]).buffer),
      Buffer.from([
        0xff, 128, 44, 0xff, 128, 55,
        0xff, 128, 66, 0xff, 128, 77,
        0xff, 128, 88, 0xff, 128, 99
      ]),
      ...vspAnimationList.map((vspAnimation) => {
        return Buffer.from(new Uint16Array([
          vspAnimation.start,
          vspAnimation.finish,
          vspAnimation.delay,
          vspAnimation.mode,
        ]).buffer)
      }),
    ])
  })

  const data = loader.load()

  expect(data.version).toBe(vspVersion)
  expect(data.palette).toEqual(vspPalette)
  expect(data.numtiles).toBe(vspNumTiles)
  expect(data.imagedata.decompressed).toEqual(vspImageData)
  expect(data.vspanim).toEqual(vspAnimationList)
}<commit_msg>simplify<commit_after>"use strict"

const expect = require('expect')
const createVerge2VspLoader = require('./createVerge2VspLoader')
const fill = require('lodash/fill')
const {makeBuffer, B} = require('../makeBuffer')

const vspVersion = 3
const vspPalette = fill(Array(256 * 3), 77)
const vspNumTiles = 3
const vspImageData = [
  ...fill(Array(128), 44), ...fill(Array(128), 55),
  ...fill(Array(128), 66), ...fill(Array(128), 77),
  ...fill(Array(128), 88), ...fill(Array(128), 99),
]

const vspAnimationList = fill(Array(100), {
  start: 4,
  finish: 3,
  delay: 2,
  mode: 1,
})

{
  // can read vsp
  const loader = createVerge2VspLoader({
    data: makeBuffer([
      B.u16(vspVersion),
      B.u8(vspPalette),
      B.u16(vspNumTiles),
      // compressed image data
      B.u32(6 * 3),
      B.u8([
        0xff, 128, 44, 0xff, 128, 55,
        0xff, 128, 66, 0xff, 128, 77,
        0xff, 128, 88, 0xff, 128, 99
      ]),
      ...vspAnimationList.map((vspAnimation) => {
        return B.u16([
          vspAnimation.start,
          vspAnimation.finish,
          vspAnimation.delay,
          vspAnimation.mode,
        ])
      }),
    ])
  })

  const data = loader.load()

  expect(data.version).toBe(vspVersion)
  expect(data.palette).toEqual(vspPalette)
  expect(data.numtiles).toBe(vspNumTiles)
  expect(data.imagedata.decompressed).toEqual(vspImageData)
  expect(data.vspanim).toEqual(vspAnimationList)
}
{'fraction_non_alphanumeric': 0.16095076400679117, 'fraction_numerical': 0.06451612903225806, 'mean_word_length': 3.0578512396694215, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '4879318', 'n_tokens_mistral': 1208, 'n_tokens_neox': 1050, 'n_words': 203}