Replace lodash.isEmpty (#4391)
This commit is contained in:
parent
f720e6e916
commit
25c5f38f54
|
|
@ -1,9 +1,9 @@
|
|||
import { parse } from 'node:url';
|
||||
import { createHash } from 'node:crypto';
|
||||
|
||||
import isEmpty from 'lodash.isempty';
|
||||
import { getLogger } from '@sitespeed.io/log';
|
||||
|
||||
import { isEmpty } from '../../support/util.js';
|
||||
const log = getLogger('sitespeedio.file');
|
||||
|
||||
function toSafeKey(key) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import isEmpty from 'lodash.isempty';
|
||||
import { SitespeedioPlugin } from '@sitespeed.io/plugin';
|
||||
import { AssetsAggregator } from './aggregator.js';
|
||||
import { isEmpty } from '../../support/util.js';
|
||||
const DEFAULT_METRICS_LARGEST_ASSETS = ['image.0.transferSize'];
|
||||
|
||||
export default class AssetsPlugin extends SitespeedioPlugin {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import { getLogger } from '@sitespeed.io/log';
|
|||
const log = getLogger('plugin.browsertime');
|
||||
|
||||
import dayjs from 'dayjs';
|
||||
import isEmpty from 'lodash.isempty';
|
||||
import get from 'lodash.get';
|
||||
import { Stats } from 'fast-stats';
|
||||
import coach from 'coach-core';
|
||||
|
|
@ -21,6 +20,7 @@ import { SitespeedioPlugin } from '@sitespeed.io/plugin';
|
|||
|
||||
import { summarizeStats } from '../../support/statsHelpers.js';
|
||||
import { analyzeUrl } from './analyzer.js';
|
||||
import { isEmpty } from '../../support/util.js';
|
||||
|
||||
import { BrowsertimeAggregator } from './browsertimeAggregator.js';
|
||||
import { metricsPageSummary as DEFAULT_METRICS_PAGE_SUMMARY } from './default/metricsPageSummary.js';
|
||||
|
|
|
|||
|
|
@ -2,10 +2,10 @@ import { parse } from 'node:url';
|
|||
|
||||
import { Stats } from 'fast-stats';
|
||||
import { getLogger } from '@sitespeed.io/log';
|
||||
import isEmpty from 'lodash.isempty';
|
||||
import reduce from 'lodash.reduce';
|
||||
|
||||
import { summarizeStats } from '../../support/statsHelpers.js';
|
||||
import { isEmpty } from '../../support/util.js';
|
||||
|
||||
const log = getLogger('sitespeedio.plugin.domains');
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import isEmpty from 'lodash.isempty';
|
||||
import { SitespeedioPlugin } from '@sitespeed.io/plugin';
|
||||
import { DomainsAggregator } from './aggregator.js';
|
||||
import { isEmpty } from '../../support/util.js';
|
||||
|
||||
export default class DomainsPlugin extends SitespeedioPlugin {
|
||||
constructor(options, context, queue) {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
import isEmpty from 'lodash.isempty';
|
||||
import merge from 'lodash.merge';
|
||||
import get from 'lodash.get';
|
||||
import dayjs from 'dayjs';
|
||||
import { getLogger } from '@sitespeed.io/log';
|
||||
import { SitespeedioPlugin } from '@sitespeed.io/plugin';
|
||||
|
||||
import { isEmpty } from '../../support/util.js';
|
||||
|
||||
import { send } from './send-annotation.js';
|
||||
import { GraphiteDataGenerator as DataGenerator } from './data-generator.js';
|
||||
import { isStatsD } from './helpers/is-statsd.js';
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ import { getLogger } from '@sitespeed.io/log';
|
|||
import { markdown } from 'markdown';
|
||||
import merge from 'lodash.merge';
|
||||
import get from 'lodash.get';
|
||||
import isEmpty from 'lodash.isempty';
|
||||
|
||||
const log = getLogger('sitespeedio.plugin.html');
|
||||
const require = createRequire(import.meta.url);
|
||||
|
|
@ -27,7 +26,7 @@ import detailedSetup from './setup/detailed.js';
|
|||
import { getFilmstrip } from '../browsertime/filmstrip.js';
|
||||
import getScripts from './getScripts.js';
|
||||
import friendlyNames from '../../support/friendlynames.js';
|
||||
import { toArray } from '../../support/util.js';
|
||||
import { toArray, isEmpty } from '../../support/util.js';
|
||||
import { getOS, osName } from '../../support/osUtil.js';
|
||||
const __dirname = fileURLToPath(new URL('.', import.meta.url));
|
||||
const TIME_FORMAT = 'YYYY-MM-DD HH:mm:ss';
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import isEmpty from 'lodash.isempty';
|
||||
import { getLogger } from '@sitespeed.io/log';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
|
|
@ -8,7 +7,7 @@ import { InfluxDB2Sender as SenderV2 } from './senderV2.js';
|
|||
import { sendV1 } from './send-annotation.js';
|
||||
import { sendV2 } from './send-annotationV2.js';
|
||||
import { InfluxDBDataGenerator as DataGenerator } from './data-generator.js';
|
||||
import { throwIfMissing } from '../../support/util.js';
|
||||
import { throwIfMissing, isEmpty } from '../../support/util.js';
|
||||
|
||||
const log = getLogger('sitespeedio.plugin.influxdb');
|
||||
export default class InfluxDBPlugin extends SitespeedioPlugin {
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
/* eslint no-console:0 */
|
||||
|
||||
import { getLogger } from '@sitespeed.io/log';
|
||||
import isEmpty from 'lodash.isempty';
|
||||
import { SitespeedioPlugin } from '@sitespeed.io/plugin';
|
||||
|
||||
import { isEmpty } from '../../support/util.js';
|
||||
|
||||
const log = getLogger('sitespeedio.plugin.messagelogger');
|
||||
|
||||
function shortenData(key, value) {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
import isEmpty from 'lodash.isempty';
|
||||
import get from 'lodash.get';
|
||||
import set from 'lodash.set';
|
||||
import merge from 'lodash.merge';
|
||||
import reduce from 'lodash.reduce';
|
||||
|
||||
import { toArray } from './util.js';
|
||||
import { toArray, isEmpty } from './util.js';
|
||||
|
||||
function normalizePath(path) {
|
||||
if (path.endsWith('.*')) return path.slice(0, -2);
|
||||
|
|
|
|||
|
|
@ -21,3 +21,27 @@ export function throwIfMissing(options, keys, namespace) {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
export function isEmpty(value) {
|
||||
if (value === null) return true;
|
||||
|
||||
if (value === undefined) return true;
|
||||
|
||||
if (typeof value === 'boolean') return false;
|
||||
|
||||
if (typeof value === 'number') return false;
|
||||
|
||||
if (typeof value === 'string') return value.length === 0;
|
||||
|
||||
if (typeof value === 'function') return false;
|
||||
|
||||
if (Array.isArray(value)) return value.length === 0;
|
||||
|
||||
if (value instanceof Map || value instanceof Set) return value.size === 0;
|
||||
|
||||
if (typeof value === 'object') {
|
||||
return Object.keys(value).length === 0;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@
|
|||
"jstransformer-markdown-it": "3.0.0",
|
||||
"junit-report-builder": "3.2.1",
|
||||
"lodash.get": "4.4.2",
|
||||
"lodash.isempty": "4.4.0",
|
||||
"lodash.merge": "4.6.2",
|
||||
"lodash.reduce": "4.6.0",
|
||||
"lodash.set": "4.3.2",
|
||||
|
|
@ -7096,11 +7095,6 @@
|
|||
"resolved": "https://registry.npmjs.org/lodash.groupby/-/lodash.groupby-4.6.0.tgz",
|
||||
"integrity": "sha1-Cwih3PaDl8OXhVwyOXg4Mt90A9E="
|
||||
},
|
||||
"node_modules/lodash.isempty": {
|
||||
"version": "4.4.0",
|
||||
"resolved": "https://registry.npmjs.org/lodash.isempty/-/lodash.isempty-4.4.0.tgz",
|
||||
"integrity": "sha1-b4bL7di+TsmHvpqvM8loTbGzHn4="
|
||||
},
|
||||
"node_modules/lodash.merge": {
|
||||
"version": "4.6.2",
|
||||
"resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz",
|
||||
|
|
|
|||
|
|
@ -100,7 +100,6 @@
|
|||
"jstransformer-markdown-it": "3.0.0",
|
||||
"junit-report-builder": "3.2.1",
|
||||
"lodash.get": "4.4.2",
|
||||
"lodash.isempty": "4.4.0",
|
||||
"lodash.merge": "4.6.2",
|
||||
"lodash.reduce": "4.6.0",
|
||||
"lodash.set": "4.3.2",
|
||||
|
|
|
|||
Loading…
Reference in New Issue