refactor(@embark/utils): move compact utility into utils package

This commit is contained in:
Pascal Precht 2019-05-06 13:18:23 +02:00 committed by Pascal Precht
parent 1330b9fb7a
commit 8a0c33c91e
5 changed files with 10 additions and 11 deletions

View File

@ -7,3 +7,7 @@ export function last(array: any) {
export function recursiveMerge(target: any, source: any) {
return merge.recursive(target, source);
}
export function compact(array: any) {
return array.filter((n: any) => n);
}

View File

@ -25,7 +25,7 @@ import AccountParser from './accountParser';
const { extendZeroAddressShorthand, replaceZeroAddressShorthand } = AddressUtils;
import { last, recursiveMerge } from './collections';
import { compact, last, recursiveMerge } from './collections';
function timer(ms) {
const then = Date.now();
@ -229,6 +229,7 @@ const Utils = {
jsonFunctionReplacer,
fuzzySearch,
canonicalHost,
compact,
copyToClipboard,
deconstructUrl,
defaultCorsHost,

View File

@ -3,13 +3,12 @@ const {spawn, exec} = require('child_process');
const path = require('path');
const fs = require('../../core/fs.js');
const constants = require('embark-core/constants');
const utils = require('../../utils/utils.js');
const GethClient = require('./gethClient.js');
const ParityClient = require('./parityClient.js');
const Proxy = require('./proxy');
import { IPC } from 'embark-core';
import {defaultHost, dockerHostSwap, AccountParser} from 'embark-utils';
import { compact, defaultHost, dockerHostSwap, AccountParser} from 'embark-utils';
const Logger = require('embark-logger');
// time between IPC connection attempts (in ms)
@ -231,7 +230,7 @@ Blockchain.prototype.run = function () {
self.logger.error(err.message);
return;
}
args = utils.compact(args);
args = compact(args);
let full_cmd = cmd + " " + args.join(' ');
self.logger.info(__("running: %s", full_cmd.underline).green);

View File

@ -2,11 +2,11 @@ import { each } from "async";
import { Callback, Logger } /* supplied by @types/embark in packages/embark-typings */ from "embark";
import { NodeVM, NodeVMOptions } from "vm2";
import { recursiveMerge } from "embark-utils";
import { compact, recursiveMerge } from "embark-utils";
const fs = require("./fs");
const path = require("path");
const { isEs6Module, compact } = require("../../utils/utils");
const { isEs6Module } = require("../../utils/utils");
const WEB3_INVALID_RESPONSE_ERROR: string = "Invalid JSON RPC response";

View File

@ -282,10 +282,6 @@ function isValidDomain(v) {
return isValid;
}
function compact(array) {
return array.filter(n => n);
}
function groupBy(array, key) {
return array.reduce(function (rv, x) {
(rv[x[key]] = rv[x[key]] || []).push(x);
@ -397,7 +393,6 @@ module.exports = {
extractZip,
getExternalContractUrl,
normalizeInput,
compact,
groupBy,
interceptLogs,
errorMessage,