MIGRATE.js 921 B

1234567891011121314151617181920212223242526272829303132
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.transformArguments = void 0;
  4. function transformArguments(host, port, key, destinationDb, timeout, options) {
  5. const args = ['MIGRATE', host, port.toString()], isKeyArray = Array.isArray(key);
  6. if (isKeyArray) {
  7. args.push('');
  8. }
  9. else {
  10. args.push(key);
  11. }
  12. args.push(destinationDb.toString(), timeout.toString());
  13. if (options?.COPY) {
  14. args.push('COPY');
  15. }
  16. if (options?.REPLACE) {
  17. args.push('REPLACE');
  18. }
  19. if (options?.AUTH) {
  20. if (options.AUTH.username) {
  21. args.push('AUTH2', options.AUTH.username, options.AUTH.password);
  22. }
  23. else {
  24. args.push('AUTH', options.AUTH.password);
  25. }
  26. }
  27. if (isKeyArray) {
  28. args.push('KEYS', ...key);
  29. }
  30. return args;
  31. }
  32. exports.transformArguments = transformArguments;