-
Notifications
You must be signed in to change notification settings - Fork 0
Home
David Vegh edited this page May 4, 2022
·
2 revisions
write-jsdelivrstat makes it easy to collect, filter and save jsdelivr statistics to csv files.
Visit our documentation site for code reference.
In these examples we initilaize a WriteJsdelivrStat
class in order to collect statistics about npm-stat-api
npm package.
Parameters:
-
packageName
: name of the target npm package -
outDir
: path of the directory where the gathered data will be saved into csv files
Because outDir
is null
the gathered statistics will be only printed to the console.
const WriteJsdelivrStat = require("write-jsdelivrstat").default;
const targetPackage = "npm-stat-api";
const writejsdelivrstat = new WriteJsdelivrStat(targetPackage);
Because outDir
is not null
the gathered statistics will be saved into csv files too.
const WriteJsdelivrStat = require("write-jsdelivrstat").default;
const targetPackage = "npm-stat-api";
const csvDir = "stats/npm-stat-api";
const writejsdelivrstat = new WriteJsdelivrStat(targetPackage, csvDir);
Properties:
-
outDir
: path of the directory where the gathered data will be saved into csv files -
datePeriod
: grouping of the statistics -
writePackageName
: flag used to write the name of the package into a csv column -
mergeStoredData
: flag used to merge actual jsdelivr statistics with previously stored
outDir
can be changed or set at anytime.
const WriteJsdelivrStat = require("write-jsdelivrstat").default;
const targetPackage = "npm-stat-api";
const writejsdelivrstat = new WriteJsdelivrStat(targetPackage);
writejsdelivrstat.outDir = "stats/npm-stat-api";
const WriteJsdelivrStat = require("write-jsdelivrstat").default;
const targetPackage = "npm-stat-api";
const writejsdelivrstat = new WriteJsdelivrStat(targetPackage);
writejsdelivrstat.datePeriod = "month";
const WriteJsdelivrStat = require("write-jsdelivrstat").default;
const targetPackage = "npm-stat-api";
const writejsdelivrstat = new WriteJsdelivrStat(targetPackage);
writejsdelivrstat.writePackageName = true;
const WriteJsdelivrStat = require("write-jsdelivrstat").default;
const targetPackage = "npm-stat-api";
const writejsdelivrstat = new WriteJsdelivrStat(targetPackage);
writejsdelivrstat.mergeStoredData = false;
Parameters:
-
startDate
: start date of the statistics -
endDate
: end date of the statistics
const WriteJsdelivrStat = require("write-jsdelivrstat").default;
const targetPackage = "npm-stat-api";
const writejsdelivrstat = new WriteJsdelivrStat(targetPackage);
writejsdelivrstat.getJsdelivrStat("2022-03", "2022-04-10").then(stats => {
console.log(stats);
});
Parameters:
-
startDate
: start date of the statistics -
endDate
: end date of the statistics -
postfix
: postfix of the csv file
const WriteJsdelivrStat = require("write-jsdelivrstat").default;
const targetPackage = "npm-stat-api";
const csvDir = "stats/npm-stat-api";
const writejsdelivrstat = new WriteJsdelivrStat(targetPackage, csvDir);
writejsdelivrstat.datePeriod = "month";
writejsdelivrstat.writeJsdelivrStat("2022", "2022-03");