refactor: simplicity

This commit is contained in:
cha0s 2021-04-19 06:16:40 -05:00
parent 8477e2330f
commit 2de4989201
3 changed files with 11 additions and 121 deletions

View File

@ -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();
}
},
),
});

View File

@ -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();
}
},
),
};

View File

@ -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),
};