@parcel/utils 2.0.0-beta.3 → 2.0.0-dev.1510
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/lib/index.js +37516 -542
- package/lib/index.js.map +1 -0
- package/package.json +41 -18
- package/src/DefaultMap.js +1 -1
- package/src/PromiseQueue.js +13 -0
- package/src/alternatives.js +21 -6
- package/src/ansi-html.js +1 -1
- package/src/blob.js +1 -0
- package/src/collection.js +35 -3
- package/src/config.js +77 -22
- package/src/debounce.js +1 -1
- package/src/dependency-location.js +5 -5
- package/src/getExisting.js +1 -4
- package/src/getModuleParts.js +23 -0
- package/src/glob.js +26 -3
- package/src/hash.js +49 -0
- package/src/http-server.js +19 -7
- package/src/index.js +25 -10
- package/src/path.js +11 -1
- package/src/prettyDiagnostic.js +90 -40
- package/src/progress-message.js +22 -0
- package/src/replaceBundleReferences.js +49 -25
- package/src/schema.js +20 -19
- package/src/shared-buffer.js +23 -0
- package/src/sourcemap.js +13 -7
- package/src/urlJoin.js +3 -1
- package/test/DefaultMap.test.js +7 -4
- package/test/PromiseQueue.test.js +28 -0
- package/test/collection.test.js +13 -1
- package/test/config.test.js +98 -0
- package/test/input/config/.testrc +3 -0
- package/test/input/config/config.cjs +3 -0
- package/test/input/config/config.js +3 -0
- package/test/input/config/config.json +3 -0
- package/test/input/config/empty.json +0 -0
- package/test/input/config/empty.toml +0 -0
- package/test/replaceBundleReferences.test.js +88 -4
- package/test/throttle.test.js +1 -1
- package/test/urlJoin.test.js +11 -0
- package/lib/DefaultMap.js +0 -64
- package/lib/Deferred.js +0 -34
- package/lib/PromiseQueue.js +0 -144
- package/lib/TapStream.js +0 -46
- package/lib/alternatives.js +0 -151
- package/lib/ansi-html.js +0 -32
- package/lib/blob.js +0 -47
- package/lib/bundle-url.js +0 -43
- package/lib/collection.js +0 -51
- package/lib/config.js +0 -159
- package/lib/countLines.js +0 -18
- package/lib/debounce.js +0 -20
- package/lib/dependency-location.js +0 -21
- package/lib/escape-html.js +0 -24
- package/lib/generateBuildMetrics.js +0 -156
- package/lib/generateCertificate.js +0 -149
- package/lib/getCertificate.js +0 -19
- package/lib/getExisting.js +0 -31
- package/lib/getRootDir.js +0 -74
- package/lib/glob.js +0 -118
- package/lib/http-server.js +0 -110
- package/lib/is-url.js +0 -27
- package/lib/isDirectoryInside.js +0 -24
- package/lib/md5.js +0 -61
- package/lib/objectHash.js +0 -34
- package/lib/openInBrowser.js +0 -94
- package/lib/parseCSSImport.js +0 -16
- package/lib/path.js +0 -44
- package/lib/prettifyTime.js +0 -10
- package/lib/prettyDiagnostic.js +0 -119
- package/lib/relativeBundlePath.js +0 -38
- package/lib/relativeUrl.js +0 -32
- package/lib/replaceBundleReferences.js +0 -184
- package/lib/schema.js +0 -391
- package/lib/sourcemap.js +0 -155
- package/lib/stream.js +0 -86
- package/lib/throttle.js +0 -16
- package/lib/urlJoin.js +0 -43
- package/src/.babelrc +0 -3
- package/src/md5.js +0 -56
package/src/md5.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
// @flow strict-local
|
|
2
|
-
|
|
3
|
-
import type {Readable} from 'stream';
|
|
4
|
-
import type {FileSystem} from '@parcel/fs';
|
|
5
|
-
|
|
6
|
-
import crypto from 'crypto';
|
|
7
|
-
import {objectSortedEntriesDeep} from './collection';
|
|
8
|
-
|
|
9
|
-
type StringHashEncoding = 'hex' | 'latin1' | 'binary' | 'base64';
|
|
10
|
-
|
|
11
|
-
export function md5FromString(
|
|
12
|
-
string: string | Buffer,
|
|
13
|
-
encoding: StringHashEncoding = 'hex',
|
|
14
|
-
): string {
|
|
15
|
-
return crypto
|
|
16
|
-
.createHash('md5')
|
|
17
|
-
.update(string)
|
|
18
|
-
.digest(encoding);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function md5FromReadableStream(stream: Readable): Promise<string> {
|
|
22
|
-
return new Promise((resolve, reject) => {
|
|
23
|
-
stream.on('error', err => {
|
|
24
|
-
reject(err);
|
|
25
|
-
});
|
|
26
|
-
stream
|
|
27
|
-
.pipe(crypto.createHash('md5').setEncoding('hex'))
|
|
28
|
-
.on('finish', function() {
|
|
29
|
-
resolve(this.read());
|
|
30
|
-
})
|
|
31
|
-
.on('error', err => {
|
|
32
|
-
reject(err);
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export function md5FromOrderedObject(
|
|
38
|
-
obj: {+[string]: mixed, ...},
|
|
39
|
-
encoding: StringHashEncoding = 'hex',
|
|
40
|
-
): string {
|
|
41
|
-
return md5FromString(JSON.stringify(obj), encoding);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export function md5FromObject(
|
|
45
|
-
obj: {+[string]: mixed, ...},
|
|
46
|
-
encoding: StringHashEncoding = 'hex',
|
|
47
|
-
): string {
|
|
48
|
-
return md5FromString(JSON.stringify(objectSortedEntriesDeep(obj)), encoding);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export function md5FromFilePath(
|
|
52
|
-
fs: FileSystem,
|
|
53
|
-
filePath: string,
|
|
54
|
-
): Promise<string> {
|
|
55
|
-
return md5FromReadableStream(fs.createReadStream(filePath));
|
|
56
|
-
}
|