Aracılığıyla paylaş


MIMEType class

MIMEType sınıfıuygulaması.

Tarayıcı kurallarına uygun olarak, MIMEType nesnelerin tüm özellikleri nesnenin kendisinde veri özellikleri olarak değil, sınıf prototipinde alıcı ve ayarlayıcı olarak uygulanır.

MIME dizesi, birden çok anlamlı bileşen içeren yapılandırılmış bir dizedir. Ayrıştırıldığında, bu bileşenlerin her biri için özellikler içeren bir MIMEType nesnesi döndürülür.

Oluşturucular

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

Girişi ayrıştırarak yeni bir MIMEType nesnesi oluşturur.

TypeError geçerli bir MIME değilse bir input oluşturulur. Verilen değerleri dizeler halinde zorlamak için çaba gösterileceğini unutmayın.

Özellikler

essence

MIME'nin özünü alır. Bu özellik salt okunur. MIME'yi değiştirmek için mime.type veya mime.subtype kullanın.

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 parametrelerini temsil eden MIMEParams nesnesini alır. Bu özellik salt okunurdur. Ayrıntılar için MIMEParams belgelerine bakın.

subtype

MIME'nin alt tür bölümünü alır ve ayarlar.

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'nin tür bölümünü alır ve ayarlar.

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

Yöntemler

toString()

toString() nesnesinde MIMEType yöntemi, serileştirilmiş MIME'yi döndürür.

Standart uyumluluk gereksinimi nedeniyle, bu yöntem kullanıcıların MIME'nin serileştirme işlemini özelleştirmesine izin vermez.

Oluşturucu Ayrıntıları

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

Girişi ayrıştırarak yeni bir MIMEType nesnesi oluşturur.

TypeError geçerli bir MIME değilse bir input oluşturulur. Verilen değerleri dizeler halinde zorlamak için çaba gösterileceğini unutmayın.

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

Parametreler

input

string | { toString: () => string }

Ayrıştırmak için giriş MIME'si.

Özellik Ayrıntıları

essence

MIME'nin özünü alır. Bu özellik salt okunur. MIME'yi değiştirmek için mime.type veya mime.subtype kullanın.

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

Özellik Değeri

string

params

MIME parametrelerini temsil eden MIMEParams nesnesini alır. Bu özellik salt okunurdur. Ayrıntılar için MIMEParams belgelerine bakın.

params: MIMEParams

Özellik Değeri

subtype

MIME'nin alt tür bölümünü alır ve ayarlar.

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

Özellik Değeri

string

type

MIME'nin tür bölümünü alır ve ayarlar.

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

Özellik Değeri

string

Yöntem Ayrıntıları

toString()

toString() nesnesinde MIMEType yöntemi, serileştirilmiş MIME'yi döndürür.

Standart uyumluluk gereksinimi nedeniyle, bu yöntem kullanıcıların MIME'nin serileştirme işlemini özelleştirmesine izin vermez.

function toString(): string

Döndürülenler

string