```ts
import { assert } from 'assert';

export function swapPair(first: string, second: string): string {
  return `${second}${first}`;
}

export function swapAll(text: string): string {
  let result = '';

  for (let i = 0; i < text.length; i += 2) {
    const pair = text[i] + text[i + 1];
    result += swapPair(pair[0], pair[1]);
  }

  // Handle the last remaining character if the length is odd
  if (text.length % 2 !== 0) {
    result += text[text.length - 1];
  }

  return result;
}

// Check function to verify the correctness of the solution
function check() {
  assert.equal(swapPair('a', 'b'), 'ba');
  assert.equal(swapPair('c', 'd'), 'cd');
  assert.equal(swapAll('ab'), 'ba');
  assert.equal(swapAll('abc'), 'acb');
  assert.equal(swapAll('abcd'), 'adcb');
  assert.equal(swapAll('aabbcc'), 'bbccaac');
  assert.equal(swapAll('a'), 'a'); // Single character case
  assert.equal(swapAll('abab'), 'baab'); // Even length case
  assert.equal(swapAll('abcde'), 'edcba'); // Odd length case with multiple pairs

  console.log('All tests passed!');
}

check();
```