Skip to content

Commit

Permalink
switch to named export for getPackageDownloads and getPackageRequestP…
Browse files Browse the repository at this point in the history
…eriods
  • Loading branch information
cheapsteak committed Jan 15, 2024
1 parent b840723 commit 1e2ef10
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/server/routes/prefetchUrls.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import _ from 'lodash';
import isScopedPackageName from 'utils/isScopedPackageName.js';
import getPackageRequestPeriods from 'utils/getPackageRequestPeriods.js';
import { getPackageRequestPeriods } from 'utils/getPackageRequestPeriods.js';

function getPrefetchUrls(packageNames, start, end) {
const requestPeriods = getPackageRequestPeriods(start, end);
Expand Down
3 changes: 1 addition & 2 deletions packages/utils/getPackageRequestPeriods.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function maxDate(a, b) {
* @param endDay {number} End of period 0 is today
* @returns {Array<{startDate: string, endDate: string}>}
*/
function getPackageRequestPeriods(startDay, endDay) {
export function getPackageRequestPeriods(startDay, endDay) {
let requestPeriod;
let requestEndDay = 1;

Expand Down Expand Up @@ -40,4 +40,3 @@ function getPackageRequestPeriods(startDay, endDay) {

return periods;
}
export default getPackageRequestPeriods;
4 changes: 2 additions & 2 deletions packages/utils/getPackagesDownloadsOverPeriod.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const getPackageRequestPeriods = require('./getPackageRequestPeriods');
const getPackagesDownloads = require('./stats/getPackagesDownloads');
const { getPackageRequestPeriods } = require('./getPackageRequestPeriods');
const { getPackagesDownloads } = require('./stats/getPackagesDownloads');

/**
* Merge 2 statistic periods
Expand Down
7 changes: 4 additions & 3 deletions packages/utils/stats/getPackagesDownloads.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import isScopedPackageName from '../isScopedPackageName.js';
import fetchPackagesStats from './fetchPackagesStats.js';
import standardizeNpmPackageResponse from './standardizeNpmPackageResponse.js';

async function getPackagesDownloads(packageNames, { startDate, endDate }) {
export async function getPackagesDownloads(
packageNames,
{ startDate, endDate },
) {
const [scopedPackageNames, standardPackageNames] = _.partition(
packageNames,
isScopedPackageName,
Expand Down Expand Up @@ -38,5 +41,3 @@ async function getPackagesDownloads(packageNames, { startDate, endDate }) {
combinedPackagesStats.find(entry => entry.package === packageName),
);
}

export default getPackagesDownloads;
2 changes: 1 addition & 1 deletion packages/utils/stats/getPackagesDownloads.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import getPackageDownloads from './getPackagesDownloads';
import { getPackageDownloads } from './getPackagesDownloads';
import dummyData from '../dummyData';

jest.mock('./fetchPackagesStats');
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/stats/getPackagesDownloadsComparisons.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import _ from 'lodash';
import dateFns from 'date-fns';

import getPackagesDownloads from './getPackagesDownloads.js';
import { getPackagesDownloads } from './getPackagesDownloads.js';

const { format: formatDate, subDays } = dateFns;

Expand Down

0 comments on commit 1e2ef10

Please sign in to comment.