main
Last change
on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
1.5 KB
|
Line | |
---|
1 | "use strict";
|
---|
2 |
|
---|
3 | var _interopRequireWildcard = require("@babel/runtime-corejs3/helpers/interopRequireWildcard").default;
|
---|
4 | var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
|
---|
5 | exports.__esModule = true;
|
---|
6 | exports.default = void 0;
|
---|
7 | var _stampit = _interopRequireDefault(require("stampit"));
|
---|
8 | var _ramda = require("ramda");
|
---|
9 | var _ramdaAdjunct = require("ramda-adjunct");
|
---|
10 | var url = _interopRequireWildcard(require("./url.cjs"));
|
---|
11 | /**
|
---|
12 | * This stamp represents a File object with url and data.
|
---|
13 | */
|
---|
14 |
|
---|
15 | const File = (0, _stampit.default)({
|
---|
16 | props: {
|
---|
17 | uri: null,
|
---|
18 | mediaType: 'text/plain',
|
---|
19 | data: null,
|
---|
20 | parseResult: null
|
---|
21 | },
|
---|
22 | init({
|
---|
23 | uri = this.uri,
|
---|
24 | mediaType = this.mediaType,
|
---|
25 | data = this.data,
|
---|
26 | parseResult = this.parseResult
|
---|
27 | } = {}) {
|
---|
28 | this.uri = uri;
|
---|
29 | this.mediaType = mediaType;
|
---|
30 | this.data = data;
|
---|
31 | this.parseResult = parseResult;
|
---|
32 | },
|
---|
33 | methods: {
|
---|
34 | get extension() {
|
---|
35 | if ((0, _ramdaAdjunct.isString)(this.uri)) {
|
---|
36 | return url.getExtension(this.uri);
|
---|
37 | }
|
---|
38 | return '';
|
---|
39 | },
|
---|
40 | toString() {
|
---|
41 | if (typeof this.data === 'string') {
|
---|
42 | return this.data;
|
---|
43 | }
|
---|
44 | if (this.data instanceof ArrayBuffer || ['ArrayBuffer'].includes((0, _ramda.type)(this.data)) || ArrayBuffer.isView(this.data)) {
|
---|
45 | const textDecoder = new TextDecoder('utf-8');
|
---|
46 | return textDecoder.decode(this.data);
|
---|
47 | }
|
---|
48 | return String(this.data);
|
---|
49 | }
|
---|
50 | }
|
---|
51 | });
|
---|
52 | var _default = exports.default = File; |
---|
Note:
See
TracBrowser
for help on using the repository browser.