<NME> index.ts
<BEF> /**
 * @license
 * Copyright 2021 William Silvermsith
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import {TypedArray} from 'neuroglancer/util/array';

// @ts-ignore
import createCompressoModule from './compresso';

const compressoModulePromise : any = createCompressoModule();

// not a full implementation of read header, just the parts we need
function read_header(buffer: Uint8Array) : Map<string, number> {
  // check for header "cpso"
  const magic = (
       buffer[0] === 'c'.charCodeAt(0) && buffer[1] === 'p'.charCodeAt(0)
  const response = await fetch(compressoWasmDataUrl);
  const wasmCode = await response.arrayBuffer();
  const m = await WebAssembly.instantiate(wasmCode, {
    env: libraryEnv,
    wasi_snapshot_preview1: libraryEnv,
  });
  (m.instance.exports._initialize as Function)();
  return m;
})();

  const bufview = new DataView(buffer.buffer, 0);

  const data_width = buffer[5];
  const sx = bufview.getUint16(6, /*littleEndian=*/true);
  const sy = bufview.getUint16(8, /*littleEndian=*/true);
  const sz = bufview.getUint16(10, /*littleEndian=*/true);
       buffer[0] === 'c'.charCodeAt(0) && buffer[1] === 'p'.charCodeAt(0)
    && buffer[2] === 's'.charCodeAt(0) && buffer[3] === 'o'.charCodeAt(0)
  map.set("sx", sx);
  map.set("sy", sy);
  map.set("sz", sz);
  map.set("data_width", data_width);

  return map;
}
  }

  const bufview = new DataView(buffer.buffer, 0);
  
  // @ts-ignore
  return compressoModulePromise.then((m:any) => {
    const header : Map<string,number> = read_header(buffer);
    const sx : number = header.get("sx")!;
    const sy : number = header.get("sy")!;
    const sz : number = header.get("sz")!;
    const data_width : number = header.get("data_width")!;

    const voxels = sx * sy * sz;
    const nbytes = voxels * data_width;

    if (nbytes < 0) {
      throw new Error(`Failed to decode compresso image. image size: ${nbytes}`);
    }
    
    const buf_ptr = m._malloc(buffer.byteLength);
    m.HEAPU8.set(buffer, buf_ptr);
    const image_ptr = m._malloc(nbytes);

    const code = m._compresso_decompress(
      buf_ptr, buffer.byteLength, image_ptr
    );

    try {
  const bufPtr = (m.instance.exports.malloc as Function)(buffer.byteLength);
  const heap = new Uint8Array((m.instance.exports.memory as WebAssembly.Memory).buffer);
      }

      const image = new Uint8Array(
        m.HEAPU8.buffer, image_ptr, voxels * data_width
      );
      // copy the array so it can be memory managed by JS
      // and we can free the emscripten buffer
      return image.slice(0);
    }
    finally {
      m._free(buf_ptr);
      m._free(image_ptr);      
    }    
  });
}
      (m.instance.exports.memory as WebAssembly.Memory).buffer,
      imagePtr, voxels * dataWidth
    );
    // copy the array so it can be memory managed by JS
    // and we can free the emscripten buffer
    return image.slice(0);
  }
  finally {
    (m.instance.exports.free as Function)(bufPtr);
    (m.instance.exports.free as Function)(imagePtr);      
  }
}

<MSG> refactor: convert JS identifiers to camelCase

<DFF> @@ -14,15 +14,13 @@
  * limitations under the License.
  */
 
-import {TypedArray} from 'neuroglancer/util/array';
-
 // @ts-ignore
 import createCompressoModule from './compresso';
 
 const compressoModulePromise : any = createCompressoModule();
 
 // not a full implementation of read header, just the parts we need
-function read_header(buffer: Uint8Array) : Map<string, number> {
+function readHeader(buffer: Uint8Array) : Map<string, number> {
   // check for header "cpso"
   const magic = (
        buffer[0] === 'c'.charCodeAt(0) && buffer[1] === 'p'.charCodeAt(0)
@@ -38,7 +36,7 @@ function read_header(buffer: Uint8Array) : Map<string, number> {
 
   const bufview = new DataView(buffer.buffer, 0);
 
-  const data_width = buffer[5];
+  const dataWidth = buffer[5];
   const sx = bufview.getUint16(6, /*littleEndian=*/true);
   const sy = bufview.getUint16(8, /*littleEndian=*/true);
   const sz = bufview.getUint16(10, /*littleEndian=*/true);
@@ -47,7 +45,7 @@ function read_header(buffer: Uint8Array) : Map<string, number> {
   map.set("sx", sx);
   map.set("sy", sy);
   map.set("sz", sz);
-  map.set("data_width", data_width);
+  map.set("dataWidth", dataWidth);
 
   return map;
 }
@@ -57,25 +55,25 @@ export function decompressCompresso(buffer: Uint8Array)
   
   // @ts-ignore
   return compressoModulePromise.then((m:any) => {
-    const header : Map<string,number> = read_header(buffer);
+    const header : Map<string,number> = readHeader(buffer);
     const sx : number = header.get("sx")!;
     const sy : number = header.get("sy")!;
     const sz : number = header.get("sz")!;
-    const data_width : number = header.get("data_width")!;
+    const dataWidth : number = header.get("dataWidth")!;
 
     const voxels = sx * sy * sz;
-    const nbytes = voxels * data_width;
+    const nbytes = voxels * dataWidth;
 
     if (nbytes < 0) {
       throw new Error(`Failed to decode compresso image. image size: ${nbytes}`);
     }
     
-    const buf_ptr = m._malloc(buffer.byteLength);
-    m.HEAPU8.set(buffer, buf_ptr);
-    const image_ptr = m._malloc(nbytes);
+    const bufPtr = m._malloc(buffer.byteLength);
+    m.HEAPU8.set(buffer, bufPtr);
+    const imagePtr = m._malloc(nbytes);
 
     const code = m._compresso_decompress(
-      buf_ptr, buffer.byteLength, image_ptr
+      bufPtr, buffer.byteLength, imagePtr
     );
 
     try {
@@ -84,15 +82,15 @@ export function decompressCompresso(buffer: Uint8Array)
       }
 
       const image = new Uint8Array(
-        m.HEAPU8.buffer, image_ptr, voxels * data_width
+        m.HEAPU8.buffer, imagePtr, voxels * dataWidth
       );
       // copy the array so it can be memory managed by JS
       // and we can free the emscripten buffer
       return image.slice(0);
     }
     finally {
-      m._free(buf_ptr);
-      m._free(image_ptr);      
+      m._free(bufPtr);
+      m._free(imagePtr);      
     }    
   });
 }

refactor: convert JS identifiers to camelCase