다음을 통해 공유


MIMEType class

MIMEType 클래스의 구현입니다.

브라우저 규칙에 따라 개체의 모든 속성은 개체 자체의 MIMEType 데이터 속성이 아닌 클래스 프로토타입에서 getter 및 setter로 구현됩니다.

MIME 문자열은 여러 의미 있는 구성 요소를 포함하는 구조화된 문자열입니다. 구문 분석할 MIMEType 때 이러한 각 구성 요소에 대한 속성을 포함하는 개체가 반환됩니다.

생성자

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

입력을 구문 분석하여 새 MIMEType 개체를 만듭니다.

TypeError 가 유효한 MIME가 아니면 이 throw input 됩니다. 지정된 값을 문자열로 강제 변환하기 위해 노력합니다.

속성

essence

MIME의 본질을 가져옵니다. 이 속성은 읽기 전용입니다. 또는 mime.subtype 를 사용하여 mime.type 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()

개체의 MIMEType 메서드는 toString() 직렬화된 MIME를 반환합니다.

표준 규정 준수가 필요하기 때문에 이 메서드는 사용자가 MIME의 serialization 프로세스를 사용자 지정할 수 없습니다.

생성자 세부 정보

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

입력을 구문 분석하여 새 MIMEType 개체를 만듭니다.

TypeError 가 유효한 MIME가 아니면 이 throw input 됩니다. 지정된 값을 문자열로 강제 변환하기 위해 노력합니다.

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

매개 변수

input

string | { toString: () => string }

구문 분석할 입력 MIME입니다.

속성 세부 정보

essence

MIME의 본질을 가져옵니다. 이 속성은 읽기 전용입니다. 또는 mime.subtype 를 사용하여 mime.type 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()

개체의 MIMEType 메서드는 toString() 직렬화된 MIME를 반환합니다.

표준 규정 준수가 필요하기 때문에 이 메서드는 사용자가 MIME의 serialization 프로세스를 사용자 지정할 수 없습니다.

function toString(): string

반환

string