1.1.1 • Published 5 years ago

check-extension v1.1.1

Weekly downloads
7
License
MIT
Repository
github
Last release
5 years ago

ci status

check-extension

Check whether a file has a given extension.

Install

npm i check-extension

Usage

const checkExtension = require("check-extension");

let isJsFile = checkExtension("myFile.js", ".js"); // => true
let isJsonFile = checkExtension("myFile.js", ".json"); // => false
let isMarkdownFile = checkExtension("README.md", [".md", ".markdown"]); // => true
let isOtherFile = checkExtension("LICENSE", null); // => true

API

function checkExtension(file, extensions)

Checks whether a file has a given extension.

Parameters

NameTypeDescription
filestringThe path of the file to check.
extensionsstring/arrayOne or more allowed extensions. Can be omitted (or set to a falsy value like null) to check whether a file has no extension.

Returns

true if the extensions matched, false otherwise.

Testing

npm test

License

MIT

1.1.1

5 years ago

1.1.0

6 years ago

1.0.0

8 years ago