Skip to content

Commit

Permalink
Migrate to bent from the deprecated request library
Browse files Browse the repository at this point in the history
  • Loading branch information
fendor committed Apr 3, 2022
1 parent 8c3915a commit 58c686e
Show file tree
Hide file tree
Showing 3 changed files with 401 additions and 701 deletions.
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -429,14 +429,14 @@
}
},
"devDependencies": {
"@types/bent": "^7.3.2",
"@types/cheerio": "^0.22.30",
"@types/glob": "^7.1.4",
"@types/js-yaml": "^4.0.5",
"@types/lodash-es": "^4.17.3",
"@types/lru-cache": "^7.6.1",
"@types/mocha": "^9.0.0",
"@types/node": "^17.0.23",
"@types/request-promise-native": "^1.0.17",
"@types/vscode": "^1.52.0",
"@types/which": "^2.0.1",
"@types/yauzl": "^2.9.1",
Expand All @@ -461,13 +461,12 @@
"justusadam.language-haskell"
],
"dependencies": {
"bent": "^7.3.12",
"cheerio": "^1.0.0-rc.10",
"extend": ">=3.0.2",
"js-yaml": "^4.1.0",
"lodash-es": "^4.17.21",
"lru-cache": "^7.7.3",
"request": "^2.88.2",
"request-promise-native": "^1.0.8",
"ts-pattern": "^4.0.1",
"vscode-languageclient": "^7.0.0",
"which": "^2.0.1",
Expand Down
11 changes: 6 additions & 5 deletions src/commands/importIdentifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ import * as cheerio from 'cheerio';
import * as yaml from 'js-yaml';
import escapeRegExp from 'lodash-es/escapeRegExp';
import * as LRUCache from 'lru-cache';
import * as request from 'request-promise-native';
import * as bent from 'bent';
import * as vscode from 'vscode';
import { CommandNames } from './constants';

const getJson = bent('json');

const askHoogle = async (variable: string): Promise<any> => {
return await request({
url: `https://hoogle.haskell.org/?hoogle=${variable}&scope=set%3Astackage&mode=json`,
json: true,
}).promise();
return await getJson(
`https://hoogle.haskell.org/?hoogle=${variable}&scope=set%3Astackage&mode=json`
);
};

const withCache =
Expand Down
Loading

0 comments on commit 58c686e

Please sign in to comment.