Skip to content

Instantly share code, notes, and snippets.

@Sasha-hk
Last active April 9, 2022 00:00
Show Gist options
  • Save Sasha-hk/ae0820c1faae86ea170be353c55b2e8a to your computer and use it in GitHub Desktop.
Save Sasha-hk/ae0820c1faae86ea170be353c55b2e8a to your computer and use it in GitHub Desktop.

Loading animation in pure Node.js

Code:

const loading = () => {
  const view = ['|', '/', '-', '\\'];
  let i = 0;

  setInterval(() => {
    process.stdout.write(`\r${view[i++]}`);
    i &= 3;
  }, 250);
}

loading();

Run:

node [file_name]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment