is-ipfs
is-ipfs copied to clipboard
Support is* variants
Extracted @alanshaw's suggestion from https://github.com/ipfs/is-ipfs/pull/27#discussion_r259796241:
Not for this PR but I'm musing on naming, I would ideally like to do something like
const { isMultiaddr } = require('is-ipfs')orimport { isMultiaddr } from 'is-ipfs'rather than have to import the whole library.If we eventually start using es-modules we can tree shake the stuff we're not using but as it is now we're encouraging importing the whole library since (for example)
const { cid } = require('is-ipfs')would likely conflict with cid instance vars we have in code and it's not descriptive to validate a cid likeif (cid(myCid)).
TL;DR:
Current
const isIPFS = require('is-ipfs')
isIPFS.multiaddr(addr)
Proposed
const { isMultiaddr } = require('is-ipfs')
isMultiaddr(addr)
I believe we could start with supporting both.