mirror of https://github.com/embarklabs/embark.git
refactor(@embark/embark-utils): move last fn into utils package
This commit is contained in:
parent
4c4c8ed1d6
commit
6308c82993
|
@ -0,0 +1,5 @@
|
|||
|
||||
export function last(array: any) {
|
||||
return array[array.length - 1];
|
||||
}
|
||||
|
|
@ -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,
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue