Skip to content

Commit 1864da2

Browse files
committed
feat: remove the startPolling API
1 parent 7d4a3d0 commit 1864da2

File tree

6 files changed

+2
-95
lines changed

6 files changed

+2
-95
lines changed

src/api.ts

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import {
2727
CrawlPageDetailTargetConfig,
2828
PageCookies,
2929
CrawlPageSingleResult,
30-
StartPollingConfig,
3130
CrawlPageAdvancedConfig,
3231
CrawlDataSingleResult,
3332
CrawlFileSingleResult,
@@ -1395,47 +1394,3 @@ export function createCrawlFile(xCrawlInstanceConfig: XCrawlInstanceConfig) {
13951394

13961395
return crawlFile
13971396
}
1398-
1399-
export function createStartPolling(xCrawlInstanceConfig: XCrawlInstanceConfig) {
1400-
const { id: xId, logConfig } = xCrawlInstanceConfig
1401-
let id = 0
1402-
const type = 'polling'
1403-
1404-
return (
1405-
config: StartPollingConfig,
1406-
callback: (count: number, stopPolling: () => void) => void
1407-
) => {
1408-
const serialNumber = `${xId}-${type}-${++id}`
1409-
const { d, h, m } = config
1410-
1411-
const day = !isUndefined(d) ? d * 1000 * 60 * 60 * 24 : 0
1412-
const hour = !isUndefined(h) ? h * 1000 * 60 * 60 : 0
1413-
const minute = !isUndefined(m) ? m * 1000 * 60 : 0
1414-
const total = day + hour + minute
1415-
1416-
let count = 0
1417-
1418-
startCallback()
1419-
const intervalId = setInterval(startCallback, total)
1420-
1421-
function startCallback() {
1422-
if (logConfig.start) {
1423-
log(
1424-
`${whiteBold(serialNumber)} | ${logStart(
1425-
`Start polling - count: ${++count}`
1426-
)}`
1427-
)
1428-
}
1429-
1430-
callback(count, stopPolling)
1431-
}
1432-
1433-
function stopPolling() {
1434-
clearInterval(intervalId)
1435-
1436-
if (logConfig.result) {
1437-
log(`${whiteBold(serialNumber)} | ${logWarn('Stop the polling')}`)
1438-
}
1439-
}
1440-
}
1441-
}

src/index.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ import {
22
createCrawlData,
33
createCrawlFile,
44
createCrawlHTML,
5-
createCrawlPage,
6-
createStartPolling
5+
createCrawlPage
76
} from './api'
87

98
import { XCrawlConfig, XCrawlInstance, XCrawlInstanceConfig } from './types'
@@ -67,8 +66,7 @@ function createnInstance(
6766
crawlPage: createCrawlPage(xCrawlInstanceConfig),
6867
crawlHTML: createCrawlHTML(xCrawlInstanceConfig),
6968
crawlData: createCrawlData(xCrawlInstanceConfig),
70-
crawlFile: createCrawlFile(xCrawlInstanceConfig),
71-
startPolling: createStartPolling(xCrawlInstanceConfig)
69+
crawlFile: createCrawlFile(xCrawlInstanceConfig)
7270
}
7371

7472
return instance

src/types/api.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,6 @@ export interface CrawlFileAdvancedConfig extends CrawlCommonConfig {
181181
}) => Promise<Buffer>
182182
}
183183

184-
export interface StartPollingConfig {
185-
d?: number
186-
h?: number
187-
m?: number
188-
}
189-
190184
/* API Result */
191185
export interface CrawlCommonResult {
192186
id: number

src/types/index.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { PuppeteerLaunchOptions } from 'puppeteer'
22
import {
3-
StartPollingConfig,
43
IntervalTime,
54
CrawlPageSingleResult,
65
CrawlDataSingleResult,
@@ -129,9 +128,4 @@ export interface XCrawlInstance {
129128
callback?: (result: CrawlFileSingleResult[]) => void
130129
): Promise<CrawlFileSingleResult[]>
131130
}
132-
133-
startPolling: (
134-
config: StartPollingConfig,
135-
callback: (count: number, stopPolling: () => void) => void
136-
) => void
137131
}

test/environment/api/startPolling.test.ts

Lines changed: 0 additions & 33 deletions
This file was deleted.

test/environment/test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,3 @@ import './api/crawlPage.test'
1313
import './api/crawlHTML.test'
1414
import './api/crawlData.test'
1515
import './api/crawlFile.test'
16-
import './api/startPolling.test'

0 commit comments

Comments
 (0)