1.0.4 • Published 1 year ago

gpi v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

NPM version

Get a specific package information through a version with range selection, the search algorithm comes from npm/cli.

Online test platform

NPM

import { gpi, preload } from 'gpi';

gpi('react-dom', '^16.x.x', {
  customFetch: window.fetch, // Default value is `window.fetch`
  registry: 'https://registry.npmjs.org', // Default value is `https://registry.npmjs.org`
  retry(err, pkgName, times, nextRequest) {  // Retry callback
    if (times < 5) {
      console.log(`"${pkgName}" retry times (${times})`);
      nextRequest();
    } else {
      throw err; // Must throw an error
    }
  },
}).then(res => {
  console.log(res);
})

// Preload packge information
preload('react', {
  customFetch: window.fetch, // Default value is `window.fetch`
  registry: 'https://registry.npmjs.org', // Default value is `https://registry.npmjs.org`
  retry(err, pkgName, times, nextRequest) {
    if (times < 5) {
      console.log(`"${pkgName}" retry times (${times})`);
      nextRequest();
    } else {
      throw err;
    }
  },
}).then(pkgs => {
  console.log(pkgs);
})

CDN

<!DOCTYPE html>
<html lang="en">
<body>
  <script src="https://unpkg.com/gpi/dist/gpi.umd.js"></script>
  <script>
    const { gpi, preload } = Gpi;

    // ...
  </script>
</body>
</html>
1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago