次の方法で共有


MIMEType class

MIMEType クラスの実装。

ブラウザー規則に従って、MIMEType オブジェクトのすべてのプロパティは、オブジェクト自体のデータ プロパティとしてではなく、クラス プロトタイプのゲッターとセッターとして実装されます。

MIME 文字列は、複数の意味のあるコンポーネントを含む構造化文字列です。 解析すると、これらの各コンポーネントのプロパティを含む MIMEType オブジェクトが返されます。

コンストラクター

MIMEType(string | { toString: () => string })

入力を解析して、新しい MIMEType オブジェクトを作成します。

TypeError が有効な MIME でない場合、input がスローされます。 指定された値を文字列に強制的に変換する作業が行われます。

プロパティ

essence

MIME の本質を取得します。 このプロパティは読み取り専用です。 mime.type または mime.subtype を使用して MIME を変更します。

import { MIMEType } from 'node:util';

const myMIME = new MIMEType('text/javascript;key=value');
console.log(myMIME.essence);
// Prints: text/javascript
myMIME.type = 'application';
console.log(myMIME.essence);
// Prints: application/javascript
console.log(String(myMIME));
// Prints: application/javascript;key=value
params

MIME のパラメーターを表す MIMEParams オブジェクトを取得します。 このプロパティは読み取り専用です。 詳細については、MIMEParams ドキュメントを参照してください。

subtype

MIME のサブタイプ部分を取得および設定します。

import { MIMEType } from 'node:util';

const myMIME = new MIMEType('text/ecmascript');
console.log(myMIME.subtype);
// Prints: ecmascript
myMIME.subtype = 'javascript';
console.log(myMIME.subtype);
// Prints: javascript
console.log(String(myMIME));
// Prints: text/javascript
type

MIME の種類部分を取得および設定します。

import { MIMEType } from 'node:util';

const myMIME = new MIMEType('text/javascript');
console.log(myMIME.type);
// Prints: text
myMIME.type = 'application';
console.log(myMIME.type);
// Prints: application
console.log(String(myMIME));
// Prints: application/javascript

メソッド

toString()

toString() オブジェクトの MIMEType メソッドは、シリアル化された MIME を返します。

標準コンプライアンスが必要なため、この方法では、ユーザーが MIME のシリアル化プロセスをカスタマイズすることはできません。

コンストラクターの詳細

MIMEType(string | { toString: () => string })

入力を解析して、新しい MIMEType オブジェクトを作成します。

TypeError が有効な MIME でない場合、input がスローされます。 指定された値を文字列に強制的に変換する作業が行われます。

new MIMEType(input: string | { toString: () => string })

パラメーター

input

string | { toString: () => string }

解析する入力 MIME。

プロパティの詳細

essence

MIME の本質を取得します。 このプロパティは読み取り専用です。 mime.type または mime.subtype を使用して MIME を変更します。

import { MIMEType } from 'node:util';

const myMIME = new MIMEType('text/javascript;key=value');
console.log(myMIME.essence);
// Prints: text/javascript
myMIME.type = 'application';
console.log(myMIME.essence);
// Prints: application/javascript
console.log(String(myMIME));
// Prints: application/javascript;key=value
essence: string

プロパティ値

string

params

MIME のパラメーターを表す MIMEParams オブジェクトを取得します。 このプロパティは読み取り専用です。 詳細については、MIMEParams ドキュメントを参照してください。

params: MIMEParams

プロパティ値

subtype

MIME のサブタイプ部分を取得および設定します。

import { MIMEType } from 'node:util';

const myMIME = new MIMEType('text/ecmascript');
console.log(myMIME.subtype);
// Prints: ecmascript
myMIME.subtype = 'javascript';
console.log(myMIME.subtype);
// Prints: javascript
console.log(String(myMIME));
// Prints: text/javascript
subtype: string

プロパティ値

string

type

MIME の種類部分を取得および設定します。

import { MIMEType } from 'node:util';

const myMIME = new MIMEType('text/javascript');
console.log(myMIME.type);
// Prints: text
myMIME.type = 'application';
console.log(myMIME.type);
// Prints: application
console.log(String(myMIME));
// Prints: application/javascript
type: string

プロパティ値

string

メソッドの詳細

toString()

toString() オブジェクトの MIMEType メソッドは、シリアル化された MIME を返します。

標準コンプライアンスが必要なため、この方法では、ユーザーが MIME のシリアル化プロセスをカスタマイズすることはできません。

function toString(): string

戻り値

string