在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:SilentCicero/ipfs-mini开源软件地址:https://github.com/SilentCicero/ipfs-mini开源编程语言:JavaScript 100.0%开源软件介绍:ipfs-miniA super tiny module for querying an IPFS node, that works in the browser and in Node. Only 2.76 kB compressed! This module was inspired by Install
Usageconst IPFS = require('ipfs-mini');
const ipfs = new IPFS({ host: 'ipfs.infura.io', port: 5001, protocol: 'https' });
ipfs.add('hello world!').then(console.log).catch(console.log);
// result null 'QmTp2hEo8eXRp6wg7jXv1BLCMh5a4F3B7buAUZNZUu772j'
ipfs.cat('QmTp2hEo8eXRp6wg7jXv1BLCMh5a4F3B7buAUZNZUu772j', (err, result) => {
console.log(err, result);
});
// result null 'hello world!'
ipfs.addJSON({ somevalue: 2, name: 'Nick' }, (err, result) => {
console.log(err, result);
});
// result null 'QmTp2hEo8eXRp6wg7jXv1BLCMh5a4F3B7buAUZNZUu772j'
ipfs.catJSON('QmTp2hEo8eXRp6wg7jXv1BLCMh5a4F3B7buAUZNZUu772j').then(console.log).catch(console.log);
// result null { somevalue: 2, name: 'Nick' } AboutA very simple module for querying an IPFS node. This module works for both This module uses the ExamplesAn example of the module in use for the browser, can be found in ./example. Inside is a single, no configuration required, HTML file using the Browser Usage
Webpack Figures2.76 kB compressed (not gzipped)
API DesignconstructorIntakes a single provider object, outputs an Parameters
Result output const IPFS = require('ipfs-mini');
const ipfs = new IPFS({ host: 'ipfs.infura.io', port: 5001, protocol: 'https' });
ipfs.cat('QmTp2hEo8eXRp6wg7jXv1BLCMh5a4F3B7buAUZNZUu772j', (err, result) => {
console.log(err, result);
}); setProviderSets the IPFS instance provider. Parameters
No result output. const IPFS = require('ipfs-mini');
const ipfs = new IPFS();
ipfs.setProvider({ host: 'ipfs.infura.io', port: 5001, protocol: 'https' });
ipfs.cat('QmTp2hEo8eXRp6wg7jXv1BLCMh5a4F3B7buAUZNZUu772j', cb); addQueries Parameters
Result output const IPFS = require('ipfs-mini');
const ipfs = new IPFS({ host: 'ipfs.infura.io', port: 5001, protocol: 'https' });
ipfs.add('hello world!', (err, result) => {
console.log(err, result);
});
// result null 'QmTp2hEo8eXRp6wg7jXv1BLCMh5a4F3B7buAUZNZUu772j' addJSONQueries Parameters
Result output const IPFS = require('ipfs-mini');
const ipfs = new IPFS({ host: 'ipfs.infura.io', port: 5001, protocol: 'https' });
ipfs.addJSON({ somevalue: 2, name: 'Nick' }, (err, result) => {
console.log(err, result);
});
// result null 'QmTp2hEo8eXRp6wg7jXv1BLCMh5a4F3B7buAUZNZUu772j' catQueries a Parameters
Result output const IPFS = require('ipfs-mini');
const ipfs = new IPFS({ host: 'ipfs.infura.io', port: 5001, protocol: 'https' });
ipfs.cat('QmTp2hEo8eXRp6wg7jXv1BLCMh5a4F3B7buAUZNZUu772j', (err, result) => {
console.log(err, result);
});
// result null 'Hello world!' catJSONQueries a Parameters
Result output const IPFS = require('ipfs-mini');
const ipfs = new IPFS({ host: 'ipfs.infura.io', port: 5001, protocol: 'https' });
ipfs.catJSON('QmTp2hEo8eXRp6wg7jXv1BLCMh5a4F3B7buAUZNZUu772j', (err, result) => {
console.log(err, result);
});
// result null { somevalue: 2, name: 'Nick' ...} statQueries a Parameters
Result output stats const IPFS = require('ipfs-mini');
const ipfs = new IPFS({ host: 'ipfs.infura.io', port: 5001, protocol: 'https' });
ipfs.stat('QmTp2hEo8eXRp6wg7jXv1BLCMh5a4F3B7buAUZNZUu772j', (err, result) => {
console.log(err, result);
});
/* result null {
BlockSize: 14595
CumulativeSize: 14595
DataSize: 14592
Hash: "QmbhrsdhbvQy3RyNiDdStgF4YRVc4arteS3wL5ES5M6cVd"
LinksSize: 3
NumLinks: 0
}
*/ ContributingPlease help better the ecosystem by submitting issues and pull requests to default. We need all the help we can get to build the absolute best linting standards and utilities. We follow the AirBNB linting standard and the unix philosophy. Help outThere is always a lot of work to do, and will have many rules to maintain. So please help out in any way that you can:
Please consult our Code of Conduct docs before helping out. We communicate via issues and pull requests. Important documentsLicenceThis project is licensed under the MIT license, Copyright (c) 2016 Nick Dodson. For more information see LICENSE.md.
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论