@bgord/tools 1.1.11 → 1.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mime.vo.d.ts +2 -1
- package/dist/mime.vo.js +11 -7
- package/package.json +1 -1
- package/src/mime.vo.ts +13 -10
package/dist/mime.vo.d.ts
CHANGED
|
@@ -5,7 +5,8 @@ export declare const MimeError: {
|
|
|
5
5
|
export declare class Mime {
|
|
6
6
|
readonly type: string;
|
|
7
7
|
readonly subtype: string;
|
|
8
|
-
constructor(
|
|
8
|
+
private constructor();
|
|
9
|
+
static fromString(candidate: string): Mime;
|
|
9
10
|
static fromExtension(extension: ExtensionType): Mime;
|
|
10
11
|
isSatisfiedBy(another: Mime): boolean;
|
|
11
12
|
toExtension(): ExtensionType;
|
package/dist/mime.vo.js
CHANGED
|
@@ -5,13 +5,17 @@ export const MimeError = { NotAccepted: "mime.not.accepted" };
|
|
|
5
5
|
export class Mime {
|
|
6
6
|
type;
|
|
7
7
|
subtype;
|
|
8
|
-
constructor(
|
|
9
|
-
const { type, subtype } = MimeValue.parse(candidate);
|
|
8
|
+
constructor(type, subtype) {
|
|
10
9
|
this.type = type;
|
|
11
10
|
this.subtype = subtype;
|
|
12
11
|
}
|
|
12
|
+
static fromString(candidate) {
|
|
13
|
+
const { type, subtype } = MimeValue.parse(candidate);
|
|
14
|
+
return new Mime(type, subtype);
|
|
15
|
+
}
|
|
13
16
|
static fromExtension(extension) {
|
|
14
|
-
|
|
17
|
+
const { type, subtype } = MimeValue.parse(String(mime.contentType(extension)));
|
|
18
|
+
return new Mime(type, subtype);
|
|
15
19
|
}
|
|
16
20
|
isSatisfiedBy(another) {
|
|
17
21
|
if (!(this.type === another.type || this.type === "*"))
|
|
@@ -29,8 +33,8 @@ export class Mime {
|
|
|
29
33
|
}
|
|
30
34
|
}
|
|
31
35
|
export const MIMES = {
|
|
32
|
-
csv:
|
|
33
|
-
text:
|
|
34
|
-
markdown:
|
|
35
|
-
pdf:
|
|
36
|
+
csv: Mime.fromString("text/csv"),
|
|
37
|
+
text: Mime.fromString("text/plain"),
|
|
38
|
+
markdown: Mime.fromString("text/markdown"),
|
|
39
|
+
pdf: Mime.fromString("application/pdf"),
|
|
36
40
|
};
|
package/package.json
CHANGED
package/src/mime.vo.ts
CHANGED
|
@@ -5,18 +5,21 @@ import { MimeValue } from "./mime-value.vo";
|
|
|
5
5
|
export const MimeError = { NotAccepted: "mime.not.accepted" } as const;
|
|
6
6
|
|
|
7
7
|
export class Mime {
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
private constructor(
|
|
9
|
+
readonly type: string,
|
|
10
|
+
readonly subtype: string,
|
|
11
|
+
) {}
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
static fromString(candidate: string): Mime {
|
|
12
14
|
const { type, subtype } = MimeValue.parse(candidate);
|
|
13
15
|
|
|
14
|
-
|
|
15
|
-
this.subtype = subtype;
|
|
16
|
+
return new Mime(type, subtype);
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
static fromExtension(extension: ExtensionType): Mime {
|
|
19
|
-
|
|
20
|
+
const { type, subtype } = MimeValue.parse(String(mime.contentType(extension)));
|
|
21
|
+
|
|
22
|
+
return new Mime(type, subtype);
|
|
20
23
|
}
|
|
21
24
|
|
|
22
25
|
isSatisfiedBy(another: Mime): boolean {
|
|
@@ -38,8 +41,8 @@ export class Mime {
|
|
|
38
41
|
}
|
|
39
42
|
|
|
40
43
|
export const MIMES = {
|
|
41
|
-
csv:
|
|
42
|
-
text:
|
|
43
|
-
markdown:
|
|
44
|
-
pdf:
|
|
44
|
+
csv: Mime.fromString("text/csv"),
|
|
45
|
+
text: Mime.fromString("text/plain"),
|
|
46
|
+
markdown: Mime.fromString("text/markdown"),
|
|
47
|
+
pdf: Mime.fromString("application/pdf"),
|
|
45
48
|
};
|