es/png.js
function createChunk(type, data) {
	const length = typeof data != 'undefined' ? data.length : 0;
	const chunk = Buffer.alloc(4 + 4 + length + 4);

	chunk.writeUInt32BE(length, 0);
	chunk.fill(type, 4, 8, 'utf8');
	if (typeof data != 'undefined') {
		chunk.fill(data, 8, chunk.length - 4);
	}
	chunk.writeUInt32BE(crc32(chunk.slice(4, -4)), chunk.length - 4);

	return chunk;
}
function createChunk(type, data) {
	const length = typeof data != 'undefined' ? data.length : 0;
	const chunk = Buffer.alloc(4 + 4 + length + 4);

	chunk.writeUInt32BE(length, 0);
	chunk.fill(type, 4, 8, 'utf8');
	if (typeof data != 'undefined') {
		chunk.fill(data, 8, chunk.length - 4);
	}
	chunk.writeUInt32BE(crc32(chunk.slice(4, -4)), chunk.length - 4);

	return chunk;
}
function createChunk ( type , data ) { const length = typeof data != 'undefined' ? data . length : 0 ; const chunk = Buffer . alloc ( 4 + 4 + length + 4 ) ; chunk . writeUInt32BE ( length , 0 ) ; chunk . fill ( type , 4 , 8 , 'utf8' ) ; if ( typeof data != 'undefined' ) { chunk . fill ( data , 8 , chunk . length - 4 ) ; } chunk . writeUInt32BE ( crc32 ( chunk . slice ( 4 , - 4 ) ) , chunk . length - 4 ) ; return chunk ; }
Create a chunk of the given type with the given data.

@param type
@param data
@returns {Buffer}
Create a chunk of the given type with the given data .