diff --git a/packages/embark-utils/src/collections.ts b/packages/embark-utils/src/collections.ts new file mode 100644 index 000000000..1eaf2353b --- /dev/null +++ b/packages/embark-utils/src/collections.ts @@ -0,0 +1,5 @@ + +export function last(array: any) { + return array[array.length - 1]; +} + diff --git a/packages/embark-utils/src/index.js b/packages/embark-utils/src/index.js index 7d2bf8fea..b1210fdc6 100644 --- a/packages/embark-utils/src/index.js +++ b/packages/embark-utils/src/index.js @@ -8,6 +8,8 @@ const {findNextPort} = require('./network'); const logUtils = require('./log-utils'); const toposortGraph = require('./toposort'); +import { last } from './collections'; + function checkIsAvailable(url, callback) { const protocol = url.split(':')[0]; const httpObj = (protocol === 'https') ? https : http; @@ -125,6 +127,7 @@ const Utils = { findNextPort, hashTo32ByteHexString, isHex, + last, soliditySha3, recursiveMerge, sha512, diff --git a/packages/embark/src/lib/utils/longRunningProcessTimer.ts b/packages/embark/src/lib/utils/longRunningProcessTimer.ts index f6e92a606..6eb9b6ac7 100644 --- a/packages/embark/src/lib/utils/longRunningProcessTimer.ts +++ b/packages/embark/src/lib/utils/longRunningProcessTimer.ts @@ -5,7 +5,6 @@ import prettyMs from "pretty-ms"; import { Logger } from "embark"; -const utils = require("./utils.js"); const ora = require("ora"); export interface LongRunningProcessTimerOptions { @@ -63,7 +62,7 @@ export default class LongRunningProcessTimer { let strDuration; // find any download ongoing measurements we"ve made - entry = utils.last(items.getEntries().filter((thisEntry) => thisEntry.name === this.downloadOngoing)); + entry = last(items.getEntries().filter((thisEntry) => thisEntry.name === this.downloadOngoing)); if (entry) { // ongoing performance mark // TODO: add i18n @@ -73,7 +72,7 @@ export default class LongRunningProcessTimer { } } else { // otherwise, find our download complete measurement - entry = utils.last(items.getEntries().filter((thisEntry) => thisEntry.name === this.downloadComplete)); + entry = last(items.getEntries().filter((thisEntry) => thisEntry.name === this.downloadComplete)); if (entry) { // TODO: add i18n strDuration = this.processFinishedMsg.replace("{{packageName}}", this.packageName).replace("{{version}}", this.version).replace("{{duration}}", prettyMs(entry.duration)); diff --git a/packages/embark/src/lib/utils/utils.js b/packages/embark/src/lib/utils/utils.js index 39b37712f..9506a6da1 100644 --- a/packages/embark/src/lib/utils/utils.js +++ b/packages/embark/src/lib/utils/utils.js @@ -402,10 +402,6 @@ function groupBy(array, key) { }, {}); } -function last(array) { - return array[array.length - 1]; -} - function interceptLogs(consoleContext, logger) { let context = {}; context.console = consoleContext; @@ -541,7 +537,6 @@ module.exports = { getHexBalanceFromString, compact, groupBy, - last, interceptLogs, errorMessage, timer,