🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@nodevu/core

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nodevu/core - npm Package Compare versions

Comparing version
0.2.0
to
0.3.0
+40
util/prod/optionsParser.js
const { DateTime } = require('luxon');
// this function allows us to parse user-passed options.
//
// this is particularly useful for tests so we can reduce variables
// and ensure that our test suite is able to be consistent.
function parseOptions(options) {
// set up our defaults
const parsedOptions = {
fetch: globalThis.fetch,
now: DateTime.now(),
urls: {
index: 'https://nodejs.org/dist/index.json',
schedule:
'https://raw.githubusercontent.com/nodejs/Release/master/schedule.json',
},
};
// allow the end-user to replace our fetch implementation with another one they prefer.
if (options?.fetch) {
parsedOptions.fetch = options.fetch;
}
// allow the end-user to provide a custom DateTime. This is particularly useful for tests.
if (options?.now) {
parsedOptions.now = options.now;
}
if (options?.urls?.index) {
parsedOptions.urls.index = options.urls.index;
}
if (options?.urls?.schedule) {
parsedOptions.urls.schedule = options.urls.schedule;
}
return parsedOptions;
}
module.exports = parseOptions;
async function schedule(options) {
// parse our options and set up fetch if a custom fetch is passed
const fetch = options.fetch;
const url = options.urls.schedule;
// fetch the url, get the json from the fetched URL that we're going to use
const raw = await fetch(url);
const schedule = await raw.json();
return schedule;
}
module.exports = schedule;
async function versions(options) {
// parse our options and set up fetch if a custom fetch is passed
const fetch = options.fetch;
const url = options.urls.index;
// fetch the url, get the json from the fetched URL that we're going to use
const raw = await fetch(url);
const versions = await raw.json();
return versions;
}
module.exports = versions;
+5
-9
{
"name": "@nodevu/core",
"version": "0.2.0",
"version": "0.3.0",
"description": "nodevu core API: comprehensive node.js version tooling",

@@ -9,7 +9,7 @@ "main": "index.js",

"lint:write": "biome check ./ --write",
"test": "node--test",
"test": "node --test",
"test:update": "npm run test:update:static && npm run test:update:now",
"test:update:static": "node ./util/dev/updateStaticData.js",
"test:update:now": "node ./util/dev/updateStaticNow.js",
"coverage": "nyc node--test",
"coverage": "c8 node --test",
"updates:check": "npx npm-check-updates",

@@ -20,6 +20,3 @@ "updates:update": "npx npm-check-updates -u"

"license": "MIT",
"files": [
"index.js",
"LICENSE"
],
"files": ["index.js", "LICENSE", "/util/prod"],
"dependencies": {

@@ -32,6 +29,5 @@ "@nodevu/parsefiles": "^0.0.3",

"@biomejs/biome": "1.9.4",
"nyc": "^17.1.0",
"test": "^3.3.0",
"c8": "^10.1.2",
"undici": "^6.20.1"
}
}