Skip to content

Commit 93c4832

Browse files
committed
- replace all "async" variables to "asyncHandler"
1 parent 05ea9e1 commit 93c4832

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+230
-237
lines changed

src/cache/cache-methods.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,19 @@ import Urls from '../urls'
33
import Request from '../request'
44

55
//TODO: rename me
6-
export function cacheMethod(method, key, contain, async) {
6+
export function cacheMethod(method, key, contain, asyncHandler) {
77
if (!Utils.isString(key)) {
88
throw new Error('The "key" argument must be String')
99
}
1010

11-
//TODO: refactor me
12-
let responder = async
13-
const isAsync = !!responder
14-
15-
if (responder) {
16-
responder = Utils.wrapAsync(responder)
11+
if (asyncHandler) {
12+
asyncHandler = Utils.wrapAsync(asyncHandler)
1713
}
1814

1915
return Request.send({
2016
method : method,
2117
url : contain ? Urls.cacheItemCheck(key) : Urls.cacheItem(key),
22-
isAsync : isAsync,
23-
asyncHandler: responder
18+
isAsync : !!asyncHandler,
19+
asyncHandler: asyncHandler
2420
})
2521
}

src/cache/contains.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { cacheMethod } from './cache-methods'
22

3-
export function contains(key, async) {
4-
return cacheMethod('GET', key, true, async)
3+
export function contains(key, asyncHandler) {
4+
return cacheMethod('GET', key, true, asyncHandler)
55
}

src/cache/put.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,28 @@ import Urls from '../urls'
33
import Async from '../request/async'
44
import Request from '../request'
55

6-
export function put(key, value, timeToLive, async) {
6+
export function put(key, value, timeToLive, asyncHandler) {
77
if (!Utils.isString(key)) {
88
throw new Error('You can use only String as key to put into Cache')
99
}
1010

1111
if (!(timeToLive instanceof Async)) {
1212
if (typeof timeToLive === 'object' && !arguments[3]) {
13-
async = timeToLive
13+
asyncHandler = timeToLive
1414
timeToLive = null
1515
} else if (typeof timeToLive !== ('number' || 'string') && timeToLive != null) {
1616
throw new Error('You can use only String as timeToLive attribute to put into Cache')
1717
}
1818
} else {
19-
async = timeToLive
19+
asyncHandler = timeToLive
2020
timeToLive = null
2121
}
2222

2323
if (Utils.isObject(value) && value.constructor !== Object) {
2424
value.___class = value.___class || Utils.getClassName(value)
2525
}
2626

27-
let responder = Utils.extractResponder([async])
27+
let responder = Utils.extractResponder([asyncHandler])
2828
const isAsync = !!responder
2929

3030
if (responder) {

src/cache/remove.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { cacheMethod } from './cache-methods'
22

3-
export function remove(key, async) {
4-
return cacheMethod('DELETE', key, false, async)
3+
export function remove(key, asyncHandler) {
4+
return cacheMethod('DELETE', key, false, asyncHandler)
55
}

src/commerce/cancel-play-subscription.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@ import Request from '../request'
44

55
import { validateStringArgument } from './validate-string-argument'
66

7-
export function cancelPlaySubscription(packageName, subscriptionId, token, async) {
7+
export function cancelPlaySubscription(packageName, subscriptionId, token, asyncHandler) {
88
validateStringArgument('Package Name', packageName)
99
validateStringArgument('Subscription Id', subscriptionId)
1010
validateStringArgument('Token', token)
1111

12-
if (async) {
13-
async = Utils.wrapAsync(async)
12+
if (asyncHandler) {
13+
asyncHandler = Utils.wrapAsync(asyncHandler)
1414
}
1515

1616
return Request.post({
1717
url : Urls.commerceSubCancel(packageName, subscriptionId, token),
18-
isAsync : !!async,
19-
asyncHandler: async
18+
isAsync : !!asyncHandler,
19+
asyncHandler: asyncHandler
2020
})
2121
}

src/commerce/get-play-subscription-status.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@ import Request from '../request'
44

55
import { validateStringArgument } from './validate-string-argument'
66

7-
export function getPlaySubscriptionStatus(packageName, subscriptionId, token, async) {
7+
export function getPlaySubscriptionStatus(packageName, subscriptionId, token, asyncHandler) {
88
validateStringArgument('Package Name', packageName)
99
validateStringArgument('Subscription Id', subscriptionId)
1010
validateStringArgument('Token', token)
1111

12-
if (async) {
13-
async = Utils.wrapAsync(async)
12+
if (asyncHandler) {
13+
asyncHandler = Utils.wrapAsync(asyncHandler)
1414
}
1515

1616
return Request.get({
1717
url : Urls.commerceSubStatus(packageName, subscriptionId, token),
18-
isAsync : !!async,
19-
asyncHandler: async
18+
isAsync : !!asyncHandler,
19+
asyncHandler: asyncHandler
2020
})
2121
}

src/commerce/validate-play-purchase.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@ import Request from '../request'
44

55
import { validateStringArgument } from './validate-string-argument'
66

7-
export function validatePlayPurchase(packageName, productId, token, async) {
7+
export function validatePlayPurchase(packageName, productId, token, asyncHandler) {
88
validateStringArgument('Package Name', packageName)
99
validateStringArgument('Product Id', productId)
1010
validateStringArgument('Token', token)
1111

12-
if (async) {
13-
async = Utils.wrapAsync(async)
12+
if (asyncHandler) {
13+
asyncHandler = Utils.wrapAsync(asyncHandler)
1414
}
1515

1616
return Request.get({
1717
url : Urls.commerceValidate(packageName, productId, token),
18-
isAsync : !!async,
19-
asyncHandler: async
18+
isAsync : !!asyncHandler,
19+
asyncHandler: asyncHandler
2020
})
2121
}

src/commerce/validate-string-argument.js

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,3 @@ export function validateStringArgument(label, value) {
77
throw new Error(`${label} be provided and must be not an empty STRING!`)
88
}
99
}
10-
11-
export function cancelPlaySubscription(packageName, subscriptionId, token, async) {
12-
validateStringArgument('Package Name', packageName)
13-
validateStringArgument('Subscription Id', subscriptionId)
14-
validateStringArgument('Token', token)
15-
16-
if (async) {
17-
async = Utils.wrapAsync(async)
18-
}
19-
20-
return Request.post({
21-
url : Urls.commerceSubCancel(packageName, subscriptionId, token),
22-
isAsync : !!async,
23-
asyncHandler: async
24-
})
25-
}

src/counters/add-and-get.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { implementMethodWithValue } from './implement-method-with-value'
22

3-
export function addAndGet(counterName, value, async) {
4-
return implementMethodWithValue(counterName, 'incrementby/get' + '?value=', value, async)
3+
export function addAndGet(counterName, value, asyncHandler) {
4+
return implementMethodWithValue(counterName, 'incrementby/get' + '?value=', value, asyncHandler)
55
}

src/counters/decrement-and-get.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { implementMethod } from './implement-method'
22

3-
export function decrementAndGet(counterName, async) {
4-
return implementMethod(counterName, 'decrement/get', async)
3+
export function decrementAndGet(counterName, asyncHandler) {
4+
return implementMethod(counterName, 'decrement/get', asyncHandler)
55
}

0 commit comments

Comments
 (0)