Skip to content

Commit

Permalink
Mine types + Extensions (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
remithomas authored Jul 12, 2018
1 parent a6226ea commit c4df7a8
Show file tree
Hide file tree
Showing 13 changed files with 436 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
.npmrc
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
> Simple common constants, for Javascript and Typescript projects.
- [Country codes](#country-codes) (fr,es,...)
- [Extensions](#extensions) (wav,doc,3gp,...)
- [Http codes](#http-codes) (404,499,...)
- [Http methods](#http-methods) (GET,POST,...)
- [Language codes](#language-codes) (fr,ty,...)
Expand All @@ -29,6 +30,16 @@ import { UNITED_KINGDOM } from 'generalities/country-codes';
console.log(UNITED_KINGDOM);
```

### Extensions

Print extensions without dot `.`

```js
import { VIDEO_3GPP2 } from 'generalities/extensions';
// print: 3g2
console.log(VIDEO_3GPP2);
```

### Http Methods

```js
Expand All @@ -53,6 +64,14 @@ import { FRENCH, TAHITIAN } from 'generalities/language-codes';
console.log(FRENCH, TAHITIAN);
```

### MIME types

```js
import { VIDEO_3GPP2 } from 'generalities/mime-types';
// print: video/3gpp2
console.log(VIDEO_3GPP2);
```

## Development

```bash
Expand All @@ -74,4 +93,3 @@ Please feel free to submit, comment anything on this repo :)
## Todos

- [ ] Currency codes
- [ ] [MIME types and extensions](https://developer.mozilla.org/fr/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Complete_list_of_MIME_types)
70 changes: 70 additions & 0 deletions extensions.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
export declare const APPLICATION_7Z: string;
export declare const APPLICATION_DOCX: string;
export declare const APPLICATION_EPUB_ZIP: string;
export declare const APPLICATION_JAVA_ARCHIVE: string;
export declare const APPLICATION_JAVASCRIPT: string;
export declare const APPLICATION_JSON: string;
export declare const APPLICATION_MSWORD: string;
export declare const APPLICATION_OCTET_STREAM: string;
export declare const APPLICATION_OCTET_STREAM2: string;
export declare const APPLICATION_OGG: string;
export declare const APPLICATION_PDF: string;
export declare const APPLICATION_RTF: string;
export declare const APPLICATION_TYPESCRIPT: string;
export declare const APPLICATION_VND_AMAZON_EBOOK: string;
export declare const APPLICATION_VND_APPLE_INSTALLER: string;
export declare const APPLICATION_VND_MOZILLA_XUL_XML: string;
export declare const APPLICATION_VND_MS_EXCEL: string;
export declare const APPLICATION_VND_MS_FONTOBJECT: string;
export declare const APPLICATION_VND_MS_POWERPOINT_OPENXML: string;
export declare const APPLICATION_VND_MS_POWERPOINT: string;
export declare const APPLICATION_VND_OASIS_OPENDOCUMENT_PRESENTATION: string;
export declare const APPLICATION_VND_OASIS_OPENDOCUMENT_SPREADSHEET_SHEET: string;
export declare const APPLICATION_VND_OASIS_OPENDOCUMENT_SPREADSHEET: string;
export declare const APPLICATION_VND_OASIS_OPENDOCUMENT_TEXT: string;
export declare const APPLICATION_VND_OPENXMLFORMATS_OFFICEDOCUMENT_PRESENTATIONML: string;
export declare const APPLICATION_VND_OPENXMLFORMATS_OFFICEDOCUMENT_WORDPROCESSINGML: string;
export declare const APPLICATION_VND_VISIO: string;
export declare const APPLICATION_X_ABIWORD: string;
export declare const APPLICATION_X_BZIP: string;
export declare const APPLICATION_X_BZIP2: string;
export declare const APPLICATION_X_CSH: string;
export declare const APPLICATION_X_RAR_COMPRESSED: string;
export declare const APPLICATION_X_SH: string;
export declare const APPLICATION_X_SHOCKWAWE_FLASH: string;
export declare const APPLICATION_X_TAR: string;
export declare const APPLICATION_XHTML_XML: string;
export declare const APPLICATION_XML: string;
export declare const APPLICATION_ZIP: string;
export declare const AUDIO_3GPP: string;
export declare const AUDIO_3GPP2: string;
export declare const AUDIO_AAC: string;
export declare const AUDIO_MID: string;
export declare const AUDIO_MIDI: string;
export declare const AUDIO_OGG: string;
export declare const AUDIO_WEBM: string;
export declare const AUDIO_X_WAV: string;
export declare const FONT_OTF: string;
export declare const FONT_TTF: string;
export declare const FONT_WOFF: string;
export declare const FONT_WOFF2: string;
export declare const IMAGE_GIF: string;
export declare const IMAGE_JPEG: string;
export declare const IMAGE_JPG: string;
export declare const IMAGE_PNG: string;
export declare const IMAGE_SVG_XML: string;
export declare const IMAGE_TIF: string;
export declare const IMAGE_TIFF: string;
export declare const IMAGE_WEBP: string;
export declare const IMAGE_X_ICON: string;
export declare const TEXT_CALENDAR: string;
export declare const TEXT_CSS: string;
export declare const TEXT_CSV: string;
export declare const TEXT_HTM: string;
export declare const TEXT_HTML: string;
export declare const VIDEO_3GPP: string;
export declare const VIDEO_3GPP2: string;
export declare const VIDEO_MPEG: string;
export declare const VIDEO_OGG: string;
export declare const VIDEO_WEBM: string;
export declare const VIDEO_X_MSVIDEO: string;
72 changes: 72 additions & 0 deletions extensions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.APPLICATION_7Z = '7z';
exports.APPLICATION_DOCX = 'docx'; // alias
exports.APPLICATION_EPUB_ZIP = 'epub';
exports.APPLICATION_JAVA_ARCHIVE = 'jar';
exports.APPLICATION_JAVASCRIPT = 'js';
exports.APPLICATION_JSON = 'json';
exports.APPLICATION_MSWORD = 'doc';
exports.APPLICATION_OCTET_STREAM = 'arc';
exports.APPLICATION_OCTET_STREAM2 = 'bin';
exports.APPLICATION_OGG = 'ogx';
exports.APPLICATION_PDF = 'pdf';
exports.APPLICATION_RTF = 'rtf';
exports.APPLICATION_TYPESCRIPT = 'ts';
exports.APPLICATION_VND_AMAZON_EBOOK = 'azw';
exports.APPLICATION_VND_APPLE_INSTALLER = 'mpkg';
exports.APPLICATION_VND_MOZILLA_XUL_XML = 'xul';
exports.APPLICATION_VND_MS_EXCEL = 'xls';
exports.APPLICATION_VND_MS_FONTOBJECT = 'eot';
exports.APPLICATION_VND_MS_POWERPOINT_OPENXML = 'pptx';
exports.APPLICATION_VND_MS_POWERPOINT = 'ppt';
exports.APPLICATION_VND_OASIS_OPENDOCUMENT_PRESENTATION = 'odp';
exports.APPLICATION_VND_OASIS_OPENDOCUMENT_SPREADSHEET_SHEET = 'xlsx';
exports.APPLICATION_VND_OASIS_OPENDOCUMENT_SPREADSHEET = 'ods';
exports.APPLICATION_VND_OASIS_OPENDOCUMENT_TEXT = 'odt';
exports.APPLICATION_VND_OPENXMLFORMATS_OFFICEDOCUMENT_PRESENTATIONML = 'pptx';
exports.APPLICATION_VND_OPENXMLFORMATS_OFFICEDOCUMENT_WORDPROCESSINGML = 'docx';
exports.APPLICATION_VND_VISIO = 'vsd';
exports.APPLICATION_X_ABIWORD = 'abw';
exports.APPLICATION_X_BZIP = 'bz';
exports.APPLICATION_X_BZIP2 = 'bz2';
exports.APPLICATION_X_CSH = 'csh';
exports.APPLICATION_X_RAR_COMPRESSED = 'rar';
exports.APPLICATION_X_SH = 'sh';
exports.APPLICATION_X_SHOCKWAWE_FLASH = 'swf';
exports.APPLICATION_X_TAR = 'tar';
exports.APPLICATION_XHTML_XML = 'xhtml';
exports.APPLICATION_XML = 'xml';
exports.APPLICATION_ZIP = 'zip';
exports.AUDIO_3GPP = '3gp';
exports.AUDIO_3GPP2 = '3g2';
exports.AUDIO_AAC = 'aac';
exports.AUDIO_MID = 'mid';
exports.AUDIO_MIDI = 'midi';
exports.AUDIO_OGG = 'oga';
exports.AUDIO_WEBM = 'weba';
exports.AUDIO_X_WAV = 'wav';
exports.FONT_OTF = 'otf';
exports.FONT_TTF = 'ttf';
exports.FONT_WOFF = 'woff';
exports.FONT_WOFF2 = 'woff2';
exports.IMAGE_GIF = 'gif';
exports.IMAGE_JPEG = 'jpeg';
exports.IMAGE_JPG = 'jpg';
exports.IMAGE_PNG = 'png';
exports.IMAGE_SVG_XML = 'svg';
exports.IMAGE_TIF = 'tif';
exports.IMAGE_TIFF = 'tiff';
exports.IMAGE_WEBP = 'webp';
exports.IMAGE_X_ICON = 'ico';
exports.TEXT_CALENDAR = 'ics';
exports.TEXT_CSS = 'css';
exports.TEXT_CSV = 'csv';
exports.TEXT_HTM = 'htm';
exports.TEXT_HTML = 'html';
exports.VIDEO_3GPP = '3gp';
exports.VIDEO_3GPP2 = '3g2';
exports.VIDEO_MPEG = 'mpeg';
exports.VIDEO_OGG = 'ogv';
exports.VIDEO_WEBM = 'webm';
exports.VIDEO_X_MSVIDEO = 'avi';
70 changes: 70 additions & 0 deletions extensions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
export const APPLICATION_7Z: string = '7z';
export const APPLICATION_DOCX: string = 'docx'; // alias
export const APPLICATION_EPUB_ZIP: string = 'epub';
export const APPLICATION_JAVA_ARCHIVE: string = 'jar';
export const APPLICATION_JAVASCRIPT: string = 'js';
export const APPLICATION_JSON: string = 'json';
export const APPLICATION_MSWORD: string = 'doc';
export const APPLICATION_OCTET_STREAM: string = 'arc';
export const APPLICATION_OCTET_STREAM2: string = 'bin';
export const APPLICATION_OGG: string = 'ogx';
export const APPLICATION_PDF: string = 'pdf';
export const APPLICATION_RTF: string = 'rtf';
export const APPLICATION_TYPESCRIPT: string = 'ts';
export const APPLICATION_VND_AMAZON_EBOOK: string = 'azw';
export const APPLICATION_VND_APPLE_INSTALLER: string = 'mpkg';
export const APPLICATION_VND_MOZILLA_XUL_XML: string = 'xul';
export const APPLICATION_VND_MS_EXCEL: string = 'xls';
export const APPLICATION_VND_MS_FONTOBJECT: string = 'eot';
export const APPLICATION_VND_MS_POWERPOINT_OPENXML: string = 'pptx';
export const APPLICATION_VND_MS_POWERPOINT: string = 'ppt';
export const APPLICATION_VND_OASIS_OPENDOCUMENT_PRESENTATION: string = 'odp';
export const APPLICATION_VND_OASIS_OPENDOCUMENT_SPREADSHEET_SHEET: string = 'xlsx';
export const APPLICATION_VND_OASIS_OPENDOCUMENT_SPREADSHEET: string = 'ods';
export const APPLICATION_VND_OASIS_OPENDOCUMENT_TEXT: string = 'odt';
export const APPLICATION_VND_OPENXMLFORMATS_OFFICEDOCUMENT_PRESENTATIONML: string = 'pptx';
export const APPLICATION_VND_OPENXMLFORMATS_OFFICEDOCUMENT_WORDPROCESSINGML: string = 'docx';
export const APPLICATION_VND_VISIO: string = 'vsd';
export const APPLICATION_X_ABIWORD: string = 'abw';
export const APPLICATION_X_BZIP: string = 'bz';
export const APPLICATION_X_BZIP2: string = 'bz2';
export const APPLICATION_X_CSH: string = 'csh';
export const APPLICATION_X_RAR_COMPRESSED: string = 'rar';
export const APPLICATION_X_SH: string = 'sh';
export const APPLICATION_X_SHOCKWAWE_FLASH: string = 'swf';
export const APPLICATION_X_TAR: string = 'tar';
export const APPLICATION_XHTML_XML: string = 'xhtml';
export const APPLICATION_XML: string = 'xml';
export const APPLICATION_ZIP: string = 'zip';
export const AUDIO_3GPP: string = '3gp';
export const AUDIO_3GPP2: string = '3g2';
export const AUDIO_AAC: string = 'aac';
export const AUDIO_MID: string = 'mid';
export const AUDIO_MIDI: string = 'midi';
export const AUDIO_OGG: string = 'oga';
export const AUDIO_WEBM: string = 'weba';
export const AUDIO_X_WAV: string = 'wav';
export const FONT_OTF: string = 'otf';
export const FONT_TTF: string = 'ttf';
export const FONT_WOFF: string = 'woff';
export const FONT_WOFF2: string = 'woff2';
export const IMAGE_GIF: string = 'gif';
export const IMAGE_JPEG: string = 'jpeg';
export const IMAGE_JPG: string = 'jpg';
export const IMAGE_PNG: string = 'png';
export const IMAGE_SVG_XML: string = 'svg';
export const IMAGE_TIF: string = 'tif';
export const IMAGE_TIFF: string = 'tiff';
export const IMAGE_WEBP: string = 'webp';
export const IMAGE_X_ICON: string = 'ico';
export const TEXT_CALENDAR: string = 'ics';
export const TEXT_CSS: string = 'css';
export const TEXT_CSV: string = 'csv';
export const TEXT_HTM: string = 'htm';
export const TEXT_HTML: string = 'html';
export const VIDEO_3GPP: string = '3gp';
export const VIDEO_3GPP2: string = '3g2';
export const VIDEO_MPEG: string = 'mpeg';
export const VIDEO_OGG: string = 'ogv';
export const VIDEO_WEBM: string = 'webm';
export const VIDEO_X_MSVIDEO: string = 'avi';
4 changes: 3 additions & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import * as CountryCodes from './country-codes';
import * as Extensions from './extensions';
import * as HttpCodes from './http-codes';
import * as HttpMethods from './http-methods';
import * as LanguageCodes from './language-codes';
export { CountryCodes, HttpCodes, HttpMethods, LanguageCodes, };
import * as MimeTypes from './mime-types';
export { CountryCodes, Extensions, HttpCodes, HttpMethods, LanguageCodes, MimeTypes, };
4 changes: 4 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@
Object.defineProperty(exports, "__esModule", { value: true });
const CountryCodes = require("./country-codes");
exports.CountryCodes = CountryCodes;
const Extensions = require("./extensions");
exports.Extensions = Extensions;
const HttpCodes = require("./http-codes");
exports.HttpCodes = HttpCodes;
const HttpMethods = require("./http-methods");
exports.HttpMethods = HttpMethods;
const LanguageCodes = require("./language-codes");
exports.LanguageCodes = LanguageCodes;
const MimeTypes = require("./mime-types");
exports.MimeTypes = MimeTypes;
4 changes: 4 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import * as CountryCodes from './country-codes';
import * as Extensions from './extensions';
import * as HttpCodes from './http-codes';
import * as HttpMethods from './http-methods';
import * as LanguageCodes from './language-codes';
import * as MimeTypes from './mime-types';

export {
CountryCodes,
Extensions,
HttpCodes,
HttpMethods,
LanguageCodes,
MimeTypes,
};
63 changes: 63 additions & 0 deletions mime-types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
export declare const APPLICATION_7Z: string;
export declare const APPLICATION_EPUB_ZIP: string;
export declare const APPLICATION_JAVA_ARCHIVE: string;
export declare const APPLICATION_JAVASCRIPT: string;
export declare const APPLICATION_JSON: string;
export declare const APPLICATION_MSWORD: string;
export declare const APPLICATION_OCTET_STREAM: string;
export declare const APPLICATION_OGG: string;
export declare const APPLICATION_PDF: string;
export declare const APPLICATION_RTF: string;
export declare const APPLICATION_TYPESCRIPT: string;
export declare const APPLICATION_VND_AMAZON_EBOOK: string;
export declare const APPLICATION_VND_APPLE_INSTALLER: string;
export declare const APPLICATION_VND_MOZILLA_XUL_XML: string;
export declare const APPLICATION_VND_MS_EXCEL: string;
export declare const APPLICATION_VND_MS_FONTOBJECT: string;
export declare const APPLICATION_VND_MS_POWERPOINT: string;
export declare const APPLICATION_VND_OASIS_OPENDOCUMENT_PRESENTATION: string;
export declare const APPLICATION_VND_OASIS_OPENDOCUMENT_SPREADSHEET_SHEET: string;
export declare const APPLICATION_VND_OASIS_OPENDOCUMENT_SPREADSHEET: string;
export declare const APPLICATION_VND_OASIS_OPENDOCUMENT_TEXT: string;
export declare const APPLICATION_VND_OPENXMLFORMATS_OFFICEDOCUMENT_PRESENTATIONML: string;
export declare const APPLICATION_VND_OPENXMLFORMATS_OFFICEDOCUMENT_WORDPROCESSINGML: string;
export declare const APPLICATION_VND_VISIO: string;
export declare const APPLICATION_X_ABIWORD: string;
export declare const APPLICATION_X_BZIP: string;
export declare const APPLICATION_X_BZIP2: string;
export declare const APPLICATION_X_CSH: string;
export declare const APPLICATION_X_RAR_COMPRESSED: string;
export declare const APPLICATION_X_SH: string;
export declare const APPLICATION_X_SHOCKWAWE_FLASH: string;
export declare const APPLICATION_X_TAR: string;
export declare const APPLICATION_XHTML_XML: string;
export declare const APPLICATION_XML: string;
export declare const APPLICATION_ZIP: string;
export declare const AUDIO_3GPP: string;
export declare const AUDIO_3GPP2: string;
export declare const AUDIO_AAC: string;
export declare const AUDIO_MIDI: string;
export declare const AUDIO_OGG: string;
export declare const AUDIO_WEBM: string;
export declare const AUDIO_X_WAV: string;
export declare const FONT_OTF: string;
export declare const FONT_TTF: string;
export declare const FONT_WOFF: string;
export declare const FONT_WOFF2: string;
export declare const IMAGE_GIF: string;
export declare const IMAGE_JPEG: string;
export declare const IMAGE_PNG: string;
export declare const IMAGE_SVG_XML: string;
export declare const IMAGE_TIFF: string;
export declare const IMAGE_WEBP: string;
export declare const IMAGE_X_ICON: string;
export declare const TEXT_CALENDAR = "text/calendar";
export declare const TEXT_CSS: string;
export declare const TEXT_CSV: string;
export declare const TEXT_HTML: string;
export declare const VIDEO_3GPP: string;
export declare const VIDEO_3GPP2: string;
export declare const VIDEO_MPEG: string;
export declare const VIDEO_OGG: string;
export declare const VIDEO_WEBM: string;
export declare const VIDEO_X_MSVIDEO: string;
Loading

0 comments on commit c4df7a8

Please sign in to comment.