@common.js/fetch-blob 3.2.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019 David Frank
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,5 @@
1
+ # @common.js/fetch-blob
2
+
3
+ The [fetch-blob](https://www.npmjs.com/package/fetch-blob) package exported as CommonJS modules.
4
+
5
+ Exported from [fetch-blob@3.2.0](https://www.npmjs.com/package/fetch-blob/v/3.2.0) using https://github.com/etienne-martin/common.js.
package/file.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ /** @type {typeof globalThis.File} */ export const File: typeof globalThis.File;
2
+ export default File;
package/file.js ADDED
@@ -0,0 +1,275 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ File: function() {
13
+ return File;
14
+ },
15
+ default: function() {
16
+ return _default;
17
+ }
18
+ });
19
+ var _indexJs = /*#__PURE__*/ _interopRequireDefault(require("./index.js"));
20
+ function _assertThisInitialized(self) {
21
+ if (self === void 0) {
22
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
23
+ }
24
+ return self;
25
+ }
26
+ function _checkPrivateRedeclaration(obj, privateCollection) {
27
+ if (privateCollection.has(obj)) {
28
+ throw new TypeError("Cannot initialize the same private elements twice on an object");
29
+ }
30
+ }
31
+ function _classApplyDescriptorGet(receiver, descriptor) {
32
+ if (descriptor.get) {
33
+ return descriptor.get.call(receiver);
34
+ }
35
+ return descriptor.value;
36
+ }
37
+ function _classApplyDescriptorSet(receiver, descriptor, value) {
38
+ if (descriptor.set) {
39
+ descriptor.set.call(receiver, value);
40
+ } else {
41
+ if (!descriptor.writable) {
42
+ throw new TypeError("attempted to set read only private field");
43
+ }
44
+ descriptor.value = value;
45
+ }
46
+ }
47
+ function _classCallCheck(instance, Constructor) {
48
+ if (!(instance instanceof Constructor)) {
49
+ throw new TypeError("Cannot call a class as a function");
50
+ }
51
+ }
52
+ function _classExtractFieldDescriptor(receiver, privateMap, action) {
53
+ if (!privateMap.has(receiver)) {
54
+ throw new TypeError("attempted to " + action + " private field on non-instance");
55
+ }
56
+ return privateMap.get(receiver);
57
+ }
58
+ function _classPrivateFieldGet(receiver, privateMap) {
59
+ var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get");
60
+ return _classApplyDescriptorGet(receiver, descriptor);
61
+ }
62
+ function _classPrivateFieldInit(obj, privateMap, value) {
63
+ _checkPrivateRedeclaration(obj, privateMap);
64
+ privateMap.set(obj, value);
65
+ }
66
+ function _classPrivateFieldSet(receiver, privateMap, value) {
67
+ var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set");
68
+ _classApplyDescriptorSet(receiver, descriptor, value);
69
+ return value;
70
+ }
71
+ function isNativeReflectConstruct() {
72
+ if (typeof Reflect === "undefined" || !Reflect.construct) return false;
73
+ if (Reflect.construct.sham) return false;
74
+ if (typeof Proxy === "function") return true;
75
+ try {
76
+ Date.prototype.toString.call(Reflect.construct(Date, [], function() {}));
77
+ return true;
78
+ } catch (e) {
79
+ return false;
80
+ }
81
+ }
82
+ function _construct(Parent, args, Class) {
83
+ if (isNativeReflectConstruct()) {
84
+ _construct = Reflect.construct;
85
+ } else {
86
+ _construct = function _construct(Parent, args, Class) {
87
+ var a = [
88
+ null
89
+ ];
90
+ a.push.apply(a, args);
91
+ var Constructor = Function.bind.apply(Parent, a);
92
+ var instance = new Constructor();
93
+ if (Class) _setPrototypeOf(instance, Class.prototype);
94
+ return instance;
95
+ };
96
+ }
97
+ return _construct.apply(null, arguments);
98
+ }
99
+ function _defineProperties(target, props) {
100
+ for(var i = 0; i < props.length; i++){
101
+ var descriptor = props[i];
102
+ descriptor.enumerable = descriptor.enumerable || false;
103
+ descriptor.configurable = true;
104
+ if ("value" in descriptor) descriptor.writable = true;
105
+ Object.defineProperty(target, descriptor.key, descriptor);
106
+ }
107
+ }
108
+ function _createClass(Constructor, protoProps, staticProps) {
109
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
110
+ if (staticProps) _defineProperties(Constructor, staticProps);
111
+ return Constructor;
112
+ }
113
+ function _getPrototypeOf(o) {
114
+ _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
115
+ return o.__proto__ || Object.getPrototypeOf(o);
116
+ };
117
+ return _getPrototypeOf(o);
118
+ }
119
+ function _inherits(subClass, superClass) {
120
+ if (typeof superClass !== "function" && superClass !== null) {
121
+ throw new TypeError("Super expression must either be null or a function");
122
+ }
123
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
124
+ constructor: {
125
+ value: subClass,
126
+ writable: true,
127
+ configurable: true
128
+ }
129
+ });
130
+ if (superClass) _setPrototypeOf(subClass, superClass);
131
+ }
132
+ function _instanceof(left, right) {
133
+ if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
134
+ return !!right[Symbol.hasInstance](left);
135
+ } else {
136
+ return left instanceof right;
137
+ }
138
+ }
139
+ function _interopRequireDefault(obj) {
140
+ return obj && obj.__esModule ? obj : {
141
+ default: obj
142
+ };
143
+ }
144
+ function _isNativeFunction(fn) {
145
+ return Function.toString.call(fn).indexOf("[native code]") !== -1;
146
+ }
147
+ function _possibleConstructorReturn(self, call) {
148
+ if (call && (_typeof(call) === "object" || typeof call === "function")) {
149
+ return call;
150
+ }
151
+ return _assertThisInitialized(self);
152
+ }
153
+ function _setPrototypeOf(o, p) {
154
+ _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
155
+ o.__proto__ = p;
156
+ return o;
157
+ };
158
+ return _setPrototypeOf(o, p);
159
+ }
160
+ var _typeof = function(obj) {
161
+ "@swc/helpers - typeof";
162
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
163
+ };
164
+ function _wrapNativeSuper(Class) {
165
+ var _cache = typeof Map === "function" ? new Map() : undefined;
166
+ _wrapNativeSuper = function _wrapNativeSuper(Class) {
167
+ if (Class === null || !_isNativeFunction(Class)) return Class;
168
+ if (typeof Class !== "function") {
169
+ throw new TypeError("Super expression must either be null or a function");
170
+ }
171
+ if (typeof _cache !== "undefined") {
172
+ if (_cache.has(Class)) return _cache.get(Class);
173
+ _cache.set(Class, Wrapper);
174
+ }
175
+ function Wrapper() {
176
+ return _construct(Class, arguments, _getPrototypeOf(this).constructor);
177
+ }
178
+ Wrapper.prototype = Object.create(Class.prototype, {
179
+ constructor: {
180
+ value: Wrapper,
181
+ enumerable: false,
182
+ writable: true,
183
+ configurable: true
184
+ }
185
+ });
186
+ return _setPrototypeOf(Wrapper, Class);
187
+ };
188
+ return _wrapNativeSuper(Class);
189
+ }
190
+ function _isNativeReflectConstruct() {
191
+ if (typeof Reflect === "undefined" || !Reflect.construct) return false;
192
+ if (Reflect.construct.sham) return false;
193
+ if (typeof Proxy === "function") return true;
194
+ try {
195
+ Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
196
+ return true;
197
+ } catch (e) {
198
+ return false;
199
+ }
200
+ }
201
+ function _createSuper(Derived) {
202
+ var hasNativeReflectConstruct = _isNativeReflectConstruct();
203
+ return function _createSuperInternal() {
204
+ var Super = _getPrototypeOf(Derived), result;
205
+ if (hasNativeReflectConstruct) {
206
+ var NewTarget = _getPrototypeOf(this).constructor;
207
+ result = Reflect.construct(Super, arguments, NewTarget);
208
+ } else {
209
+ result = Super.apply(this, arguments);
210
+ }
211
+ return _possibleConstructorReturn(this, result);
212
+ };
213
+ }
214
+ var _toStringTag, _hasInstance;
215
+ var _lastModified, _name;
216
+ var _File = (_lastModified = /*#__PURE__*/ new WeakMap(), _name = /*#__PURE__*/ new WeakMap(), _toStringTag = Symbol.toStringTag, _hasInstance = Symbol.hasInstance, /*#__PURE__*/ function(Blob) {
217
+ "use strict";
218
+ _inherits(File, Blob);
219
+ var _super = _createSuper(File);
220
+ function File(fileBits, fileName) {
221
+ var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
222
+ _classCallCheck(this, File);
223
+ var _this;
224
+ if (arguments.length < 2) {
225
+ throw new TypeError("Failed to construct 'File': 2 arguments required, but only ".concat(arguments.length, " present."));
226
+ }
227
+ _this = _super.call(this, fileBits, options);
228
+ _classPrivateFieldInit(_assertThisInitialized(_this), _lastModified, {
229
+ writable: true,
230
+ value: 0
231
+ });
232
+ _classPrivateFieldInit(_assertThisInitialized(_this), _name, {
233
+ writable: true,
234
+ value: ""
235
+ });
236
+ if (options === null) options = {};
237
+ // Simulate WebIDL type casting for NaN value in lastModified option.
238
+ var lastModified = options.lastModified === undefined ? Date.now() : Number(options.lastModified);
239
+ if (!Number.isNaN(lastModified)) {
240
+ _classPrivateFieldSet(_assertThisInitialized(_this), _lastModified, lastModified);
241
+ }
242
+ _classPrivateFieldSet(_assertThisInitialized(_this), _name, String(fileName));
243
+ return _this;
244
+ }
245
+ _createClass(File, [
246
+ {
247
+ key: "name",
248
+ get: function get() {
249
+ return _classPrivateFieldGet(this, _name);
250
+ }
251
+ },
252
+ {
253
+ key: "lastModified",
254
+ get: function get() {
255
+ return _classPrivateFieldGet(this, _lastModified);
256
+ }
257
+ },
258
+ {
259
+ key: _toStringTag,
260
+ get: function get() {
261
+ return "File";
262
+ }
263
+ }
264
+ ], [
265
+ {
266
+ key: _hasInstance,
267
+ value: function value(object) {
268
+ return !!object && _instanceof(object, _indexJs.default) && /^(File)$/.test(object[Symbol.toStringTag]);
269
+ }
270
+ }
271
+ ]);
272
+ return File;
273
+ }(_wrapNativeSuper(_indexJs.default)));
274
+ var File = _File;
275
+ var _default = File;
package/from.d.ts ADDED
@@ -0,0 +1,26 @@
1
+ export default blobFromSync;
2
+ /**
3
+ * @param {string} path filepath on the disk
4
+ * @param {string} [type] mimetype to use
5
+ */
6
+ export function blobFromSync(path: string, type?: string): Blob;
7
+ import File from "./file.js";
8
+ import Blob from "./index.js";
9
+ /**
10
+ * @param {string} path filepath on the disk
11
+ * @param {string} [type] mimetype to use
12
+ * @returns {Promise<Blob>}
13
+ */
14
+ export function blobFrom(path: string, type?: string): Promise<Blob>;
15
+ /**
16
+ * @param {string} path filepath on the disk
17
+ * @param {string} [type] mimetype to use
18
+ * @returns {Promise<File>}
19
+ */
20
+ export function fileFrom(path: string, type?: string): Promise<File>;
21
+ /**
22
+ * @param {string} path filepath on the disk
23
+ * @param {string} [type] mimetype to use
24
+ */
25
+ export function fileFromSync(path: string, type?: string): File;
26
+ export { File, Blob };