This repository was archived by the owner on Feb 13, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +11
-12
lines changed Expand file tree Collapse file tree 4 files changed +11
-12
lines changed Original file line number Diff line number Diff line change @@ -238,7 +238,8 @@ class Analytics {
238
238
callback = callback || noop
239
239
240
240
if ( ! this . enable ) {
241
- return setImmediate ( callback )
241
+ setImmediate ( callback )
242
+ return Promise . resolve ( )
242
243
}
243
244
244
245
if ( this . timer ) {
@@ -247,7 +248,8 @@ class Analytics {
247
248
}
248
249
249
250
if ( ! this . queue . length ) {
250
- return setImmediate ( callback )
251
+ setImmediate ( callback )
252
+ return Promise . resolve ( )
251
253
}
252
254
253
255
const items = this . queue . splice ( 0 , this . flushAt )
@@ -286,14 +288,19 @@ class Analytics {
286
288
}
287
289
288
290
return this . axiosInstance . post ( `${ this . host } ${ this . path } ` , data , req )
289
- . then ( ( ) => done ( ) )
291
+ . then ( ( ) => {
292
+ done ( )
293
+ return Promise . resolve ( data )
294
+ } )
290
295
. catch ( err => {
291
296
if ( err . response ) {
292
297
const error = new Error ( err . response . statusText )
293
- return done ( error )
298
+ done ( error )
299
+ throw error
294
300
}
295
301
296
302
done ( err )
303
+ throw err
297
304
} )
298
305
}
299
306
Original file line number Diff line number Diff line change 54
54
"husky" : " ^3.0.4" ,
55
55
"np" : " ^7.5.0" ,
56
56
"nyc" : " ^15.1.0" ,
57
- "pify" : " ^4.0.1" ,
58
57
"sinon" : " ^7.3.2" ,
59
58
"snyk" : " ^1.171.1" ,
60
59
"standard" : " ^12.0.1"
Original file line number Diff line number Diff line change @@ -3,7 +3,6 @@ import bodyParser from 'body-parser'
3
3
import express from 'express'
4
4
import delay from 'delay'
5
5
import auth from 'basic-auth'
6
- import pify from 'pify'
7
6
import test from 'ava'
8
7
import Analytics from '.'
9
8
import { version } from './package'
@@ -28,7 +27,6 @@ const createClient = options => {
28
27
} , options )
29
28
30
29
const client = new Analytics ( 'key' , options )
31
- client . flush = pify ( client . flush . bind ( client ) )
32
30
client . flushed = true
33
31
34
32
return client
Original file line number Diff line number Diff line change @@ -6011,11 +6011,6 @@ pify@^3.0.0:
6011
6011
resolved "https://registry.yarnpkg.com/pify/-/pify-3.0.0.tgz#e5a4acd2c101fdf3d9a4d07f0dbc4db49dd28176"
6012
6012
integrity sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=
6013
6013
6014
- pify@^4.0.1 :
6015
- version "4.0.1"
6016
- resolved "https://registry.yarnpkg.com/pify/-/pify-4.0.1.tgz#4b2cd25c50d598735c50292224fd8c6df41e3231"
6017
- integrity sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==
6018
-
6019
6014
pinkie-promise@^1.0.0 :
6020
6015
version "1.0.0"
6021
6016
resolved "https://registry.yarnpkg.com/pinkie-promise/-/pinkie-promise-1.0.0.tgz#d1da67f5482563bb7cf57f286ae2822ecfbf3670"
You can’t perform that action at this time.
0 commit comments