mirror of
https://github.com/embarklabs/embark.git
synced 2025-01-24 12:40:21 +00:00
refactor(@embark/utils): move compact utility into utils package
This commit is contained in:
parent
1330b9fb7a
commit
8a0c33c91e
@ -7,3 +7,7 @@ export function last(array: any) {
|
|||||||
export function recursiveMerge(target: any, source: any) {
|
export function recursiveMerge(target: any, source: any) {
|
||||||
return merge.recursive(target, source);
|
return merge.recursive(target, source);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function compact(array: any) {
|
||||||
|
return array.filter((n: any) => n);
|
||||||
|
}
|
||||||
|
@ -25,7 +25,7 @@ import AccountParser from './accountParser';
|
|||||||
|
|
||||||
const { extendZeroAddressShorthand, replaceZeroAddressShorthand } = AddressUtils;
|
const { extendZeroAddressShorthand, replaceZeroAddressShorthand } = AddressUtils;
|
||||||
|
|
||||||
import { last, recursiveMerge } from './collections';
|
import { compact, last, recursiveMerge } from './collections';
|
||||||
|
|
||||||
function timer(ms) {
|
function timer(ms) {
|
||||||
const then = Date.now();
|
const then = Date.now();
|
||||||
@ -229,6 +229,7 @@ const Utils = {
|
|||||||
jsonFunctionReplacer,
|
jsonFunctionReplacer,
|
||||||
fuzzySearch,
|
fuzzySearch,
|
||||||
canonicalHost,
|
canonicalHost,
|
||||||
|
compact,
|
||||||
copyToClipboard,
|
copyToClipboard,
|
||||||
deconstructUrl,
|
deconstructUrl,
|
||||||
defaultCorsHost,
|
defaultCorsHost,
|
||||||
|
@ -3,13 +3,12 @@ const {spawn, exec} = require('child_process');
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
const fs = require('../../core/fs.js');
|
const fs = require('../../core/fs.js');
|
||||||
const constants = require('embark-core/constants');
|
const constants = require('embark-core/constants');
|
||||||
const utils = require('../../utils/utils.js');
|
|
||||||
const GethClient = require('./gethClient.js');
|
const GethClient = require('./gethClient.js');
|
||||||
const ParityClient = require('./parityClient.js');
|
const ParityClient = require('./parityClient.js');
|
||||||
const Proxy = require('./proxy');
|
const Proxy = require('./proxy');
|
||||||
import { IPC } from 'embark-core';
|
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');
|
const Logger = require('embark-logger');
|
||||||
|
|
||||||
// time between IPC connection attempts (in ms)
|
// time between IPC connection attempts (in ms)
|
||||||
@ -231,7 +230,7 @@ Blockchain.prototype.run = function () {
|
|||||||
self.logger.error(err.message);
|
self.logger.error(err.message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
args = utils.compact(args);
|
args = compact(args);
|
||||||
|
|
||||||
let full_cmd = cmd + " " + args.join(' ');
|
let full_cmd = cmd + " " + args.join(' ');
|
||||||
self.logger.info(__("running: %s", full_cmd.underline).green);
|
self.logger.info(__("running: %s", full_cmd.underline).green);
|
||||||
|
@ -2,11 +2,11 @@ import { each } from "async";
|
|||||||
import { Callback, Logger } /* supplied by @types/embark in packages/embark-typings */ from "embark";
|
import { Callback, Logger } /* supplied by @types/embark in packages/embark-typings */ from "embark";
|
||||||
import { NodeVM, NodeVMOptions } from "vm2";
|
import { NodeVM, NodeVMOptions } from "vm2";
|
||||||
|
|
||||||
import { recursiveMerge } from "embark-utils";
|
import { compact, recursiveMerge } from "embark-utils";
|
||||||
|
|
||||||
const fs = require("./fs");
|
const fs = require("./fs");
|
||||||
const path = require("path");
|
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";
|
const WEB3_INVALID_RESPONSE_ERROR: string = "Invalid JSON RPC response";
|
||||||
|
|
||||||
|
@ -282,10 +282,6 @@ function isValidDomain(v) {
|
|||||||
return isValid;
|
return isValid;
|
||||||
}
|
}
|
||||||
|
|
||||||
function compact(array) {
|
|
||||||
return array.filter(n => n);
|
|
||||||
}
|
|
||||||
|
|
||||||
function groupBy(array, key) {
|
function groupBy(array, key) {
|
||||||
return array.reduce(function (rv, x) {
|
return array.reduce(function (rv, x) {
|
||||||
(rv[x[key]] = rv[x[key]] || []).push(x);
|
(rv[x[key]] = rv[x[key]] || []).push(x);
|
||||||
@ -397,7 +393,6 @@ module.exports = {
|
|||||||
extractZip,
|
extractZip,
|
||||||
getExternalContractUrl,
|
getExternalContractUrl,
|
||||||
normalizeInput,
|
normalizeInput,
|
||||||
compact,
|
|
||||||
groupBy,
|
groupBy,
|
||||||
interceptLogs,
|
interceptLogs,
|
||||||
errorMessage,
|
errorMessage,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user