src/attributes.js
function createBufferFromArray(gl, array, arrayName) {
  const type = arrayName === "indices" ? gl.ELEMENT_ARRAY_BUFFER : gl.ARRAY_BUFFER;
  const typedArray = makeTypedArray(array, arrayName);
  return createBufferFromTypedArray(gl, typedArray, type);
}
function createBufferFromArray(gl, array, arrayName) {
  const type = arrayName === "indices" ? gl.ELEMENT_ARRAY_BUFFER : gl.ARRAY_BUFFER;
  const typedArray = makeTypedArray(array, arrayName);
  return createBufferFromTypedArray(gl, typedArray, type);
}
function createBufferFromArray ( gl , array , arrayName ) { const type = arrayName === "indices" ? gl . ELEMENT_ARRAY_BUFFER : gl . ARRAY_BUFFER ; const typedArray = makeTypedArray ( array , arrayName ) ; return createBufferFromTypedArray ( gl , typedArray , type ) ; }
Creates a buffer from an array, typed array, or array spec

Given something like this

[1, 2, 3],

or

new Uint16Array([1,2,3]);

or

{
data: [1, 2, 3],
type: Uint8Array,
}

returns a WebGLBuffer that constains the given data.

@param {WebGLRenderingContext} gl A WebGLRenderingContext.
@param {module:twgl.ArraySpec} array an array, typed array, or array spec.
@param {string} arrayName name of array. Used to guess the type if type can not be dervied other wise.
@return {WebGLBuffer} a WebGLBuffer containing the data in array.
@memberOf module:twgl/attributes
Creates a buffer from an array typed array or array spec