1.0.1 • Published 12 months ago

exty v1.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
12 months ago

exty

What

A curried library to check the extension type of a file, including extension-less and dotfiles. It works on both relative and absolute paths.

Why?

To replace repetitive checks using path.extname or String.endsWith or a regex pattern.

Example

  • Functions for identifying .js, .ts, and .json files come right out of the box:
import { isJS, isTS, isJSON } from "exty";

const jsPath = "../index.js";
const tsPath = "./index.ts";
const jsonPath = "/home/user/project/package.json";

isJS(jsPath);      //true
isTS(tsPath);      //true
isJSON(jsonPath);  //true
  • Or you can create your own checkers:
import { isExtFactory } from "exty";

const isEnvLocal = isExtFactory(".env.local");

const envLocalPath = "../.env.local";
const envPath = "./.env";

isEnvLocal(envLocalPath); //true
isEnvLocal(envPath);      //false

Installation

$ npm install exty

Dependencies

  • 0 javascript/nodejs dependency!

Test

$ npm test

1.0.1

12 months ago

1.0.0

1 year ago

0.0.1

10 years ago