Skip to content
Permalink
Browse files

Chore: Remove `async` dependency

Fix #2098
  • Loading branch information...
molant authored and antross committed Mar 25, 2019
1 parent ecae908 commit 4571a8249c91396c7bc9a8e2f84a7d5eaa13f528
@@ -14,6 +14,7 @@
],
"references": [
{ "path": "../hint" },
{ "path": "../parser-html" },
{ "path": "../utils-tests-helpers" }
]
}
@@ -6,23 +6,20 @@
],
"timeout": "1m"
},
"dependencies": {
"async": "^2.6.2"
},
"description": "Require scripts and styles to use Subresource Integrity",
"devDependencies": {
"@hint/utils-tests-helpers": "^3.0.0",
"@typescript-eslint/eslint-plugin": "^1.4.2",
"@typescript-eslint/parser": "1.4.2",
"ava": "^1.3.1",
"cpx": "^1.5.0",
"eslint": "^5.15.1",
"eslint-plugin-markdown": "^1.0.0",
"@typescript-eslint/eslint-plugin": "^1.4.2",
"hint": "^4.5.0",
"npm-run-all": "^4.1.5",
"nyc": "^13.3.0",
"rimraf": "^2.6.3",
"typescript": "^3.3.4000",
"@typescript-eslint/parser": "1.4.2"
"typescript": "^3.3.4000"
},
"engines": {
"node": ">=8.0.0"
@@ -4,9 +4,6 @@

import * as crypto from 'crypto';
import { URL } from 'url';
import { promisify } from 'util';

import * as async from 'async';

import { HintContext, ReportOptions } from 'hint/dist/src/lib/hint-context';
import { IHint, FetchEnd, ElementFound, NetworkData, Request, Response } from 'hint/dist/src/lib/types';
@@ -18,7 +15,6 @@ import { Algorithms, OriginCriteria, ErrorData, URLs } from './types';
import meta from './meta';

const debug: debug.IDebugger = d(__filename);
const everySeries = promisify(async.everySeries) as (arr: any, iterator: any) => Promise<any>;

/*
* ------------------------------------------------------------------------------
@@ -453,15 +449,18 @@ Actual: ${integrities.join(', ')}`;
this.downloadContent,
this.hasRightHash
].map((fn) => {
// Otherwise `this` will be undefined when we call to the fn inside `every`
return fn.bind(this);
});

debug(`Validating integrity of: ${evt.resource}`);

await everySeries(validations, async (validation: Function) => {
return await validation(evt, urls);
});
for (const validation of validations) {
const valid = await validation(evt, urls);

if (!valid) {
break;
}
}
}

/**
@@ -10,7 +10,6 @@
"dependencies": {
"ajv": "^6.10.0",
"applicationinsights": "^1.2.0",
"async": "^2.6.2",
"boxen": "^3.0.0",
"browserslist": "^4.5.2",
"caniuse-api": "^3.0.0",
@@ -1,8 +1,6 @@
import { promisify } from 'util';
import { URL } from 'url';
import * as path from 'path';

import * as async from 'async';
import boxen from 'boxen';
import { default as ora, Ora } from 'ora';
import * as chalk from 'chalk';
@@ -22,10 +20,9 @@ import * as resourceLoader from '../utils/resource-loader';
import { installPackages } from '../utils/npm';
import cwd from '../utils/fs/cwd';
import * as insights from '../utils/app-insights';
import { FormatterOptions, IFormatter } from '../types/formatters';
import { FormatterOptions } from '../types/formatters';
import loadHintPackage from '../utils/packages/load-hint-package';

const each = promisify(async.each);
const debug: debug.IDebugger = d(__filename);
const configStoreKey: string = 'run';

@@ -370,9 +367,9 @@ export default async (actions: CLIOptions): Promise<boolean> => {
};

if (engine) {
await each(engine.formatters, async (formatter: IFormatter) => {
for (const formatter of engine.formatters) {
await formatter.format(reports, formatterOptions);
});
}
}
};

@@ -7,7 +7,6 @@
"timeout": "1m"
},
"dependencies": {
"async": "^2.6.2",
"data-urls": "^1.1.0",
"iconv-lite": "^0.4.24",
"iltorb": "^2.4.2",
@@ -11,7 +11,6 @@ import * as url from 'url';
import { promisify } from 'util';
import * as zlib from 'zlib';

import * as async from 'async';
import * as brotli from 'iltorb';
import * as request from 'request';
import * as iconv from 'iconv-lite';
@@ -51,7 +50,6 @@ const inflate = (buff: Buffer): Promise<Buffer> => {
const identity = (buff: Buffer): Promise<Buffer> => {
return Promise.resolve(Buffer.from(buff));
};
const asyncSome = promisify(async.someSeries) as any;

const defaults = {
encoding: null,
@@ -95,7 +93,7 @@ export class Requester {

/** Returns the functions to try to use in order for a given algorithm. */
private decompressors(algorithm: string): Function[] {
const priorities: {[name: string]: number | undefined} = {
const priorities: { [name: string]: number | undefined } = {
br: 0,
gzip: 1,
deflate: 2, // eslint-disable-line sort-keys
@@ -143,14 +141,16 @@ export class Requester {
const algorithms = contentEncoding ?
contentEncoding.split(',') :
['']; // `contentEncoding` could be null. For our purposes '' is OK
const decompressors = this.decompressors(algorithms.shift()!.trim()); // `algorithms` will have at least one item, so `shift()` won't return `undefined`.
const decompressors = this.decompressors(algorithms.shift()!.trim()) as IDecompressor[]; // `algorithms` will have at least one item, so `shift()` won't return `undefined`.
let rawBody: Buffer | null = null;

await asyncSome(decompressors, async (decompressor: IDecompressor) => {
for (const decompressor of decompressors) {
rawBody = await that.tryToDecompress(decompressor, rawBodyResponse);

return !!rawBody;
});
if (rawBody) {
break;
}
}

// There's another decompression we need to do
if (rawBody && algorithms.length > 0) {
@@ -1427,7 +1427,7 @@ async@^0.9.0:
resolved "https://registry.yarnpkg.com/async/-/async-0.9.2.tgz#aea74d5e61c1f899613bf64bda66d4c78f2fd17d"
integrity sha1-rqdNXmHB+JlhO/ZL2mbUx48v0X0=

async@^2.0.0, async@^2.6.2:
async@^2.0.0:
version "2.6.2"
resolved "https://registry.yarnpkg.com/async/-/async-2.6.2.tgz#18330ea7e6e313887f5d2f2a904bac6fe4dd5381"
integrity sha512-H1qVYh1MYhEEFLsP97cVKqCGo7KfCyTt6uEWqsTBr9SO84oK9Uwbyd/yCW+6rKJLHksBNUVWZDAjfS+Ccx0Bbg==

0 comments on commit 4571a82

Please sign in to comment.
You can’t perform that action at this time.