This lets you poll locations from IPFS very easily. This is used by ipfs-stats
to manage hundreds of location lookups. It looks up locations sequentially to improve the performance and avoid too many requests at once.
$ npm install --save ipfs-locations
The code published to npm that gets loaded on require is in fact an ES5 transpiled version with the right shims added. This means that you can require it and use with your favorite bundler without having to adjust asset management process.
const LocationsPoller = require('ipfs-locations')
Loading this module through a script tag will make the IpfsLocations
obj available in the global namespace.
<script src="https://unpkg.com/ipfs-locations/dist/index.min.js"></script>
<!-- OR -->
<script src="https://unpkg.com/ipfs-locations/dist/index.js"></script>
ipfs
Object. IPFS API Object.
locations.get(addr)
obtains the location for a certain address. It will return a Promise.locations.getImmediate(addr)
does the same as the previous but returns immediatelly. If there is no value in cache, returns a location with 'Unknown'.