Skip to content

Commit

Permalink
chore: merge branch 'release/1.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
JadsonLucena committed Aug 19, 2024
2 parents ee0ae1e + aff2318 commit 61abf92
Show file tree
Hide file tree
Showing 7 changed files with 8,509 additions and 1,258 deletions.
101 changes: 4 additions & 97 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# MediaTypes
[![CodeQL](https://github.com/JadsonLucena/MediaTypes.js/actions/workflows/github-code-scanning/codeql/badge.svg)](https://github.com/JadsonLucena/MediaTypes.js/actions/workflows/github-code-scanning/codeql)
[![Test](https://github.com/JadsonLucena/MediaTypes.js/actions/workflows/test.yml/badge.svg)](https://github.com/JadsonLucena/MediaTypes.js/actions/workflows/test.yml)
[![Coverage Status](https://coveralls.io/repos/github/JadsonLucena/MediaTypes.js/badge.svg)](https://coveralls.io/github/JadsonLucena/MediaTypes.js)
[![Coverage](https://coveralls.io/repos/github/JadsonLucena/MediaTypes.js/badge.svg)](https://coveralls.io/github/JadsonLucena/MediaTypes.js)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-%23FE5196?logo=conventionalcommits&logoColor=white)](https://conventionalcommits.org)

Expand All @@ -12,101 +12,8 @@ This is a comprehensive compilation of media types under the [RFC-6838](https://
A file's extension has no meaning on the web. In order for the client to interpret the document correctly, the media type must be sent in the Content-Type header.


## Interfaces
```typescript
/**
* @constructor
* @fires MediaTypes#update
* @fires MediaTypes#error
*
* @throws {TypeError} Invalid updateInterval
*/
constructor(updateInterval?: number = 86400000)
```

```typescript
// Getters
list(): { [extension: string]: MIMEType[] } // List of all extensions with their media types
updateInterval(): number
versions(): { apache: string, debian: string, nginx: string }
```

```typescript
// Setters
/**
* Periodic database update in milliseconds. if less than zero, will be disabled
*
* @fires MediaTypes#update
* @fires MediaTypes#error
*
* @throws {TypeError} Invalid updateInterval
* @see https://developer.mozilla.org/en-US/docs/Web/API/setInterval#delay
*/
updateInterval(updateInterval?: number = 86400000): void
```

```typescript
/**
* @method
* @throws {TypeError} Invalid extension
* @throws {SyntaxError} Invalid extension
* @throws {TypeError} Invalid mediaType
* @throws {SyntaxError} Invalid mediaType
*/
delete(
extension: string
mediaType: string, // https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types#structure_of_a_mime_type
): boolean

/**
* @method
* @throws {TypeError} Invalid path
* @throws {SyntaxError} Invalid extension
*/
get(
path: string // https://nodejs.org/api/path.html#pathparsepath
): MIMEType[] // https://nodejs.org/api/util.html#class-utilmimetype

/**
* @method
* @throws {TypeError} Invalid extension
* @throws {SyntaxError} Invalid extension
* @throws {TypeError} Invalid mediaType
* @throws {SyntaxError} Invalid mediaType
*/
set(
extension: string
mediaType: string, // https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types#structure_of_a_mime_type
): boolean

/**
* @method
* @fires MediaTypes#update
*/
update(force?: boolean = false): Promise<null | { [extension: string]: MIMEType[] }> // List of new inserted media types
```

```typescript
// Events
on('update', callback: (list: { [extension: string]: MIMEType[] }) => void): void
on('error', callback: (error: Error) => void): void
```

> This module extends the main methods of the [EventEmitter module](https://nodejs.org/api/events.html#class-eventemitter):
> - [addListener](https://nodejs.org/api/events.html#emitteraddlistenereventname-listener)
> - [eventNames](https://nodejs.org/api/events.html#emittereventnames)
> - [getMaxListeners](https://nodejs.org/api/events.html#emittergetmaxlisteners)
> - [listenerCount](https://nodejs.org/api/events.html#emitterlistenercounteventname-listener)
> - [listeners](https://nodejs.org/api/events.html#emitterlistenerseventname)
> - [off](https://nodejs.org/api/events.html#emitteroffeventname-listener)
> - [on](https://nodejs.org/api/events.html#emitteroneventname-listener)
> - [once](https://nodejs.org/api/events.html#emitteronceeventname-listener)
> - [prependListener](https://nodejs.org/api/events.html#emitterprependlistenereventname-listener)
> - [prependOnceListener](https://nodejs.org/api/events.html#emitterprependoncelistenereventname-listener)
> - [removeAllListeners](https://nodejs.org/api/events.html#emitterremovealllistenerseventname)
> - [removeListener](https://nodejs.org/api/events.html#emitterremovelistenereventname-listener)
> - [setMaxListeners](https://nodejs.org/api/events.html#emittersetmaxlistenersn)
> - [rawListeners](https://nodejs.org/api/events.html#emitterrawlistenerseventname)
## Interface
Although this is a javascript module, we use a typescript interface to maintain interoperability and better readability. See: [src/MediaTypes.d.ts](src/MediaTypes.d.ts)

## Specifications
We strive to maintain complete code coverage in tests. With that, we provide all the necessary use cases for a good understanding of how this module works. See: [test/MediaTypes.spec.js](https://github.com/JadsonLucena/MediaTypes.js/blob/main/test/MediaTypes.spec.js)
We strive to maintain complete code coverage in tests. With that, we provide all the necessary use cases for a good understanding of how this module works. See: [test/MediaTypes.spec.js](test/MediaTypes.spec.js)
Loading

0 comments on commit 61abf92

Please sign in to comment.