https://github.com/mapbox/spritezero 我是一个nodejs新手,代码基于此存储库
q.awaitAll(function (err, buffers) {
// if(err) return;
// console.log(buffers);
[1, 2, 4].forEach(function (pxRatio) {
var pngPath = destDir + "/sprite@" + pxRatio + ".png";
var jsonPath = destDir + "/sprite@" + pxRatio + ".json";
spritezero.generateLayout(
{ imgs: buffers, pixelRatio: pxRatio, format: true },
async function(err, dataLayout) {
if (err) return;
let result1 = await client.put(
jsonPath,
Buffer.from(JSON.stringify(dataLayout, null))
);
//console.log(client.signatureUrl(result.name));
}
);
spritezero.generateLayout(
{ imgs: buffers, pixelRatio: pxRatio, format: false },
function(err, imageLayout) {
spritezero.generateImage(imageLayout, async function(err, image) {
if (err) return;
let result2 = await client.put(pngPath, image);
//console.log(client.signatureUrl(result.name));
});
}
);
});
});
我希望此函数具有上面代码中的返回值, result1和result2来自spritezero.generateLayout中的回调
返回{pxRatio:[result1.name,result2.name}