@@ -2,9 +2,7 @@ const request = require('request-promise-native');
22const url = require ( 'url' ) ;
33const async = require ( 'async' ) ;
44const crypto = require ( 'crypto' ) ;
5- const throttledQueue = require ( 'throttled-queue' ) ;
6-
7- const throttle = throttledQueue ( 10 , 1000 ) ;
5+ const throttle = require ( 'throttled-queue' ) ( 10 , 1000 ) ;
86
97/**
108 * base model
@@ -38,23 +36,21 @@ class base {
3836
3937 data . private_token = this . token ;
4038
41- return new Promise ( ( resolve , reject ) => {
42- throttle ( ( ) => {
43- request . post ( `${ this . url } ${ path } ` , {
44- json : true ,
45- body : data ,
46- insecure : this . _insecure ,
47- proxy : this . _proxy ,
48- resolveWithFullResponse : true ,
49- headers : {
50- 'PRIVATE-TOKEN' : this . token
51- }
52- } ) . then ( response => {
53- if ( this . config . get ( '_createDump' ) ) this . setDump ( response , key ) ;
54- resolve ( response ) ;
55- } ) . catch ( e => reject ( e ) ) ;
56- } )
57- } ) ;
39+ return new Promise ( ( resolve , reject ) => throttle ( ( ) => {
40+ request . post ( `${ this . url } ${ path } ` , {
41+ json : true ,
42+ body : data ,
43+ insecure : this . _insecure ,
44+ proxy : this . _proxy ,
45+ resolveWithFullResponse : true ,
46+ headers : {
47+ 'PRIVATE-TOKEN' : this . token
48+ }
49+ } ) . then ( response => {
50+ if ( this . config . get ( '_createDump' ) ) this . setDump ( response , key ) ;
51+ resolve ( response ) ;
52+ } ) . catch ( e => reject ( e ) ) ;
53+ } ) ) ;
5854 }
5955
6056 /**
@@ -71,22 +67,20 @@ class base {
7167 path += ( path . includes ( '?' ) ? '&' : '?' ) + `private_token=${ this . token } ` ;
7268 path += `&page=${ page } &per_page=${ perPage } ` ;
7369
74- return new Promise ( ( resolve , reject ) => {
75- throttle ( ( ) => {
76- request ( `${ this . url } ${ path } ` , {
77- json : true ,
78- insecure : this . _insecure ,
79- proxy : this . _proxy ,
80- resolveWithFullResponse : true ,
81- headers : {
82- 'PRIVATE-TOKEN' : this . token
83- }
84- } ) . then ( response => {
85- if ( this . config . get ( '_createDump' ) ) this . setDump ( response , key ) ;
86- resolve ( response ) ;
87- } ) . catch ( e => reject ( e ) ) ;
88- } )
89- } ) ;
70+ return new Promise ( ( resolve , reject ) => throttle ( ( ) => {
71+ request ( `${ this . url } ${ path } ` , {
72+ json : true ,
73+ insecure : this . _insecure ,
74+ proxy : this . _proxy ,
75+ resolveWithFullResponse : true ,
76+ headers : {
77+ 'PRIVATE-TOKEN' : this . token
78+ }
79+ } ) . then ( response => {
80+ if ( this . config . get ( '_createDump' ) ) this . setDump ( response , key ) ;
81+ resolve ( response ) ;
82+ } ) . catch ( e => reject ( e ) ) ;
83+ } ) ) ;
9084 }
9185
9286 /**
@@ -197,4 +191,4 @@ class base {
197191 }
198192}
199193
200- module . exports = base ;
194+ module . exports = base ;
0 commit comments