all-node-versions
Advanced tools
Comparing version 9.0.0 to 10.0.0
@@ -1,2 +0,2 @@ | ||
import{promises as fs}from"fs"; | ||
import{readFile}from"fs/promises"; | ||
import{env}from"process"; | ||
@@ -19,3 +19,3 @@ | ||
export const getCacheFileContent=async function(cacheFile){ | ||
const cacheFileContent=await fs.readFile(cacheFile,"utf8"); | ||
const cacheFileContent=await readFile(cacheFile); | ||
const{lastUpdate,...versionsInfo}=JSON.parse(cacheFileContent); | ||
@@ -22,0 +22,0 @@ const age=Date.now()-lastUpdate; |
@@ -1,2 +0,2 @@ | ||
import pathExists from"path-exists"; | ||
import{pathExists}from"path-exists"; | ||
@@ -17,4 +17,4 @@ import{ | ||
export const readCachedVersions=async function(fetch){ | ||
if(fetch===true){ | ||
export const readCachedVersions=async function(fetchOpt){ | ||
if(fetchOpt===true){ | ||
return; | ||
@@ -31,3 +31,3 @@ } | ||
if(isOldCache(age,fetch)){ | ||
if(isOldCache(age,fetchOpt)){ | ||
return; | ||
@@ -39,4 +39,4 @@ } | ||
const isOldCache=function(age,fetch){ | ||
return age>MAX_AGE_MS&&fetch!==false; | ||
const isOldCache=function(age,fetchOpt){ | ||
return age>MAX_AGE_MS&&fetchOpt!==false; | ||
}; | ||
@@ -43,0 +43,0 @@ |
export const groupBy=function(array,group){ | ||
const mapper=getMapper(group); | ||
return groupByFunc(array,mapper); | ||
}; | ||
const getMapper=function(group){ | ||
if(typeof group==="function"){ | ||
return group; | ||
} | ||
if(typeof group==="string"){ | ||
return getByProp.bind(undefined,group); | ||
} | ||
if(Array.isArray(group)){ | ||
return getByProps.bind(undefined,group); | ||
} | ||
throw new Error(`Group must be a function, property or array of properties`); | ||
}; | ||
const getByProps=function(propNames,object){ | ||
let keys=""; | ||
for(const propName of propNames){ | ||
const key=getByProp(propName,object); | ||
keys=keys===""?key:`${keys}.${key}`; | ||
} | ||
return keys; | ||
}; | ||
const getByProp=function(propName,object){ | ||
if(object===null||typeof object!=="object"){ | ||
return""; | ||
} | ||
return String(object[propName]); | ||
}; | ||
const groupByFunc=function(array,mapper){ | ||
const object={}; | ||
@@ -54,3 +8,3 @@ | ||
for(const item of array){ | ||
const key=String(mapper(item)); | ||
const key=String(item[group]); | ||
@@ -57,0 +11,0 @@ |
@@ -12,4 +12,4 @@ import{env}from"process"; | ||
export default async function allNodeVersions(opts){ | ||
const{fetch,...fetchNodeOpts}=getOpts(opts); | ||
const versionsInfo=await getAllVersions(fetch,fetchNodeOpts); | ||
const{fetch:fetchOpt,...fetchNodeOpts}=getOpts(opts); | ||
const versionsInfo=await getAllVersions(fetchOpt,fetchNodeOpts); | ||
return versionsInfo; | ||
@@ -19,6 +19,6 @@ } | ||
const getAllVersions=async function(fetch,fetchNodeOpts){ | ||
const getAllVersions=async function(fetchOpt,fetchNodeOpts){ | ||
if( | ||
processCachedVersions!==undefined&& | ||
fetch!==true&& | ||
fetchOpt!==true&& | ||
!env.TEST_CACHE_FILENAME) | ||
@@ -29,3 +29,3 @@ { | ||
const versionsInfo=await getVersionsInfo(fetch,fetchNodeOpts); | ||
const versionsInfo=await getVersionsInfo(fetchOpt,fetchNodeOpts); | ||
@@ -42,9 +42,10 @@ | ||
const getVersionsInfo=async function(fetch,fetchNodeOpts){ | ||
const cachedVersions=await readCachedVersions(fetch); | ||
const getVersionsInfo=async function(fetchOpt,fetchNodeOpts){ | ||
const cachedVersions=await readCachedVersions(fetchOpt); | ||
return cachedVersions===undefined? | ||
await getNewVersionsInfo(fetchNodeOpts): | ||
cachedVersions; | ||
}; | ||
if(cachedVersions!==undefined){ | ||
return cachedVersions; | ||
} | ||
const getNewVersionsInfo=async function(fetchNodeOpts){ | ||
try{ | ||
@@ -51,0 +52,0 @@ const index=await fetchIndex(fetchNodeOpts); |
@@ -58,5 +58,7 @@ import semver from"semver"; | ||
const compareMajor=function({major:majorA},{major:majorB}){ | ||
/* c8 ignore next */ | ||
return majorA<majorB?1:-1; | ||
}; | ||
//# sourceMappingURL=normalize.js.map |
{ | ||
"name": "all-node-versions", | ||
"version": "9.0.0", | ||
"version": "10.0.0", | ||
"type": "module", | ||
@@ -50,18 +50,18 @@ "exports": "./build/src/main.js", | ||
"fetch-node-website": "^6.0.0", | ||
"filter-obj": "^2.0.2", | ||
"filter-obj": "^3.0.0", | ||
"get-stream": "^6.0.0", | ||
"global-cache-dir": "^3.0.1", | ||
"jest-validate": "^27.0.2", | ||
"path-exists": "^4.0.0", | ||
"semver": "^7.3.5", | ||
"write-file-atomic": "^3.0.3" | ||
"jest-validate": "^27.5.1", | ||
"path-exists": "^5.0.0", | ||
"semver": "^7.3.6", | ||
"write-file-atomic": "^4.0.1" | ||
}, | ||
"devDependencies": { | ||
"@ehmicky/dev-tasks": "^1.0.34", | ||
"@ehmicky/dev-tasks": "^1.0.72", | ||
"is-plain-obj": "^4.0.0", | ||
"test-each": "^3.0.1" | ||
"test-each": "^4.0.0" | ||
}, | ||
"engines": { | ||
"node": ">=12.20.0" | ||
"node": ">=14.18.0" | ||
} | ||
} |
@@ -105,3 +105,3 @@ [![Codecov](https://img.shields.io/codecov/c/github/ehmicky/all-node-versions.svg?label=tested&logo=codecov)](https://codecov.io/gh/ehmicky/all-node-versions) | ||
Base URL to fetch the list of available Node.js versions. Can be customized (for | ||
example `https://npm.taobao.org/mirrors/node`). | ||
example `https://npmmirror.com/mirrors/node`). | ||
@@ -108,0 +108,0 @@ The following environment variables can also be used: `NODE_MIRROR`, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
1
42768
191
+ Addedfilter-obj@3.0.0(transitive)
+ Addedpath-exists@5.0.0(transitive)
+ Addedwrite-file-atomic@4.0.2(transitive)
- Removedis-typedarray@1.0.0(transitive)
- Removedtypedarray-to-buffer@3.1.5(transitive)
- Removedwrite-file-atomic@3.0.3(transitive)
Updatedfilter-obj@^3.0.0
Updatedjest-validate@^27.5.1
Updatedpath-exists@^5.0.0
Updatedsemver@^7.3.6
Updatedwrite-file-atomic@^4.0.1