diff --git a/__test__/apiConfig.test.ts b/__test__/apiConfig.test.ts index 5ff0a37..9a8b143 100644 --- a/__test__/apiConfig.test.ts +++ b/__test__/apiConfig.test.ts @@ -1,4 +1,4 @@ -import { isType } from '../src/utils/util.is' +import { isType } from 'is-any-type' import { ApiConfig as MidtransConfigApi } from '../src/lib/apiConfig' import { config } from '../config' diff --git a/__test__/coreApi.test.ts b/__test__/coreApi.test.ts index 05e3cc5..309acba 100644 --- a/__test__/coreApi.test.ts +++ b/__test__/coreApi.test.ts @@ -1,4 +1,4 @@ -import { isType } from '../src/utils/util.is' +import { isType } from 'is-any-type' import { CoreApi } from '../src/lib/coreApi' import { config } from '../config' diff --git a/__test__/httpClient.test.ts b/__test__/httpClient.test.ts index 321dce7..293e64d 100644 --- a/__test__/httpClient.test.ts +++ b/__test__/httpClient.test.ts @@ -1,4 +1,4 @@ -import { isType } from '../src/utils/util.is' +import { isType } from 'is-any-type' import { HttpClient } from '../src/lib/httpClient' import { config } from '../config' describe('HttpClient', () => { diff --git a/__test__/iris.test.ts b/__test__/iris.test.ts index 4188d06..01b534e 100644 --- a/__test__/iris.test.ts +++ b/__test__/iris.test.ts @@ -1,4 +1,4 @@ -import { isType } from '../src/utils/util.is' +import { isType } from 'is-any-type' import { Iris } from '../src/lib/iris' import { config } from '../config' let globVar = { diff --git a/__test__/midtransClient.test.ts b/__test__/midtransClient.test.ts index 7096538..0e4e242 100644 --- a/__test__/midtransClient.test.ts +++ b/__test__/midtransClient.test.ts @@ -1,4 +1,4 @@ -import { isType } from '../src/utils/util.is' +import { isType } from 'is-any-type' import { MidtransClient } from '../src/index' import { config } from '../config' diff --git a/__test__/snap.test.ts b/__test__/snap.test.ts index 9a7477e..9fb40b8 100644 --- a/__test__/snap.test.ts +++ b/__test__/snap.test.ts @@ -1,4 +1,4 @@ -import { isType } from '../src/utils/util.is' +import { isType } from 'is-any-type' import { Snap } from '../src/lib/snap' import { config } from '../config' diff --git a/package-lock.json b/package-lock.json index 6fffa6f..ef5973a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3333,6 +3333,11 @@ } } }, + "is-any-type": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/is-any-type/-/is-any-type-0.0.2.tgz", + "integrity": "sha512-FapPzcBd/CqIi5i9xwBoZ053d7fIqtLMpTTlXpBTTVsn8b2LBdIzO1P7ixkoBwzWN0YRpGw3MzG9Kf04zJPM/Q==" + }, "is-arrayish": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", diff --git a/package.json b/package.json index c8bf114..246e36e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "midtrans-node-client", - "version": "0.0.1-rc", + "version": "0.0.1", "description": "Unoffficial Midtrans Payment API Client for Node JS | Alternative for Midtrans Official Module", "main": "./dist/index.js", "files": [ @@ -48,6 +48,7 @@ ], "dependencies": { "axios": "^0.21.1", + "is-any-type": "0.0.2", "lodash": "^4.17.20" }, "devDependencies": { diff --git a/src/lib/httpClient.ts b/src/lib/httpClient.ts index a7e9399..63beb9f 100644 --- a/src/lib/httpClient.ts +++ b/src/lib/httpClient.ts @@ -1,5 +1,5 @@ import axios, { AxiosInstance, AxiosResponse, Method } from 'axios' -import { isType } from '../utils/util.is' +import { isType } from 'is-any-type' import { Snap } from '../lib/snap' import { CoreApi } from '../lib/coreApi' import { Iris } from '../lib/iris' diff --git a/src/utils/util.is.ts b/src/utils/util.is.ts deleted file mode 100644 index b2a1819..0000000 --- a/src/utils/util.is.ts +++ /dev/null @@ -1,24 +0,0 @@ -export const isType = (data: any): string => { - const isArray: string = Array.isArray(data) && 'array' - const isObject: string = data === {} && 'object' - const isNull: string = data == null && 'null' - - const isGrouping: string = isArray || isObject || isNull - const isCheck: string = !isGrouping ? typeof data : isGrouping - - const isTypeData: string[] = [ - 'number', - 'string', - 'array', - 'symbol', - 'object', - 'undefined', - 'null', - 'function', - 'boolean' - ] - const isMatch: number = isTypeData.indexOf(isCheck) - const isResult: string = isTypeData[isMatch] - - return isResult -}