@code-pushup/utils 0.15.0 → 0.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +25 -0
- package/package.json +1 -1
- package/src/index.d.ts +1 -0
- package/src/lib/filter-by-slug.d.ts +6 -0
package/index.js
CHANGED
|
@@ -1687,6 +1687,29 @@ import chalk4 from "chalk";
|
|
|
1687
1687
|
function link2(text) {
|
|
1688
1688
|
return chalk4.underline(chalk4.blueBright(text));
|
|
1689
1689
|
}
|
|
1690
|
+
|
|
1691
|
+
// packages/utils/src/lib/filter-by-slug.ts
|
|
1692
|
+
function filterGroupsByAuditSlug(groups, auditSlugs) {
|
|
1693
|
+
const slugs = toArray(auditSlugs);
|
|
1694
|
+
if (slugs.length === 0) {
|
|
1695
|
+
return groups;
|
|
1696
|
+
}
|
|
1697
|
+
return groups.map((group) => ({
|
|
1698
|
+
...group,
|
|
1699
|
+
refs: filterSlug(group.refs, slugs)
|
|
1700
|
+
})).filter((group) => group.refs.length);
|
|
1701
|
+
}
|
|
1702
|
+
function filterAuditsBySlug(list, auditSlugs) {
|
|
1703
|
+
const slugs = toArray(auditSlugs);
|
|
1704
|
+
if (slugs.length === 0) {
|
|
1705
|
+
return list;
|
|
1706
|
+
}
|
|
1707
|
+
return filterSlug(list, slugs);
|
|
1708
|
+
}
|
|
1709
|
+
function filterSlug(refs, slugOrSlugs) {
|
|
1710
|
+
const slugs = toArray(slugOrSlugs);
|
|
1711
|
+
return refs.filter(({ slug }) => slugs.includes(slug));
|
|
1712
|
+
}
|
|
1690
1713
|
export {
|
|
1691
1714
|
CODE_PUSHUP_DOMAIN,
|
|
1692
1715
|
FOOTER_PREFIX,
|
|
@@ -1705,6 +1728,8 @@ export {
|
|
|
1705
1728
|
exists,
|
|
1706
1729
|
factorOf,
|
|
1707
1730
|
fileExists,
|
|
1731
|
+
filterAuditsBySlug,
|
|
1732
|
+
filterGroupsByAuditSlug,
|
|
1708
1733
|
findLineNumberInText,
|
|
1709
1734
|
formatBytes,
|
|
1710
1735
|
formatDuration,
|
package/package.json
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -16,3 +16,4 @@ export { CODE_PUSHUP_DOMAIN, FOOTER_PREFIX, README_LINK, calcDuration, compareIs
|
|
|
16
16
|
export { CliArgsObject, capitalize, countOccurrences, distinct, factorOf, objectToCliArgs, objectToEntries, objectToKeys, toArray, toNumberPrecision, toOrdinal, toUnixNewlines, toUnixPath, } from './lib/transform';
|
|
17
17
|
export { verboseUtils } from './lib/verbose-utils';
|
|
18
18
|
export { link } from './lib/logging';
|
|
19
|
+
export { filterAuditsBySlug, filterGroupsByAuditSlug, } from './lib/filter-by-slug';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Audit, Group } from '@code-pushup/models';
|
|
2
|
+
export declare function filterGroupsByAuditSlug(groups: Group[], auditSlugs: string | string[]): Group[];
|
|
3
|
+
export declare function filterAuditsBySlug(list: Audit[], auditSlugs: string[] | string): Audit[];
|
|
4
|
+
export declare function filterSlug<T extends {
|
|
5
|
+
slug: string;
|
|
6
|
+
}>(refs: T[], slugOrSlugs: string | string[]): T[];
|