PHP 8.2.30
Preview: getDistVersion.ts Size: 811 B
//proc/thread-self/root/home/byroehnu/.trash/node_modules11/simple-update-notifier/src/getDistVersion.ts

import https from 'https';

const getDistVersion = async (packageName: string, distTag: string) => {
  const url = `https://registry.npmjs.org/-/package/${packageName}/dist-tags`;

  return new Promise<string>((resolve, reject) => {
    https
      .get(url, (res) => {
        let body = '';

        res.on('data', (chunk) => (body += chunk));
        res.on('end', () => {
          try {
            const json = JSON.parse(body);
            const version = json[distTag];
            if (!version) {
              reject(new Error('Error getting version'));
            }
            resolve(version);
          } catch {
            reject(new Error('Could not parse version response'));
          }
        });
      })
      .on('error', (err) => reject(err));
  });
};

export default getDistVersion;

Directory Contents

Dirs: 0 × Files: 11

Name Size Perms Modified Actions
371 B lrw-r--r-- 2026-02-03 15:06:46
Edit Download
527 B lrw-r--r-- 2026-02-03 15:06:46
Edit Download
1.03 KB lrw-r--r-- 2026-02-03 15:06:46
Edit Download
810 B lrw-r--r-- 2026-02-03 15:06:46
Edit Download
811 B lrw-r--r-- 2026-02-03 15:06:46
Edit Download
2.32 KB lrw-r--r-- 2026-02-03 15:06:46
Edit Download
1.12 KB lrw-r--r-- 2026-02-03 15:06:46
Edit Download
744 B lrw-r--r-- 2026-02-03 15:06:46
Edit Download
984 B lrw-r--r-- 2026-02-03 15:06:46
Edit Download
444 B lrw-r--r-- 2026-02-03 15:06:46
Edit Download
202 B lrw-r--r-- 2026-02-03 15:06:46
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).