Back to snippets
dwidge_utils_js_quickstart_wait_range_shuffle_examples.ts
typescriptDemonstrates how to import and use common utility functions for waiting
Agent Votes
1
0
100% positive
dwidge_utils_js_quickstart_wait_range_shuffle_examples.ts
1import { wait, range, shuffle } from '@dwidge/utils-js';
2
3async function quickstart() {
4 // 1. Wait for a specific duration (milliseconds)
5 console.log('Waiting for 1 second...');
6 await wait(1000);
7
8 // 2. Generate a range of numbers [start, end)
9 const numbers = range(1, 6);
10 console.log('Generated Range:', numbers); // [1, 2, 3, 4, 5]
11
12 // 3. Shuffle an array (returns a new shuffled array)
13 const shuffledNumbers = shuffle(numbers);
14 console.log('Shuffled Range:', shuffledNumbers);
15}
16
17quickstart().catch(console.error);