@fastify/busboy
Advanced tools
Comparing version 1.2.1 to 2.0.0
'use strict' | ||
const WritableStream = require('stream').Writable | ||
const inherits = require('util').inherits | ||
const WritableStream = require('node:stream').Writable | ||
const inherits = require('node:util').inherits | ||
@@ -6,0 +6,0 @@ const StreamSearch = require('../../streamsearch/sbmh') |
'use strict' | ||
const EventEmitter = require('events').EventEmitter | ||
const inherits = require('util').inherits | ||
const EventEmitter = require('node:events').EventEmitter | ||
const inherits = require('node:util').inherits | ||
const getLimit = require('../../../lib/utils/getLimit') | ||
@@ -6,0 +6,0 @@ |
'use strict' | ||
const inherits = require('util').inherits | ||
const ReadableStream = require('stream').Readable | ||
const inherits = require('node:util').inherits | ||
const ReadableStream = require('node:stream').Readable | ||
@@ -6,0 +6,0 @@ function PartStream (opts) { |
@@ -29,4 +29,4 @@ 'use strict' | ||
*/ | ||
const EventEmitter = require('events').EventEmitter | ||
const inherits = require('util').inherits | ||
const EventEmitter = require('node:events').EventEmitter | ||
const inherits = require('node:util').inherits | ||
@@ -33,0 +33,0 @@ function SBMH (needle) { |
'use strict' | ||
const WritableStream = require('stream').Writable | ||
const { inherits } = require('util') | ||
const WritableStream = require('node:stream').Writable | ||
const { inherits } = require('node:util') | ||
const Dicer = require('../deps/dicer/lib/Dicer') | ||
@@ -44,3 +44,3 @@ | ||
if (!this._done) { | ||
this._parser && this._parser.end() | ||
this._parser?.end() | ||
return | ||
@@ -47,0 +47,0 @@ } else if (this._finished) { |
@@ -10,4 +10,4 @@ 'use strict' | ||
const ReadableStream = require('stream').Readable | ||
const inherits = require('util').inherits | ||
const { Readable } = require('node:stream') | ||
const { inherits } = require('node:util') | ||
@@ -51,6 +51,3 @@ const Dicer = require('../../deps/dicer/lib/Dicer') | ||
finished = false | ||
process.nextTick(function () { | ||
boy._done = true | ||
boy.emit('finish') | ||
}) | ||
self.end() | ||
} | ||
@@ -273,4 +270,6 @@ } | ||
Multipart.prototype.write = function (chunk, cb) { | ||
let r | ||
if ((r = this.parser.write(chunk)) && !this._pause) { cb() } else { | ||
const r = this.parser.write(chunk) | ||
if (r && !this._pause) { | ||
cb() | ||
} else { | ||
this._needDrain = !r | ||
@@ -283,3 +282,6 @@ this._cb = cb | ||
const self = this | ||
if (this._nparts === 0 && !self._boy._done) { | ||
if (self.parser.writable) { | ||
self.parser.end() | ||
} else if (!self._boy._done) { | ||
process.nextTick(function () { | ||
@@ -289,3 +291,3 @@ self._boy._done = true | ||
}) | ||
} else if (this.parser.writable) { this.parser.end() } | ||
} | ||
} | ||
@@ -298,3 +300,3 @@ | ||
function FileStream (opts) { | ||
ReadableStream.call(this, opts) | ||
Readable.call(this, opts) | ||
@@ -305,6 +307,7 @@ this.bytesRead = 0 | ||
} | ||
inherits(FileStream, ReadableStream) | ||
FileStream.prototype._read = function (n) { } | ||
inherits(FileStream, Readable) | ||
FileStream.prototype._read = function (n) {} | ||
module.exports = Multipart |
'use strict' | ||
let TextDecoder | ||
try { | ||
TextDecoder = require('util').TextDecoder | ||
} catch (e) { } | ||
const { TextDecoder: PolyfillTextDecoder, getEncoding } = require('text-decoding') | ||
// Node has always utf-8 | ||
const textDecoders = new Map() | ||
if (TextDecoder) { | ||
textDecoders.set('utf-8', new TextDecoder('utf-8')) | ||
} else { | ||
textDecoders.set('utf-8', new PolyfillTextDecoder('utf-8')) | ||
} | ||
textDecoders.set('utf8', textDecoders.get('utf-8')) | ||
const utf8Decoder = new TextDecoder('utf-8') | ||
const textDecoders = new Map([ | ||
['utf-8', utf8Decoder], | ||
['utf8', utf8Decoder] | ||
]) | ||
@@ -29,28 +20,3 @@ function decodeText (text, textEncoding, destEncoding) { | ||
return textDecoders.get(destEncoding).decode(Buffer.from(text, textEncoding)) | ||
} catch (e) { | ||
if (getEncoding(destEncoding)) { | ||
try { | ||
textDecoders.set(destEncoding, new PolyfillTextDecoder(destEncoding)) | ||
return textDecoders.get(destEncoding).decode(Buffer.from(text, textEncoding)) | ||
} catch (e) { } | ||
} | ||
} | ||
} | ||
} | ||
return text | ||
} | ||
function decodeTextPolyfill (text, textEncoding, destEncoding) { | ||
if (text) { | ||
if (textDecoders.has(destEncoding)) { | ||
try { | ||
return textDecoders.get(destEncoding).decode(Buffer.from(text, textEncoding)) | ||
} catch (e) { } | ||
} else { | ||
if (getEncoding(destEncoding)) { | ||
try { | ||
textDecoders.set(destEncoding, new PolyfillTextDecoder(destEncoding)) | ||
return textDecoders.get(destEncoding).decode(Buffer.from(text, textEncoding)) | ||
} catch (e) { } | ||
} | ||
} | ||
@@ -61,2 +27,2 @@ } | ||
module.exports = TextDecoder ? decodeText : decodeTextPolyfill | ||
module.exports = decodeText |
{ | ||
"name": "@fastify/busboy", | ||
"version": "1.2.1", | ||
"version": "2.0.0", | ||
"private": false, | ||
@@ -37,7 +37,4 @@ "author": "Brian White <mscdex@mscdex.net>", | ||
}, | ||
"dependencies": { | ||
"text-decoding": "^1.0.0" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^18.0.0", | ||
"@types/node": "^20.1.0", | ||
"busboy": "^1.0.0", | ||
@@ -47,3 +44,3 @@ "chai": "^4.3.6", | ||
"eslint-config-standard": "^17.0.0", | ||
"eslint-plugin-n": "^15.2.5", | ||
"eslint-plugin-n": "^16.0.0", | ||
"mocha": "^10.0.0", | ||
@@ -54,4 +51,4 @@ "nyc": "^15.1.0", | ||
"standard": "^17.0.0", | ||
"tsd": "^0.25.0", | ||
"typescript": "^4.5.2" | ||
"tsd": "^0.29.0", | ||
"typescript": "^5.0.2" | ||
}, | ||
@@ -58,0 +55,0 @@ "keywords": [ |
@@ -54,4 +54,4 @@ # busboy | ||
```javascript | ||
const http = require('http'); | ||
const { inspect } = require('util'); | ||
const http = require('node:http'); | ||
const { inspect } = require('node:util'); | ||
const Busboy = require('busboy'); | ||
@@ -107,6 +107,6 @@ | ||
```javascript | ||
const http = require('http'); | ||
const path = require('path'); | ||
const os = require('os'); | ||
const fs = require('fs'); | ||
const http = require('node:http'); | ||
const path = require('node:path'); | ||
const os = require('node:os'); | ||
const fs = require('node:fs'); | ||
@@ -138,4 +138,4 @@ const Busboy = require('busboy'); | ||
```javascript | ||
const http = require('http'); | ||
const { inspect } = require('util'); | ||
const http = require('node:http'); | ||
const { inspect } = require('node:util'); | ||
@@ -142,0 +142,0 @@ const Busboy = require('busboy'); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
0
70738
1481
- Removedtext-decoding@^1.0.0
- Removedtext-decoding@1.0.0(transitive)