From 2de498920147d66c120c6256dcc2a87339277fd3 Mon Sep 17 00:00:00 2001 From: cha0s Date: Mon, 19 Apr 2021 06:16:40 -0500 Subject: [PATCH] refactor: simplicity --- packages/behavior/src/globals/index.js | 16 +++-- packages/behavior/src/globals/timing.js | 29 -------- packages/behavior/src/globals/utility.js | 87 ------------------------ 3 files changed, 11 insertions(+), 121 deletions(-) delete mode 100644 packages/behavior/src/globals/timing.js delete mode 100644 packages/behavior/src/globals/utility.js diff --git a/packages/behavior/src/globals/index.js b/packages/behavior/src/globals/index.js index fd7c56b..c96b427 100644 --- a/packages/behavior/src/globals/index.js +++ b/packages/behavior/src/globals/index.js @@ -1,12 +1,18 @@ import {TickingPromise} from '@avocado/core'; -import Timing from './timing'; -import Utility from './utility'; - export default (latus) => ({ + console, latus, SIDE: process.env.SIDE, TickingPromise, - Timing, - Utility, + wait: (duration) => new TickingPromise( + () => {}, + (elapsed, resolve) => { + // eslint-disable-next-line no-param-reassign + duration -= elapsed; + if (duration <= 0) { + resolve(); + } + }, + ), }); diff --git a/packages/behavior/src/globals/timing.js b/packages/behavior/src/globals/timing.js deleted file mode 100644 index b2e8678..0000000 --- a/packages/behavior/src/globals/timing.js +++ /dev/null @@ -1,29 +0,0 @@ -import {TickingPromise} from '@avocado/core'; - -export default { - - children: () => ({ - wait: { - type: 'void', - label: 'Wait for $1 seconds', - args: [ - { - type: 'number', - label: 'Duration', - }, - ], - }, - }), - - wait: (duration) => new TickingPromise( - () => {}, - (elapsed, resolve) => { - // eslint-disable-next-line no-param-reassign - duration -= elapsed; - if (duration <= 0) { - resolve(); - } - }, - ), - -}; diff --git a/packages/behavior/src/globals/utility.js b/packages/behavior/src/globals/utility.js deleted file mode 100644 index b810c4d..0000000 --- a/packages/behavior/src/globals/utility.js +++ /dev/null @@ -1,87 +0,0 @@ -import merge from 'deepmerge'; -import get from 'lodash.get'; -import set from 'lodash.set'; - -export default { - - children: () => ({ - log: { - label: 'log', - type: 'void', - args: [ - { - label: 'value', - type: 'any', - }, - ], - vararg: true, - }, - get: { - label: 'get', - type: 'any', - args: [ - { - label: 'object', - type: 'object', - }, - { - label: 'path', - type: 'string', - }, - { - label: 'default', - type: 'any', - }, - ], - }, - makeObject: { - label: '{}', - type: 'object', - vararg: true, - args: (i) => { - switch (i % 2) { - case 0: - return { - label: 'key', - type: 'string', - }; - default: - return { - label: 'value', - type: 'any', - }; - } - }, - }, - set: { - label: 'set', - type: 'void', - args: [ - { - label: 'object', - type: 'object', - }, - { - label: 'path', - type: 'string', - }, - { - label: 'value', - type: 'any', - }, - ], - }, - }), - - get: (object, path, defaultValue) => get(object, path, defaultValue), - - log: (...args) => { - // eslint-disable-next-line no-console - console.log(...args); - }, - - merge: (l, r) => merge(l, r), - - set: (object, path, value) => set(object, path, value), - -};