3.1.21 • Published 1 year ago

@juigorg/consectetur-hic-perspiciatis v3.1.21

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Mime

NPM downloads Mime CI

An API for MIME type information.

  • All @juigorg/consectetur-hic-perspiciatis-db types
  • Compact and dependency-free @juigorg/consectetur-hic-perspiciatis's badge
  • Full TS support

!Note @juigorg/consectetur-hic-perspiciatis@4 is now latest. If you're upgrading from @juigorg/consectetur-hic-perspiciatis@3, note the following:

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

Installation

npm install @juigorg/consectetur-hic-perspiciatis

Quick Start

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

import @juigorg/consectetur-hic-perspiciatis from '@juigorg/consectetur-hic-perspiciatis';

@juigorg/consectetur-hic-perspiciatis.getType('txt');                    // ⇨ 'text/plain'
@juigorg/consectetur-hic-perspiciatis.getExtension('text/plain');        // ⇨ 'txt'

Lite Version @juigorg/consectetur-hic-perspiciatis/lite's badge

@juigorg/consectetur-hic-perspiciatis/lite is a drop-in @juigorg/consectetur-hic-perspiciatis replacement, stripped of unofficial ("prs.*", "x-*", "vnd.*") types:

import @juigorg/consectetur-hic-perspiciatis from '@juigorg/consectetur-hic-perspiciatis/lite';

API

@juigorg/consectetur-hic-perspiciatis.getType(pathOrExtension)

Get @juigorg/consectetur-hic-perspiciatis type for the given file path or extension. E.g.

@juigorg/consectetur-hic-perspiciatis.getType('js');             // ⇨ 'text/javascript'
@juigorg/consectetur-hic-perspiciatis.getType('json');           // ⇨ 'application/json'

@juigorg/consectetur-hic-perspiciatis.getType('txt');            // ⇨ 'text/plain'
@juigorg/consectetur-hic-perspiciatis.getType('dir/text.txt');   // ⇨ 'text/plain'
@juigorg/consectetur-hic-perspiciatis.getType('dir\\text.txt');  // ⇨ 'text/plain'
@juigorg/consectetur-hic-perspiciatis.getType('.text.txt');      // ⇨ 'text/plain'
@juigorg/consectetur-hic-perspiciatis.getType('.txt');           // ⇨ 'text/plain'

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

@juigorg/consectetur-hic-perspiciatis.getType('foo/txt');        // ⇨ null
@juigorg/consectetur-hic-perspiciatis.getType('bogus_type');     // ⇨ null

@juigorg/consectetur-hic-perspiciatis.getExtension(type)

Get file extension for the given @juigorg/consectetur-hic-perspiciatis type. Charset options (often included in Content-Type headers) are ignored.

@juigorg/consectetur-hic-perspiciatis.getExtension('text/plain');               // ⇨ 'txt'
@juigorg/consectetur-hic-perspiciatis.getExtension('application/json');         // ⇨ 'json'
@juigorg/consectetur-hic-perspiciatis.getExtension('text/html; charset=utf8');  // ⇨ 'html'

@juigorg/consectetur-hic-perspiciatis.getAllExtensions(type)

!Note New in @juigorg/consectetur-hic-perspiciatis@4

Get all file extensions for the given @juigorg/consectetur-hic-perspiciatis type.

@juigorg/consectetur-hic-perspiciatis.getAllExtensions('image/jpeg'); // ⇨ Set(3) { 'jpeg', 'jpg', 'jpe' }

Custom Mime instances

The default @juigorg/consectetur-hic-perspiciatis objects are immutable. Custom, mutable versions can be created as follows...

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

Create a new, custom @juigorg/consectetur-hic-perspiciatis instance. For example, to create a mutable version of the default @juigorg/consectetur-hic-perspiciatis instance:

import { Mime } from '@juigorg/consectetur-hic-perspiciatis/lite';

import standardTypes from '@juigorg/consectetur-hic-perspiciatis/types/standard.js';
import otherTypes from '@juigorg/consectetur-hic-perspiciatis/types/other.js';

const @juigorg/consectetur-hic-perspiciatis = 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)

@juigorg/consectetur-hic-perspiciatis.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.

@juigorg/consectetur-hic-perspiciatis.define({'text/x-abc': ['abc', 'abcd']});

@juigorg/consectetur-hic-perspiciatis.getType('abcd');            // ⇨ 'text/x-abc'
@juigorg/consectetur-hic-perspiciatis.getExtension('text/x-abc')  // ⇨ 'abc'

Command Line

Extension -> type

$ @juigorg/consectetur-hic-perspiciatis scripts/jquery.js
text/javascript

Type -> extension

$ @juigorg/consectetur-hic-perspiciatis -r image/jpeg
jpeg
envexpressionnpmimportkarmajapanesewafES2019callbackhigher-ordertoArraygradients cssshimrequireJSON-Schemasqscopywritereadmomentstylesheetworkflowopenthrottlewebhttpses7ES2015cloudtrailrgbwgetclassnamesassigntappathtrimRightmkdirdataViewscheme-validationweaksethashawesomesauceregexp__proto__batchObservablesrobustestreestylingSymbol.toStringTagredactclass-validatorcurlquotesnsPromiseajvIteratores2016[[Prototype]]stablearraybufferrm -rfsequencees2018ES7callbindroute53$.extendHyBichromerequesthelperses5typanionObject.definePropertycomputed-typeslistenersstreamregularWeakSetbrowserlistasciivestformsindicatorresolveelmlazypluginStyleSheetpasswordmobilelimitedArray.prototype.findLastduplexserializecommanderhotES2020ECMAScript 5schemainternal slotpackageframework.envwatchingebsqueueMicrotaskRxJSTypeBoxenderintrinsicprettysuperagentrecursiveCSSStyleDeclarationfast-clonebddpackage.jsonqses2015typeshookscheckstoragegatewayexpressutilities-0cliruntimeECMAScript 3css lesscoerciblecommandchannelObject.iswalkinguninstallcollectionglacierdatawatchArrayBuffer#slicewidthfsdom-testing-librarypushInt8Arrayprotobufbootstrap cssstructuredClonepromiseobjectcorehasOwnformdotenvcompareECMAScript 2015ieimmutableFunction.prototype.nameCSSpostcss-pluginentriescharactersstringES2017endpointliveInt16ArraymapObject.valuesECMAScript 2017SymboltimecolumnlesstermpropertysymlinksweakmapmimetypesgroupesfullconcatMapio-tsfindupwritableBigUint64Arraystringifieriami18nworkermoduleshas-owntoSortedJSONutilformattingmergebeanstalkfigletfastcloneargsqueryUint16ArraypreprocessorstringifychaigetterequalityextendansieslintpluginrandomapieventDispatchercloudformationdatastructureextratraverseidspeedlinewrapRegExp#flagsflagflatfilereact-hook-formelectronInt32ArraycharacterprototypestdlibbcryptobjtouchconcurrencySetsettingsStreamObject.fromEntrieslimitfunctionssortaccessorECMAScript 2021jsonpathforEacheslintconfigdataviewmonorepormdironceuppatchcommand-linecall-boundpreserve-symlinkscollection.es6jsonvalidfull-widthtapestatelessdeep-clonepredictablestreams2lockfilecircularfastifyECMAScript 2023getoptbreakvariables in cssponyfillspinnershasOwnPropertykeysagent_.extendparsingUint32Arrayfast-copycallboundeslint-plugingdpr256validateequaldescriptorprefixiterationconsoleECMAScript 2020persistentartredirectemrzeroTypeScriptinstallwatchFilegenericsminimaltsspecjasminevpccreateECMAScript 6filterfindLastIndexESlintlanguageTypedArrayprivate dataclientbundlertestAsyncIterator0callconnectsafehasserializationbrowserslistxhrwalkes2017classnameparseRxObject.getPrototypeOfratelimitunicodehookformslotgetintrinsicinvariantreadablestreamerrorflatMapenvironmentnumberPushrmreducerloggerwaitArrayinjoisyntaxdebuggerStreamslocationpositiveyupmocha@@toStringTagoptimizerES3descriptorsajaxwordwraptypedform-validationinternalregular expressioncss nestingnativeUnderscorekinesisgroupByeventEmitterreact-hooksmime-dbformatWebSocketsmruescapepackage managersymlinkkeycorsdirectoryredux-toolkitsetArrayBuffer.prototype.sliceless.jsthroatFloat64Arrayloadbalancingperformantfixed-widthdependency managerlogjQuerymoduleFloat32ArrayassertsdependenciestypedarraysBigInt64ArraymapreducemimesymbolstelephoneArrayBuffermake
2.1.18

1 year ago

2.1.19

1 year ago

2.1.21

1 year ago

2.1.20

1 year ago

3.1.21

1 year ago

2.1.16

1 year ago

2.1.17

1 year ago

2.1.15

1 year ago

2.1.14

1 year ago

2.1.12

1 year ago

2.1.13

1 year ago

2.1.11

1 year ago

2.1.10

1 year ago

2.1.9

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

1.0.2

1 year ago

1.0.3

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago