Skip to content

Commit

Permalink
style: @jessie-check for curl.js
Browse files Browse the repository at this point in the history
 - add jessie.js eslint config
 - upgrade elint (why?)
 - use `makePromise` from `jessie.js` to avoid `new`
 - lock packages
  • Loading branch information
dckc committed Jan 15, 2022
1 parent 6c538ef commit 77a25d7
Show file tree
Hide file tree
Showing 3 changed files with 205 additions and 151 deletions.
13 changes: 12 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,19 @@
},
"homepage": "https://github.com/rchain-community/RChain-API#readme",
"dependencies": {
"@jessie.js/eslint-plugin": "^0.1.3",
"blakejs": "^1.1.0",
"bs58": "^4.0.1",
"elliptic": "^6.5.4",
"ethereumjs-util": "^7.0.7",
"google-protobuf": "^3.13.0",
"jessie.js": "^0.2.0",
"js-sha3": "^0.8.0"
},
"devDependencies": {
"@types/node": "^14.11.2",
"ava": "^3.13.0",
"eslint": "^7.9.0",
"eslint": "^8.6.0",
"eslint-config-airbnb": "^18.2.0",
"eslint-config-airbnb-base": "^14.2.0",
"eslint-config-prettier": "^6.11.0",
Expand All @@ -70,6 +72,15 @@
"prettier": "^2.1.1",
"typescript": "^4.0.2"
},
"eslintConfig": {
"parserOptions": {
"sourceType": "module",
"ecmaVersion": 6
},
"extends": [
"plugin:@jessie.js/recommended"
]
},
"TODO": {
"documentation": "^8.0.2"
}
Expand Down
11 changes: 7 additions & 4 deletions src/curl.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
// @ts-check
// @jessie-check

import { makePromise } from 'jessie.js';

/**
* @param {string} url
* @param {{ http: any }} powers
* @returns {Promise<string>}
*/
export function curl(url, { http }) {
return new Promise((resolve, reject) => {
return makePromise((resolve, reject) => {
const req = http.get(url, response => {
let str = '';
// console.log('Response is ' + response.statusCode);
Expand All @@ -26,12 +29,12 @@ export function curl(url, { http }) {
export function nodeFetch({ http }) {
/** @type { typeof fetch } */
function fetch(url, options = {}) {
return new Promise((resolve, reject) => {
return makePromise((resolve, reject) => {
const { method = 'GET', body } = options;
if (typeof url !== 'string') { throw new Error('not implemented'); }
if (typeof url !== 'string') { throw Error('not implemented'); }
const req = http.request(url, { method }, res => {
res.setEncoding('utf8');
let content = ''
let content = '';
res.on('data', data => { content += data; });

res.on('end', () => {
Expand Down
Loading

0 comments on commit 77a25d7

Please sign in to comment.