mirror of
https://github.com/bitinflow/server.git
synced 2026-03-13 13:35:53 +00:00
refactor with async/await
Trying to be more robust about error handling and failure.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
var http = require('http');
|
||||
var util = require('util');
|
||||
var assert = require('assert');
|
||||
import http from 'http';
|
||||
import util from 'util';
|
||||
import assert from 'assert';
|
||||
|
||||
// binding agent will return a given options.socket as the socket for the agent
|
||||
// this is useful if you already have a socket established and want the request
|
||||
@@ -20,4 +20,4 @@ function create_connection(port, host, options) {
|
||||
return this.socket;
|
||||
}
|
||||
|
||||
module.exports = BindingAgent;
|
||||
export default BindingAgent;
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
// all url safe
|
||||
// can't use uppercase because hostnames are lowercased
|
||||
var chars = 'abcdefghijklmnopqrstuvwxyz';
|
||||
const chars = 'abcdefghijklmnopqrstuvwxyz';
|
||||
|
||||
module.exports = function rand_id() {
|
||||
var randomstring = '';
|
||||
export default function rand_id() {
|
||||
let randomstring = '';
|
||||
for (var i=0; i<10; ++i) {
|
||||
var rnum = Math.floor(Math.random() * chars.length);
|
||||
const rnum = Math.floor(Math.random() * chars.length);
|
||||
randomstring += chars[rnum];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user