<commit_before>
import { Options, publish as npmPublish } from "libnpmpublish";
import semver from "semver";

import { getUrl } from "./geturl";
import { Package, getPackage as _getPackage } from "./local";
import { colorify, getPrompt } from "./log";


const cache: Record<string, any> = { };

async function getPackageInfo(name: string): Promise<any> {
    // Convert dirname to package if needed
    name = _getPackage(name).name;

    if (!cache[name]) {
        try {
            const result = await getUrl("http:/" + "/registry.npmjs.org/" + name);
            cache[name] = JSON.parse(Buffer.from(result.body).toString("utf8"));
        } catch (error) {
            if (error.status === 404) { return null; }
            throw error;
        }
    }
    return cache[name] || null;
}<commit_msg>admin: use https endpoints for NPM registry<commit_after>
import { Options, publish as npmPublish } from "libnpmpublish";
import semver from "semver";

import { getUrl } from "./geturl";
import { Package, getPackage as _getPackage } from "./local";
import { colorify, getPrompt } from "./log";


const cache: Record<string, any> = { };

async function getPackageInfo(name: string): Promise<any> {
    // Convert dirname to package if needed
    name = _getPackage(name).name;

    if (!cache[name]) {
        try {
            const result = await getUrl("https:/\/registry.npmjs.org/" + name);
            cache[name] = JSON.parse(Buffer.from(result.body).toString("utf8"));
        } catch (error) {
            if (error.status === 404) { return null; }
            throw error;
        }
    }
    return cache[name] || null;
}
{'fraction_non_alphanumeric': 0.1437308868501529, 'fraction_numerical': 0.004892966360856269, 'mean_word_length': 2.8046511627906976, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2325997', 'n_tokens_mistral': 499, 'n_tokens_neox': 480, 'n_words': 141}