Skip to content

Commit 766a9c3

Browse files
committed
feat(data): add "versions" attribute
this is available in the npm api, and shows the versions and when they were published. Looks like ```json { "versions": { "1.0.0": "2015-12-06T07:21:44.323Z", "6.4.4": "2016-01-18T02:12:56.318Z", "6.6.5": "2016-03-06T05:38:52.075Z", "6.7.4": "2016-03-23T19:08:45.951Z", "6.7.7": "2016-04-24T05:05:42.686Z", "6.10.3": "2016-06-19T02:54:28.902Z", "6.12.0": "2016-08-02T05:58:22.700Z", "6.13.2": "2016-08-24T06:09:43.742Z", "6.14.0": "2016-08-27T07:18:16.659Z", "6.15.0": "2016-09-01T17:18:50.335Z", "6.17.0": "2016-10-04T21:13:21.638Z", "6.18.0": "2016-10-25T05:36:01.320Z", "6.18.1": "2016-10-29T06:04:02.203Z", "6.18.2": "2016-11-07T00:00:41.776Z", "6.19.0": "2016-11-17T18:51:32.158Z", "6.21.0": "2016-12-19T06:02:13.385Z", "6.21.1-0": "2016-12-19T06:30:12.429Z", "6.21.1": "2017-01-03T04:06:15.964Z", "6.22.1": "2017-01-24T19:11:55.667Z", "6.23.1": "2017-02-15T05:40:51.101Z", "6.24.0": "2017-03-27T01:46:22.348Z" } } ```
1 parent 866fbcf commit 766a9c3

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

formatPkg.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,13 @@ export default function formatPkg(pkg) {
6161
const devDependencies = cleaned.devDependencies || {};
6262
const concatenatedName = cleaned.name.replace(/[-/@_.]+/g, '');
6363

64+
const versions = Object.keys(cleaned.other.time)
65+
.filter(key => !['modified', 'created'].includes(key))
66+
.reduce((obj, key) => {
67+
obj[key] = cleaned.other.time[key];
68+
return obj;
69+
}, {});
70+
6471
const rawPkg = {
6572
objectID: cleaned.name,
6673
name: cleaned.name,
@@ -70,6 +77,7 @@ export default function formatPkg(pkg) {
7077
humanDownloadsLast30Days: numeral(0).format('0.[0]a'),
7178
popular: false,
7279
version,
80+
versions,
7381
description: cleaned.description ? cleaned.description : null,
7482
dependencies,
7583
devDependencies,

0 commit comments

Comments
 (0)