@crawlee/utils 3.13.9-beta.3 → 3.13.9-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +1 -0
- package/index.d.ts.map +1 -1
- package/index.js +1 -0
- package/index.js.map +1 -1
- package/index.mjs +5 -0
- package/internals/iterables.d.ts +108 -0
- package/internals/iterables.d.ts.map +1 -0
- package/internals/iterables.js +174 -0
- package/internals/iterables.js.map +1 -0
- package/package.json +3 -3
package/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export * as social from './internals/social';
|
|
|
9
9
|
export * from './internals/typedefs';
|
|
10
10
|
export * from './internals/open_graph_parser';
|
|
11
11
|
export * from './internals/gotScraping';
|
|
12
|
+
export * from './internals/iterables';
|
|
12
13
|
export * from './internals/robots';
|
|
13
14
|
export * from './internals/sitemap';
|
|
14
15
|
export * from './internals/url';
|
package/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,OAAO,KAAK,MAAM,MAAM,oBAAoB,CAAC;AAC7C,cAAc,sBAAsB,CAAC;AACrC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAEhC,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAEvE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,OAAO,KAAK,MAAM,MAAM,oBAAoB,CAAC;AAC7C,cAAc,sBAAsB,CAAC;AACrC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAEhC,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAEvE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC"}
|
package/index.js
CHANGED
|
@@ -13,6 +13,7 @@ exports.social = tslib_1.__importStar(require("./internals/social"));
|
|
|
13
13
|
tslib_1.__exportStar(require("./internals/typedefs"), exports);
|
|
14
14
|
tslib_1.__exportStar(require("./internals/open_graph_parser"), exports);
|
|
15
15
|
tslib_1.__exportStar(require("./internals/gotScraping"), exports);
|
|
16
|
+
tslib_1.__exportStar(require("./internals/iterables"), exports);
|
|
16
17
|
tslib_1.__exportStar(require("./internals/robots"), exports);
|
|
17
18
|
tslib_1.__exportStar(require("./internals/sitemap"), exports);
|
|
18
19
|
tslib_1.__exportStar(require("./internals/url"), exports);
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAA,8DAAoC;AACpC,8DAAoC;AACpC,4DAAkC;AAClC,mEAAyC;AACzC,8DAAoC;AACpC,kEAAwC;AACxC,4DAAkC;AAClC,qEAA6C;AAC7C,+DAAqC;AACrC,wEAA8C;AAC9C,kEAAwC;AACxC,6DAAmC;AACnC,8DAAoC;AACpC,0DAAgC;AAEhC,8DAAyE;AAAhE,gHAAA,oBAAoB,OAAA;AAC7B,oEAAuE;AAA9D,8GAAA,eAAe,OAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAA,8DAAoC;AACpC,8DAAoC;AACpC,4DAAkC;AAClC,mEAAyC;AACzC,8DAAoC;AACpC,kEAAwC;AACxC,4DAAkC;AAClC,qEAA6C;AAC7C,+DAAqC;AACrC,wEAA8C;AAC9C,kEAAwC;AACxC,gEAAsC;AACtC,6DAAmC;AACnC,8DAAoC;AACpC,0DAAgC;AAEhC,8DAAyE;AAAhE,gHAAA,oBAAoB,OAAA;AAC7B,oEAAuE;AAA9D,8GAAA,eAAe,OAAA"}
|
package/index.mjs
CHANGED
|
@@ -10,7 +10,9 @@ export const Sitemap = mod.Sitemap;
|
|
|
10
10
|
export const URL_NO_COMMAS_REGEX = mod.URL_NO_COMMAS_REGEX;
|
|
11
11
|
export const URL_WITH_COMMAS_REGEX = mod.URL_WITH_COMMAS_REGEX;
|
|
12
12
|
export const applySearchParams = mod.applySearchParams;
|
|
13
|
+
export const asyncifyIterable = mod.asyncifyIterable;
|
|
13
14
|
export const chunk = mod.chunk;
|
|
15
|
+
export const chunkedAsyncIterable = mod.chunkedAsyncIterable;
|
|
14
16
|
export const createRequestDebugInfo = mod.createRequestDebugInfo;
|
|
15
17
|
export const downloadListOfUrls = mod.downloadListOfUrls;
|
|
16
18
|
export const entries = mod.entries;
|
|
@@ -23,12 +25,15 @@ export const getMemoryInfo = mod.getMemoryInfo;
|
|
|
23
25
|
export const getMemoryInfoV2 = mod.getMemoryInfoV2;
|
|
24
26
|
export const gotScraping = mod.gotScraping;
|
|
25
27
|
export const htmlToText = mod.htmlToText;
|
|
28
|
+
export const isAsyncIterable = mod.isAsyncIterable;
|
|
26
29
|
export const isContainerized = mod.isContainerized;
|
|
27
30
|
export const isDocker = mod.isDocker;
|
|
31
|
+
export const isIterable = mod.isIterable;
|
|
28
32
|
export const isLambda = mod.isLambda;
|
|
29
33
|
export const keys = mod.keys;
|
|
30
34
|
export const parseOpenGraph = mod.parseOpenGraph;
|
|
31
35
|
export const parseSitemap = mod.parseSitemap;
|
|
36
|
+
export const peekableAsyncIterable = mod.peekableAsyncIterable;
|
|
32
37
|
export const sleep = mod.sleep;
|
|
33
38
|
export const snakeCaseToCamelCase = mod.snakeCaseToCamelCase;
|
|
34
39
|
export const social = mod.social;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type guard that checks if a value is iterable (has Symbol.iterator).
|
|
3
|
+
* @internal
|
|
4
|
+
*
|
|
5
|
+
* **Example usage:**
|
|
6
|
+
* ```ts
|
|
7
|
+
* if (isIterable(someValue)) {
|
|
8
|
+
* for (const item of someValue) {
|
|
9
|
+
* console.log(item);
|
|
10
|
+
* }
|
|
11
|
+
* }
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export declare function isIterable<T>(value: unknown): value is Iterable<T>;
|
|
15
|
+
/**
|
|
16
|
+
* Type guard that checks if a value is async iterable (has Symbol.asyncIterator).
|
|
17
|
+
* @internal
|
|
18
|
+
*
|
|
19
|
+
* **Example usage:**
|
|
20
|
+
* ```ts
|
|
21
|
+
* if (isAsyncIterable(someValue)) {
|
|
22
|
+
* for await (const item of someValue) {
|
|
23
|
+
* console.log(item);
|
|
24
|
+
* }
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare function isAsyncIterable<T>(value: unknown): value is AsyncIterable<T>;
|
|
29
|
+
/**
|
|
30
|
+
* Converts any iterable or async iterable to an async iterable.
|
|
31
|
+
* @internal
|
|
32
|
+
*
|
|
33
|
+
* @yields Each item from the input iterable
|
|
34
|
+
*
|
|
35
|
+
* **Example usage:**
|
|
36
|
+
* ```ts
|
|
37
|
+
* const syncArray = [1, 2, 3];
|
|
38
|
+
* for await (const item of asyncifyIterable(syncArray)) {
|
|
39
|
+
* console.log(item); // 1, 2, 3
|
|
40
|
+
* }
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export declare function asyncifyIterable<T>(iterable: Iterable<T> | AsyncIterable<T>): AsyncIterable<T>;
|
|
44
|
+
/**
|
|
45
|
+
* Lazily splits the input async iterable into chunks of specified size.
|
|
46
|
+
* The last chunk may contain fewer items if the total number of items
|
|
47
|
+
* is not evenly divisible by the chunk size.
|
|
48
|
+
* @internal
|
|
49
|
+
*
|
|
50
|
+
* @yields Arrays of items, each containing up to chunkSize items
|
|
51
|
+
*
|
|
52
|
+
* **Example usage:**
|
|
53
|
+
* ```ts
|
|
54
|
+
* const numbers = async function* () {
|
|
55
|
+
* for (let i = 1; i <= 10; i++) yield i;
|
|
56
|
+
* };
|
|
57
|
+
*
|
|
58
|
+
* for await (const chunk of chunkedAsyncIterable(numbers(), 3)) {
|
|
59
|
+
* console.log(chunk); // [1, 2, 3], [4, 5, 6], [7, 8, 9], [10]
|
|
60
|
+
* }
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
export declare function chunkedAsyncIterable<T>(iterable: AsyncIterable<T> | Iterable<T>, chunkSize: number): AsyncIterable<T[]>;
|
|
64
|
+
/**
|
|
65
|
+
* An async iterator that also supports peeking at the next value without consuming it.
|
|
66
|
+
* Extends both AsyncIterator and AsyncIterable interfaces.
|
|
67
|
+
* @internal
|
|
68
|
+
*/
|
|
69
|
+
export interface PeekableAsyncIterator<T> extends AsyncIterator<T>, AsyncIterable<T> {
|
|
70
|
+
/**
|
|
71
|
+
* Peeks at the next value without consuming it from the iterator.
|
|
72
|
+
* Subsequent calls to peek() will return the same value until next() is called.
|
|
73
|
+
*
|
|
74
|
+
* @returns Promise that resolves to the next value, or undefined if the iterator is exhausted
|
|
75
|
+
*/
|
|
76
|
+
peek(): Promise<T | undefined>;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* An async iterable that yields peekable async iterators.
|
|
80
|
+
* @internal
|
|
81
|
+
*/
|
|
82
|
+
export interface PeekableAsyncIterable<T> extends AsyncIterable<T> {
|
|
83
|
+
[Symbol.asyncIterator](): PeekableAsyncIterator<T>;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Wraps an async iterable to provide peek functionality, allowing you to look at
|
|
87
|
+
* the next value without consuming it from the iterator.
|
|
88
|
+
* @internal
|
|
89
|
+
*
|
|
90
|
+
* @param iterable - The async iterable to make peekable
|
|
91
|
+
*
|
|
92
|
+
* **Example usage:**
|
|
93
|
+
* ```ts
|
|
94
|
+
* const numbers = async function* () {
|
|
95
|
+
* yield 1; yield 2; yield 3;
|
|
96
|
+
* };
|
|
97
|
+
*
|
|
98
|
+
* const peekable = peekableAsyncIterable(numbers());
|
|
99
|
+
* const iterator = peekable[Symbol.asyncIterator]();
|
|
100
|
+
*
|
|
101
|
+
* console.log(await iterator.peek()); // 1 (doesn't consume)
|
|
102
|
+
* console.log(await iterator.peek()); // 1 (still doesn't consume)
|
|
103
|
+
* console.log(await iterator.next()); // { value: 1, done: false } (now consumed)
|
|
104
|
+
* console.log(await iterator.peek()); // 2 (next value)
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
export declare function peekableAsyncIterable<T>(iterable: AsyncIterable<T> | Iterable<T>): PeekableAsyncIterable<T>;
|
|
108
|
+
//# sourceMappingURL=iterables.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iterables.d.ts","sourceRoot":"","sources":["../../src/internals/iterables.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,QAAQ,CAAC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yncIterable;
|
|
5
|
+
exports.asyncifyIterable = asyncifyIterable;
|
|
6
|
+
exports.chunkedAsyncIterable = chunkedAsyncIterable;
|
|
7
|
+
exports.peekableAsyncIterable = peekableAsyncIterable;
|
|
8
|
+
const node_util_1 = require("node:util");
|
|
9
|
+
/**
|
|
10
|
+
* Type guard that checks if a value is iterable (has Symbol.iterator).
|
|
11
|
+
* @internal
|
|
12
|
+
*
|
|
13
|
+
* **Example usage:**
|
|
14
|
+
* ```ts
|
|
15
|
+
* if (isIterable(someValue)) {
|
|
16
|
+
* for (const item of someValue) {
|
|
17
|
+
* console.log(item);
|
|
18
|
+
* }
|
|
19
|
+
* }
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
function isIterable(value) {
|
|
23
|
+
if (value == null || typeof value === 'string' || ArrayBuffer.isView(value)) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
if (Array.isArray(value)) {
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
return typeof Object(value)[Symbol.iterator] === 'function';
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Type guard that checks if a value is async iterable (has Symbol.asyncIterator).
|
|
33
|
+
* @internal
|
|
34
|
+
*
|
|
35
|
+
* **Example usage:**
|
|
36
|
+
* ```ts
|
|
37
|
+
* if (isAsyncIterable(someValue)) {
|
|
38
|
+
* for await (const item of someValue) {
|
|
39
|
+
* console.log(item);
|
|
40
|
+
* }
|
|
41
|
+
* }
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
function isAsyncIterable(value) {
|
|
45
|
+
if (value == null || typeof value === 'string' || ArrayBuffer.isView(value)) {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
return typeof Object(value)[Symbol.asyncIterator] === 'function';
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Converts any iterable or async iterable to an async iterable.
|
|
52
|
+
* @internal
|
|
53
|
+
*
|
|
54
|
+
* @yields Each item from the input iterable
|
|
55
|
+
*
|
|
56
|
+
* **Example usage:**
|
|
57
|
+
* ```ts
|
|
58
|
+
* const syncArray = [1, 2, 3];
|
|
59
|
+
* for await (const item of asyncifyIterable(syncArray)) {
|
|
60
|
+
* console.log(item); // 1, 2, 3
|
|
61
|
+
* }
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
async function* asyncifyIterable(iterable) {
|
|
65
|
+
yield* iterable;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Lazily splits the input async iterable into chunks of specified size.
|
|
69
|
+
* The last chunk may contain fewer items if the total number of items
|
|
70
|
+
* is not evenly divisible by the chunk size.
|
|
71
|
+
* @internal
|
|
72
|
+
*
|
|
73
|
+
* @yields Arrays of items, each containing up to chunkSize items
|
|
74
|
+
*
|
|
75
|
+
* **Example usage:**
|
|
76
|
+
* ```ts
|
|
77
|
+
* const numbers = async function* () {
|
|
78
|
+
* for (let i = 1; i <= 10; i++) yield i;
|
|
79
|
+
* };
|
|
80
|
+
*
|
|
81
|
+
* for await (const chunk of chunkedAsyncIterable(numbers(), 3)) {
|
|
82
|
+
* console.log(chunk); // [1, 2, 3], [4, 5, 6], [7, 8, 9], [10]
|
|
83
|
+
* }
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
async function* chunkedAsyncIterable(iterable, chunkSize) {
|
|
87
|
+
if (typeof chunkSize !== 'number' || chunkSize < 1) {
|
|
88
|
+
throw new Error(`Chunk size must be a positive number (${(0, node_util_1.inspect)(chunkSize)}) received`);
|
|
89
|
+
}
|
|
90
|
+
let chunk = [];
|
|
91
|
+
for await (const item of iterable) {
|
|
92
|
+
chunk.push(item);
|
|
93
|
+
if (chunk.length >= chunkSize) {
|
|
94
|
+
yield chunk;
|
|
95
|
+
chunk = [];
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (chunk.length) {
|
|
99
|
+
yield chunk;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Wraps an async iterable to provide peek functionality, allowing you to look at
|
|
104
|
+
* the next value without consuming it from the iterator.
|
|
105
|
+
* @internal
|
|
106
|
+
*
|
|
107
|
+
* @param iterable - The async iterable to make peekable
|
|
108
|
+
*
|
|
109
|
+
* **Example usage:**
|
|
110
|
+
* ```ts
|
|
111
|
+
* const numbers = async function* () {
|
|
112
|
+
* yield 1; yield 2; yield 3;
|
|
113
|
+
* };
|
|
114
|
+
*
|
|
115
|
+
* const peekable = peekableAsyncIterable(numbers());
|
|
116
|
+
* const iterator = peekable[Symbol.asyncIterator]();
|
|
117
|
+
*
|
|
118
|
+
* console.log(await iterator.peek()); // 1 (doesn't consume)
|
|
119
|
+
* console.log(await iterator.peek()); // 1 (still doesn't consume)
|
|
120
|
+
* console.log(await iterator.next()); // { value: 1, done: false } (now consumed)
|
|
121
|
+
* console.log(await iterator.peek()); // 2 (next value)
|
|
122
|
+
* ```
|
|
123
|
+
*/
|
|
124
|
+
function peekableAsyncIterable(iterable) {
|
|
125
|
+
const iterator = asyncifyIterable(iterable)[Symbol.asyncIterator]();
|
|
126
|
+
let peekedValue;
|
|
127
|
+
let isExhausted = false;
|
|
128
|
+
const peekableIterator = {
|
|
129
|
+
async next() {
|
|
130
|
+
// If we have peeked a value, return it and clear the peek
|
|
131
|
+
if (peekedValue !== undefined) {
|
|
132
|
+
const result = peekedValue;
|
|
133
|
+
peekedValue = undefined;
|
|
134
|
+
if (result.done) {
|
|
135
|
+
isExhausted = true;
|
|
136
|
+
return { done: true, value: undefined };
|
|
137
|
+
}
|
|
138
|
+
return { done: false, value: result.value };
|
|
139
|
+
}
|
|
140
|
+
if (isExhausted) {
|
|
141
|
+
return { done: true, value: undefined };
|
|
142
|
+
}
|
|
143
|
+
const result = await iterator.next();
|
|
144
|
+
if (result.done) {
|
|
145
|
+
isExhausted = true;
|
|
146
|
+
}
|
|
147
|
+
return result;
|
|
148
|
+
},
|
|
149
|
+
async peek() {
|
|
150
|
+
if (peekedValue !== undefined) {
|
|
151
|
+
return peekedValue.done ? undefined : peekedValue.value;
|
|
152
|
+
}
|
|
153
|
+
if (isExhausted) {
|
|
154
|
+
return undefined;
|
|
155
|
+
}
|
|
156
|
+
const result = await iterator.next();
|
|
157
|
+
peekedValue = { done: result.done ?? false, value: result.value };
|
|
158
|
+
if (result.done) {
|
|
159
|
+
isExhausted = true;
|
|
160
|
+
return undefined;
|
|
161
|
+
}
|
|
162
|
+
return result.value;
|
|
163
|
+
},
|
|
164
|
+
[Symbol.asyncIterator]() {
|
|
165
|
+
return this;
|
|
166
|
+
},
|
|
167
|
+
};
|
|
168
|
+
return {
|
|
169
|
+
[Symbol.asyncIterator]() {
|
|
170
|
+
return peekableIterator;
|
|
171
|
+
},
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
//# sourceMappingURL=iterables.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iterables.js","sourceRoot":"","sources":["../../src/internals/iterables.ts"],"names":[],"mappings":";;AAeA,gCAUC;AAeD,0CAMC;AAgBD,4CAEC;AAqBD,oDAsBC;AA+CD,sDA+DC;AAzND,yCAAoC;AAEpC;;;;;;;;;;;;GAYG;AACH,SAAgB,UAAU,CAAI,KAAc;IACxC,IAAI,KAAK,IAAI,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1E,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,OAAO,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,UAAU,CAAC;AAChE,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,SAAgB,eAAe,CAAI,KAAc;IAC7C,IAAI,KAAK,IAAI,IAAI,IAAI,OAAO,KAAK,KAAK,QA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CAAC,KAAK,CAAC;QACxB,CAAC;QAED,CAAC,MAAM,CAAC,aAAa,CAAC;YAClB,OAAO,IAAI,CAAC;QAChB,CAAC;KACJ,CAAC;IAEF,OAAO;QACH,CAAC,MAAM,CAAC,aAAa,CAAC;YAClB,OAAO,gBAAgB,CAAC;QAC5B,CAAC;KACJ,CAAC;AACN,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crawlee/utils",
|
|
3
|
-
"version": "3.13.9-beta.
|
|
3
|
+
"version": "3.13.9-beta.5",
|
|
4
4
|
"description": "A set of shared utilities that can be used by crawlers",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=16.0.0"
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@apify/log": "^2.4.0",
|
|
51
51
|
"@apify/ps-tree": "^1.2.0",
|
|
52
|
-
"@crawlee/types": "3.13.9-beta.
|
|
52
|
+
"@crawlee/types": "3.13.9-beta.5",
|
|
53
53
|
"@types/sax": "^1.2.7",
|
|
54
54
|
"cheerio": "1.0.0-rc.12",
|
|
55
55
|
"file-type": "^20.0.0",
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "44f16b09435cf432acc59845302f9c794ce52d0a"
|
|
74
74
|
}
|