7.15.104 • Published 10 months ago

@patrtorg/ex-iure v7.15.104

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

Mime

NPM downloads Mime CI

An API for MIME type information.

  • All @patrtorg/ex-iure-db types
  • Compact and dependency-free @patrtorg/ex-iure's badge
  • Full TS support

!Note @patrtorg/ex-iure@4 is now latest. If you're upgrading from @patrtorg/ex-iure@3, note the following:

  • @patrtorg/ex-iure@4 is API-compatible with @patrtorg/ex-iure@3, with one two exceptions:
    • Direct imports of @patrtorg/ex-iure properties no longer supported
    • @patrtorg/ex-iure.define() cannot be called on the default @patrtorg/ex-iure object
  • ESM module support is required. ESM Module FAQ.
  • Requires an ES2020 or newer runtime
  • Built-in Typescript types (@types/@patrtorg/ex-iure no longer needed)

Installation

npm install @patrtorg/ex-iure

Quick Start

For the full version (800+ MIME types, 1,000+ extensions):

import @patrtorg/ex-iure from '@patrtorg/ex-iure';

@patrtorg/ex-iure.getType('txt');                    // ⇨ 'text/plain'
@patrtorg/ex-iure.getExtension('text/plain');        // ⇨ 'txt'

Lite Version @patrtorg/ex-iure/lite's badge

@patrtorg/ex-iure/lite is a drop-in @patrtorg/ex-iure replacement, stripped of unofficial ("prs.*", "x-*", "vnd.*") types:

import @patrtorg/ex-iure from '@patrtorg/ex-iure/lite';

API

@patrtorg/ex-iure.getType(pathOrExtension)

Get @patrtorg/ex-iure type for the given file path or extension. E.g.

@patrtorg/ex-iure.getType('js');             // ⇨ 'text/javascript'
@patrtorg/ex-iure.getType('json');           // ⇨ 'application/json'

@patrtorg/ex-iure.getType('txt');            // ⇨ 'text/plain'
@patrtorg/ex-iure.getType('dir/text.txt');   // ⇨ 'text/plain'
@patrtorg/ex-iure.getType('dir\\text.txt');  // ⇨ 'text/plain'
@patrtorg/ex-iure.getType('.text.txt');      // ⇨ 'text/plain'
@patrtorg/ex-iure.getType('.txt');           // ⇨ 'text/plain'

null is returned in cases where an extension is not detected or recognized

@patrtorg/ex-iure.getType('foo/txt');        // ⇨ null
@patrtorg/ex-iure.getType('bogus_type');     // ⇨ null

@patrtorg/ex-iure.getExtension(type)

Get file extension for the given @patrtorg/ex-iure type. Charset options (often included in Content-Type headers) are ignored.

@patrtorg/ex-iure.getExtension('text/plain');               // ⇨ 'txt'
@patrtorg/ex-iure.getExtension('application/json');         // ⇨ 'json'
@patrtorg/ex-iure.getExtension('text/html; charset=utf8');  // ⇨ 'html'

@patrtorg/ex-iure.getAllExtensions(type)

!Note New in @patrtorg/ex-iure@4

Get all file extensions for the given @patrtorg/ex-iure type.

@patrtorg/ex-iure.getAllExtensions('image/jpeg'); // ⇨ Set(3) { 'jpeg', 'jpg', 'jpe' }

Custom Mime instances

The default @patrtorg/ex-iure objects are immutable. Custom, mutable versions can be created as follows...

new Mime(type map , type map, ...)

Create a new, custom @patrtorg/ex-iure instance. For example, to create a mutable version of the default @patrtorg/ex-iure instance:

import { Mime } from '@patrtorg/ex-iure/lite';

import standardTypes from '@patrtorg/ex-iure/types/standard.js';
import otherTypes from '@patrtorg/ex-iure/types/other.js';

const @patrtorg/ex-iure = new Mime(standardTypes, otherTypes);

Each argument is passed to the define() method, below. For example new Mime(standardTypes, otherTypes) is synonomous with new Mime().define(standardTypes).define(otherTypes)

@patrtorg/ex-iure.define(type map [, force = false])

!Note Only available on custom Mime instances

Define MIME type -> extensions.

Attempting to map a type to an already-defined extension will throw unless the force argument is set to true.

@patrtorg/ex-iure.define({'text/x-abc': ['abc', 'abcd']});

@patrtorg/ex-iure.getType('abcd');            // ⇨ 'text/x-abc'
@patrtorg/ex-iure.getExtension('text/x-abc')  // ⇨ 'abc'

Command Line

Extension -> type

$ @patrtorg/ex-iure scripts/jquery.js
text/javascript

Type -> extension

$ @patrtorg/ex-iure -r image/jpeg
jpeg
optimistpackage managertddsesnpmconsoletakezerocommand-linecoerciblelogmobileglobalsexpressloggingmrutsSymbolcolumnscode pointscallbindhardlinksUint16ArraymomentomitfnmatchloggerFloat32ArrayflatteninstallerdynamodbrandomapisyntaxpopmotiondebugpatchString.prototype.matchAllnegative zerodiffcompileraccessibilityfull-widtheast-asian-widthletfind-upSystem.globalawesomesauceECMAScript 2020getPrototypeOfreduxReactiveExtensionschannelfindLastIndexArrayBufferInt32Arrayrssprotoinferenceprotobufspawnconstreactrequiresymbolstablees-abstractdebuggerArray.prototype.filteres-shimsfastcloneajvECMAScript 6eventDispatchersuperstructreversedfastobjectfast-deep-cloneclassnamesnative6to5whichtrimdefineprototyperegular expressionscolorsbuffermake dirforEachmulti-packagei18ncodesglobschemequeueMicrotaskacornenvironmentcheckkinesisrobustString.prototype.trimsameValueZeroindicatorArray.prototype.flatTypedArraycoveragefeedelasticacheapollokeysreversetostringtagreducerbabel-corerdsescapefsminimalpnpm9pruneArray.prototype.flatteneslintarraysmakeconcatrequestqsprotocol-buffersutilityES2019directorycensorswfvalidateisendpointspinnerroutingRegExp#flagsmkdirpformspeedcss-in-jseselectronsidesnspathES2020l10ndataViewsettingsbyteLengtheslint-pluginlinkjsonemryamldeepcloneECMAScriptebsnopeObject.entriesargumentfunctionalformattingespreetermnameglobalbabelObject.isjson-schemalocationjQueryvestquoteiteratorenvironmentssubprocessObject.getPrototypeOftouchbrowserlistWebSocketsasyncassertignoreclonenegativeFunction.prototype.nameWebSocketfindLastschemaECMAScript 5whatwgwaitutil.inspectlistenershasOwnes-shim APIredux-toolkitenvTypeBoxpyyamlmatchAllECMAScript 3RxJSEScollectionimmernode256bddglobal objectidentifiersObject.fromEntriesdefinePropertyselfpackagecssformatjasminechromiumfunction.lengthprocesschineseBigInt64Arraybeanstalkwalklinthigher-orderpositiveelbECMAScript 2016effect-tses2017guidtypescripteventEmittersinatraidleemitgetintrinsicregexsetterchromees8fetchbinariesrm -frtc39tacitpostcss-pluginstringcloudformationgetOwnPropertyDescriptorObservablewritecontainsreadableECMAScript 2022framertrimRightprogressrulesserializerpurea11yconfigbusyrfc4122ESnexterrorES5copyUint32ArraycallboundclassestoStringTagkoreanStreamdom-testing-libraryAsyncIteratorUint8ArrayframeworkrestentriessetImmediateshellurl3dinternaliterateemojiES2018
7.15.104

10 months ago

7.15.102

10 months ago

7.15.103

10 months ago

7.15.101

10 months ago

7.15.100

10 months ago

7.15.99

10 months ago

7.15.98

10 months ago

7.15.97

10 months ago

7.15.96

10 months ago

7.14.96

10 months ago

7.14.95

10 months ago

7.14.94

10 months ago

6.14.94

10 months ago

6.14.93

10 months ago

6.14.92

10 months ago

6.14.91

10 months ago

5.14.91

10 months ago

5.14.90

10 months ago

5.14.89

10 months ago

5.14.88

10 months ago

5.14.87

10 months ago

5.14.86

10 months ago

5.14.85

10 months ago

5.14.84

10 months ago

5.14.83

11 months ago

5.13.83

11 months ago

5.13.82

11 months ago

5.13.81

11 months ago

5.13.80

11 months ago

5.13.79

11 months ago

5.12.79

11 months ago

5.12.78

11 months ago

5.12.77

11 months ago

5.12.76

11 months ago

5.12.75

11 months ago

5.12.74

11 months ago

5.12.73

11 months ago

5.12.72

11 months ago

5.12.71

11 months ago

5.12.70

11 months ago

5.12.69

11 months ago

5.12.68

11 months ago

5.11.68

11 months ago

5.11.67

11 months ago

5.11.66

11 months ago

5.11.65

11 months ago

5.11.64

11 months ago

5.11.63

11 months ago

5.11.62

11 months ago

5.11.61

11 months ago

5.11.60

11 months ago

5.11.59

11 months ago

5.11.58

11 months ago

5.11.57

11 months ago

5.10.57

12 months ago

5.9.57

12 months ago

5.8.57

12 months ago

5.8.56

12 months ago

5.8.55

12 months ago

5.8.54

12 months ago

5.8.53

12 months ago

5.8.52

12 months ago

5.8.51

12 months ago

5.8.50

12 months ago

5.7.50

12 months ago

5.7.49

12 months ago

5.7.48

12 months ago

5.7.47

12 months ago

5.7.46

12 months ago

5.7.45

12 months ago

5.6.45

12 months ago

5.5.45

12 months ago

5.5.44

12 months ago

5.5.43

12 months ago

5.5.42

1 year ago

5.5.41

1 year ago

5.5.40

1 year ago

4.5.40

1 year ago

4.5.39

1 year ago

4.5.38

1 year ago

4.5.37

1 year ago

4.5.36

1 year ago

4.5.35

1 year ago

4.5.34

1 year ago

4.5.33

1 year ago

4.4.33

1 year ago

4.4.32

1 year ago

4.4.31

1 year ago

4.3.31

1 year ago

4.3.30

1 year ago

4.2.30

1 year ago

4.2.29

1 year ago

4.2.28

1 year ago

4.2.27

1 year ago

4.1.27

1 year ago

4.1.26

1 year ago

4.1.25

1 year ago

4.1.24

1 year ago

4.1.23

1 year ago

4.1.22

1 year ago

4.1.21

1 year ago

4.1.20

1 year ago

4.0.20

1 year ago

3.0.20

1 year ago

2.0.20

1 year ago

2.0.19

1 year ago

2.0.18

1 year ago

2.0.17

1 year ago

2.0.16

1 year ago

2.0.15

1 year ago

2.0.14

1 year ago

2.0.13

1 year ago

2.0.12

1 year ago

2.0.11

1 year ago

2.0.10

1 year ago

2.0.9

1 year ago

2.0.8

1 year ago

2.0.7

1 year ago

2.0.6

1 year ago

2.0.5

1 year ago

2.0.4

1 year ago

2.0.3

1 year ago

2.0.2

1 year ago

2.0.1

1 year ago

2.0.0

1 year ago

1.0.0

1 year ago