@web-academy/core-lib

Collection of core functionality

Usage no npm install needed!

<script type="module">
  import webAcademyCoreLib from 'https://cdn.skypack.dev/@web-academy/core-lib';
</script>

README

Web.Academy Core-Library

Collection of core functionality

Helpers

ArrayHelper

ArrayHelper.chunk(arr: any[], size: number): any[][]

Splits an existing array into multiple arrays (chunks) with a given size.

let arr = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'];
let chunks = ArrayHelper.chunk(arr, 3);

// ==> chunks = [['a', 'b', 'c'], ['d', 'e', 'f'], ['g', 'h']];

ArrayHelper.randomItem(arr: any[]): any

Returns a random item from given array

let arr = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'];
let item = ArrayHelper.randomItem(arr);

WaitHelper

WaitHelper.wait(ms: number): Promise

Waits for the given amount of ms and the resolves the promise

await WaitHelper.wait(500); // Waits for 500ms