如何读取将给定文本转换为缓冲区,而不是将文本“ hello world”添加到给定输入并返回最终输出作为缓冲区

这是我尝试过的

var images = Array<String>()
if let texture = envAnchor.environmentTexture{
    for i in 0..<6{
        if let newTexture = texture.makeTextureView(pixelFormat: texture.pixelFormat,textureType: .type2D,levels: 0..<texture.mipmapLevelCount,slices: i..<i+1),let ciImage = CIImage(mtlTexture: newTexture,options: nil){
            let uiImage = UIImage(ciImage: ciImage)
            images.append(imageUtil.getImageData(image: uiImage))
        }
    }
}

我想在给定输入的末尾添加新字符串,即“ Hello World”。

xiangzhou1990 回答:如何读取将给定文本转换为缓冲区,而不是将文本“ hello world”添加到给定输入并返回最终输出作为缓冲区

我建议为此使用Buffer.concat,这可以让您将任意数量的Buffer连接在一起:

let addBuffer = (text) => {
    return Buffer.concat([Buffer.from(text),Buffer.from('hello world')]);
};

console.log(addBuffer('Some text - ').toString("utf8"));
本文链接:https://www.f2er.com/3161743.html

大家都在问