packages/babel-plugin-proposal-object-rest-spread/src/index.js
function createObjectSpread(path, file, objRef) {
    const props = path.get("properties");
    const last = props[props.length - 1];
    t.assertRestElement(last.node);
    const restElement = t.cloneNode(last.node);
    last.remove();

    const impureComputedPropertyDeclarators = replaceImpureComputedKeys(path);
    const { keys, allLiteral } = extractNormalizedKeys(path);

    if (keys.length === 0) {
      return [
        impureComputedPropertyDeclarators,
        restElement.argument,
        t.callExpression(getExtendsHelper(file), [
          t.objectExpression([]),
          t.cloneNode(objRef),
        ]),
      ];
    }

    let keyExpression;
    if (!allLiteral) {
      // map to toPropertyKey to handle the possible non-string values
      keyExpression = t.callExpression(
        t.memberExpression(t.arrayExpression(keys), t.identifier("map")),
        [file.addHelper("toPropertyKey")],
      );
    } else {
      keyExpression = t.arrayExpression(keys);
    }

    return [
      impureComputedPropertyDeclarators,
      restElement.argument,
      t.callExpression(
        file.addHelper(`objectWithoutProperties${loose ? "Loose" : ""}`),
        [t.cloneNode(objRef), keyExpression],
      ),
    ];
  }
function createObjectSpread(path, file, objRef) {
    const props = path.get("properties");
    const last = props[props.length - 1];
    t.assertRestElement(last.node);
    const restElement = t.cloneNode(last.node);
    last.remove();

    const impureComputedPropertyDeclarators = replaceImpureComputedKeys(path);
    const { keys, allLiteral } = extractNormalizedKeys(path);

    if (keys.length === 0) {
      return [
        impureComputedPropertyDeclarators,
        restElement.argument,
        t.callExpression(getExtendsHelper(file), [
          t.objectExpression([]),
          t.cloneNode(objRef),
        ]),
      ];
    }

    let keyExpression;
    if (!allLiteral) {
      // map to toPropertyKey to handle the possible non-string values
      keyExpression = t.callExpression(
        t.memberExpression(t.arrayExpression(keys), t.identifier("map")),
        [file.addHelper("toPropertyKey")],
      );
    } else {
      keyExpression = t.arrayExpression(keys);
    }

    return [
      impureComputedPropertyDeclarators,
      restElement.argument,
      t.callExpression(
        file.addHelper(`objectWithoutProperties${loose ? "Loose" : ""}`),
        [t.cloneNode(objRef), keyExpression],
      ),
    ];
  }
function createObjectSpread ( path , file , objRef ) { const props = path . get ( "properties" ) ; const last = props [ props . length - 1 ] ; t . assertRestElement ( last . node ) ; const restElement = t . cloneNode ( last . node ) ; last . remove ( ) ; const impureComputedPropertyDeclarators = replaceImpureComputedKeys ( path ) ; const { keys , allLiteral } = extractNormalizedKeys ( path ) ; if ( keys . length === 0 ) { return [ impureComputedPropertyDeclarators , restElement . argument , t . callExpression ( getExtendsHelper ( file ) , [ t . objectExpression ( [ ] ) , t . cloneNode ( objRef ) , ] ) , ] ; } let keyExpression ; if ( ! allLiteral ) { // map to toPropertyKey to handle the possible non-string values keyExpression = t . callExpression ( t . memberExpression ( t . arrayExpression ( keys ) , t . identifier ( "map" ) ) , [ file . addHelper ( "toPropertyKey" ) ] , ) ; } else { keyExpression = t . arrayExpression ( keys ) ; } return [ impureComputedPropertyDeclarators , restElement . argument , t . callExpression ( file . addHelper ( ` ${ loose ? "Loose" : "" } ` ) , [ t . cloneNode ( objRef ) , keyExpression ] , ) , ] ; }
expects path to an object pattern
expects path to an object pattern