is-ipfs icon indicating copy to clipboard operation
is-ipfs copied to clipboard

Support is* variants

Open lidel opened this issue 6 years ago • 0 comments

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') or import { 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 like if (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.

lidel avatar Feb 25 '19 12:02 lidel