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 {
238238 callback = callback || noop
239239
240240 if ( ! this . enable ) {
241- return setImmediate ( callback )
241+ setImmediate ( callback )
242+ return Promise . resolve ( )
242243 }
243244
244245 if ( this . timer ) {
@@ -247,7 +248,8 @@ class Analytics {
247248 }
248249
249250 if ( ! this . queue . length ) {
250- return setImmediate ( callback )
251+ setImmediate ( callback )
252+ return Promise . resolve ( )
251253 }
252254
253255 const items = this . queue . splice ( 0 , this . flushAt )
@@ -286,14 +288,19 @@ class Analytics {
286288 }
287289
288290 return this . axiosInstance . post ( `${ this . host } ${ this . path } ` , data , req )
289- . then ( ( ) => done ( ) )
291+ . then ( ( ) => {
292+ done ( )
293+ return Promise . resolve ( data )
294+ } )
290295 . catch ( err => {
291296 if ( err . response ) {
292297 const error = new Error ( err . response . statusText )
293- return done ( error )
298+ done ( error )
299+ throw error
294300 }
295301
296302 done ( err )
303+ throw err
297304 } )
298305 }
299306
Original file line number Diff line number Diff line change 5454 "husky" : " ^3.0.4" ,
5555 "np" : " ^7.5.0" ,
5656 "nyc" : " ^15.1.0" ,
57- "pify" : " ^4.0.1" ,
5857 "sinon" : " ^7.3.2" ,
5958 "snyk" : " ^1.171.1" ,
6059 "standard" : " ^12.0.1"
Original file line number Diff line number Diff line change @@ -3,7 +3,6 @@ import bodyParser from 'body-parser'
33import express from 'express'
44import delay from 'delay'
55import auth from 'basic-auth'
6- import pify from 'pify'
76import test from 'ava'
87import Analytics from '.'
98import { version } from './package'
@@ -28,7 +27,6 @@ const createClient = options => {
2827 } , options )
2928
3029 const client = new Analytics ( 'key' , options )
31- client . flush = pify ( client . flush . bind ( client ) )
3230 client . flushed = true
3331
3432 return client
Original file line number Diff line number Diff line change @@ -6011,11 +6011,6 @@ pify@^3.0.0:
60116011 resolved "https://registry.yarnpkg.com/pify/-/pify-3.0.0.tgz#e5a4acd2c101fdf3d9a4d07f0dbc4db49dd28176"
60126012 integrity sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=
60136013
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-
60196014pinkie-promise@^1.0.0 :
60206015 version "1.0.0"
60216016 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