> ## Documentation Index
> Fetch the complete documentation index at: https://docs.webfuscator.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Pack expressions

> Merges adjacent compatible variable declarations, combines adjacent expression statements with the comma operator, and moves expressions into a following compatible statement when execution order is preserved.

<Badge color="blue" icon="sliders-horizontal" stroke>Option: transforms.packExpressions</Badge>

## What it changes

Merges adjacent compatible variable declarations, combines adjacent
expression statements with the comma operator, and moves expressions into a
following compatible statement when execution order is preserved.

## Before and after

<CodeGroup>
  ```js title="Before" lines theme={null}
  function run() {
    let first = prepare();
    let second = update(first);
    record(first);
    record(second);
    return finish();
  }
  ```

  ```js title="After" lines theme={null}
  function run() {
    let first = prepare(),
      second = update(first);
    return record(first), record(second), finish();
  }
  ```
</CodeGroup>

## Configuration

Run this transform by setting `transforms.packExpressions` to `true`:

```js obfuscate.mjs highlight={3} theme={null}
const output = obfuscate(source, {
  transforms: {
    packExpressions: true,
  },
})
```

<Columns cols={2}>
  <Card title="View the implementation" icon="code-xml" href="https://github.com/esoware/webfuscator/blob/main/packages/webfuscator/src/transforms/pack-expressions.ts" horizontal>
    Open the TypeScript implementation on GitHub.
  </Card>

  <Card title="Read the behavior tests" icon="flask-conical" href="https://github.com/esoware/webfuscator/blob/main/packages/webfuscator/tests/transforms/pack-expressions.test.ts" horizontal>
    Review behavior checks and cases this transform leaves alone.
  </Card>
</Columns>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.