@remix-run/node 1.4.2 → 1.5.0-pre.1

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/upload/meter.js DELETED
@@ -1,47 +0,0 @@
1
- /**
2
- * @remix-run/node v1.4.2
3
- *
4
- * Copyright (c) Remix Software Inc.
5
- *
6
- * This source code is licensed under the MIT license found in the
7
- * LICENSE.md file in the root directory of this source tree.
8
- *
9
- * @license MIT
10
- */
11
- 'use strict';
12
-
13
- Object.defineProperty(exports, '__esModule', { value: true });
14
-
15
- var stream = require('stream');
16
-
17
- class Meter extends stream.Transform {
18
- constructor(field, maxBytes) {
19
- super();
20
- this.field = field;
21
- this.maxBytes = maxBytes;
22
- this.bytes = 0;
23
- }
24
-
25
- _transform(chunk, _, callback) {
26
- this.bytes += chunk.length;
27
- this.push(chunk);
28
-
29
- if (typeof this.maxBytes === "number" && this.bytes > this.maxBytes) {
30
- return callback(new MeterError(this.field, this.maxBytes));
31
- }
32
-
33
- callback();
34
- }
35
-
36
- }
37
- class MeterError extends Error {
38
- constructor(field, maxBytes) {
39
- super(`Field "${field}" exceeded upload size of ${maxBytes} bytes.`);
40
- this.field = field;
41
- this.maxBytes = maxBytes;
42
- }
43
-
44
- }
45
-
46
- exports.Meter = Meter;
47
- exports.MeterError = MeterError;