From fa19e06d2947c199dc24e0ce1b7fe37219c3701f Mon Sep 17 00:00:00 2001 From: yamiteru Date: Tue, 4 Apr 2023 19:52:00 +0200 Subject: [PATCH] Update examples --- examples/arrayLoops.ts | 26 ++++++++++++-------------- examples/emptyFunctions.ts | 16 +++++++--------- 2 files changed, 19 insertions(+), 23 deletions(-) diff --git a/examples/arrayLoops.ts b/examples/arrayLoops.ts index 8d9974a..65a2893 100644 --- a/examples/arrayLoops.ts +++ b/examples/arrayLoops.ts @@ -1,36 +1,34 @@ -import { createPreset } from "../src"; -import { useTerminal } from "../src/modes"; +import { useTerminal } from "../src"; +import { suite } from "../src"; const LENGTH = 1_000; const DATA = [...new Array(LENGTH)].map(() => Math.random() * 10); const RESULT = { _: 0 }; -const defaultSuite = createPreset(); -const emptyFunctions = defaultSuite("Array loops", { - for: () => { +const emptyFunctions = suite("Array loops") + .add("for", () => { for (let i = 0; i < LENGTH; ++i) { RESULT._ = DATA[i]; } - }, - while: () => { + }) + .add("while", () => { let i = -1; while (++i < LENGTH) { RESULT._ = DATA[i]; } - }, - forOf: () => { + }) + .add("forOf", () => { for (const v of DATA) { RESULT._ = v; } - }, - forEach: () => { + }) + .add("forEach", () => { DATA.forEach((v) => (RESULT._ = v)); - }, -}); + }); (async () => { useTerminal(); - await emptyFunctions(); + await emptyFunctions.run(); })(); diff --git a/examples/emptyFunctions.ts b/examples/emptyFunctions.ts index a7984f5..018be51 100644 --- a/examples/emptyFunctions.ts +++ b/examples/emptyFunctions.ts @@ -1,18 +1,16 @@ -import { createPreset } from "../src"; +import { suite } from "../src"; import { useTerminal } from "../src/modes"; -const defaultSuite = createPreset(); -const emptyFunctions = defaultSuite("Empty functions", { - emptyAsync: async () => { +const emptyFunctions = suite("Empty functions") + .add("empty async", async () => { /* */ - }, - emptySync: () => { + }) + .add("empty sync", () => { /* */ - }, -}); + }); (async () => { useTerminal(); - await emptyFunctions(); + await emptyFunctions.run(); })();