项目作者: AIRTucha

项目描述 :
Lookups correct MIME content-type for specified path and return it as a string
高级语言: TypeScript
项目地址: git://github.com/AIRTucha/path2ct.git
创建时间: 2019-11-09T12:58:54Z
项目社区:https://github.com/AIRTucha/path2ct

开源协议:MIT License

下载


Path to content-type

Build StatusCoverage Status

Get started

The package is available via npm. It has to be installed as a local dependency:

npm install path2ct

It consists of three pure functions which can be used to quickly get file extension or corespondent content type from a path.

API

  1. getContentType: ( path: string) => string | undefined

Lookups correct MIME content-type for specified path and return it as a string. If extension can not be identified returns undefined.

  1. getContentTypeMaybe: (path: string) => Maybe<string>

Works in a very similar way to getContentType, but returns Maybe of the string which is None if MIME type can not be identified.

  1. getExtension: (path: string) => string | undefined

Support function which helps to extract file extension from a path.

Contribution guidelines

The project is based on npm eco-system. Therefore, development process is organized via npm scripts.

For installation of dependencies run

  1. npm install

To build application once

  1. npm run build

To build an application and watch for changes of files

  1. npm run build:w

To run tslint one time for CI

  1. npm run lint

To unit tests in a watching mode are performed by

  1. npm run test

To execute a test suit single time

  1. npm run test:once

To execute a test suit single time with coverage report

  1. npm run test:c

To execute a test suit single time with coverage report submitted to coveralls

  1. npm run test:ci

Everybody is welcome to contribute and submit pull requests. Please communicate your ideas and suggestions via issues.