We are only using the chunk for it's API. 

can we instead just do: 
var tempChk = new Chunk();
if (typeof key==='function') {
    key = key(tempChk, this).data.join('');
}

we don't need to pass in ctx since `this` is the context