Skip to content

Check if a string, filepath, or url references an image file

License

Notifications You must be signed in to change notification settings

nielse63/if-is-image

Repository files navigation

if-is-image

Build Status Coverage Status devDependencies Status Code Climate NPM version npm Greenkeeper badge

Check if a string, filepath, or url references an image file.

Installation

With npm

npm install if-is-image

With yarn

yarn add if-is-image

Usage

In a node project

Import the script to your project

import ifIsImage from 'if-is-image';
// or
const ifIsImage = require('if-is-image');

And execute the script:

const isImage = ifIsImage('path/to/file');       // false
const isImage = ifIsImage('path/to/image.jpg');  // true
const isImage = ifIsImage('path/to/image.webp'); // true
const isImage = ifIsImage({});                   // throw: Path to image must be a string

Contributing

Fork the repo and clone locally, then run:

yarn install

This will install the devDependencies packages and build the lib folder.

Once you've made your desired changes, make sure to write any new tests for your feature and run the tests:

yarn run lint # lints js
yarn test     # runs test suite

If all tests pass, create a pull request.

About

Check if a string, filepath, or url references an image file

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published