Why does document.duplicateLayers not return the duplicated layers?

const layers = await cutesDoc.duplicateLayers(group.layers, newDoc);
    async (layer) => {
        const name = layer.name;
        const targetLayer = getTargetLayer(name, groupLayers);

        console.log(layer, targetLayer.name);
        // await layer.move(targetLayer, Constants.ElementPlacement.PLACEATEND);

the result is layer == group not the group.layers, please help me why?

According to the document api:

Can you share the getTargetLayer function and what value are you storing inside groupLayers so I can see the full code?

I guess you are trying to copy the layers inside of a group from one document to another? Elaborate your problem the more you can so the solution can be easily created.

Thank u very much for your reply. But I don’t think the getTargetLayer function is related to this bug. It’s just for converting a name to target folder so that the duplicated layers will be placed into the right place. The source code is here:

function getTargetLayer(name, groupLayers) {
    const result = name.match(/layer(\d+)/);
    if (result) {
        const index = parseInt(result[1]);
        return groupLayers[index];
    } else {
        return null;

As you see, I’m trying to copy the layers inside a group from one document to another document, and then place them into the right folder.
Finally, I have done it by another way, like:

async function resortLayers(newDoc, groupLayers) {
    for (const layer of newDoc.layers) {
        layer.visible = true;
        const targetLayer = getTargetLayer(layer.name, groupLayers);

        if (targetLayer) {
            await layer.move(targetLayer, Constants.ElementPlacement.PLACEINSIDE);