Skip to content

Commit 4a3c5c9

Browse files
authored
Merge pull request #737 from microlinkhq/profiling
feat: add profiling support
2 parents 522b1bc + e88d2b1 commit 4a3c5c9

File tree

88 files changed

+428
-161
lines changed

Some content is hidden

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

88 files changed

+428
-161
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
# [5.46.0-beta.0](https://github.com/microlinkhq/metascraper/compare/v5.45.29...v5.46.0-beta.0) (2025-01-10)
7+
8+
### Bug Fixes
9+
10+
* load dependency ([6344788](https://github.com/microlinkhq/metascraper/commit/6344788ddbfc27a03f3ce12b2a842cd438574cc5))
11+
12+
### Features
13+
14+
* add profiling support ([9370e3c](https://github.com/microlinkhq/metascraper/commit/9370e3cdde056e86dcc2d189b3b22dd01a310372))
15+
616
## [5.45.29](https://github.com/microlinkhq/metascraper/compare/v5.45.28...v5.45.29) (2025-01-07)
717

818
### Bug Fixes

CONTRIBUTING.md

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ A set of rules under the same namespace runs in series and only the value return
4242
You can associate a `test` function with your rule bundle:
4343

4444
```js
45-
rules.test = ({ url }) => getVideoInfo(url).service === 'youtube'))
45+
rules.test = ({ url }) => getVideoInfo(url).service === 'youtube'
4646
```
4747

4848
The `test` function will receive the same arguments as a rule. This is useful for skipping all rules that doesn't target a specific URL.
@@ -52,12 +52,31 @@ A good practice is to use a memoize function to prevent unnecessary CPU cycles f
5252
```js
5353
const { memoizeOne } = require('@metascraper/helpers')
5454

55-
const test = memoizeOne(url => getVideoInfo(url).service === 'youtube'))
55+
const test = memoizeOne(url => getVideoInfo(url).service === 'youtube')
5656

5757
const rules = []
58-
rules.test ({ url }) => test(url)
58+
rules.test = ({ url }) => test(url)
5959
```
6060

61+
### Defining `pkgName` property
62+
63+
Additionally you can define `pkgName` property associated with your rules:
64+
65+
```js
66+
const { memoizeOne } = require('@metascraper/helpers')
67+
68+
const rules = []
69+
rules.pkgName = 'metascraper-module'
70+
```
71+
72+
This is using for printing debug logs, see debugging section to know how to use it.
73+
74+
## Debugging your Rules
75+
76+
In case you need to see what's happening under the hood, you can set `DEBUG='metascraper*'.
77+
78+
This is useful for verifying rule precedence and detecting slow rules.
79+
6180
## Testing your Rules
6281

6382
Since the order of the rules is important, testing it is also an important thing in order to be sure more popular rules are executed first over less popular rules.
@@ -74,7 +93,6 @@ const metascraper = require('metascraper')([
7493
require('metascraper-logo')()
7594
])
7695

77-
7896
describe('metascraper-logo', () => {
7997
it('creates an absolute favicon url if the logo is not present', async () => {
8098
const html = `
@@ -92,8 +110,8 @@ describe('metascraper-logo', () => {
92110
</body>
93111
</html>
94112
`
95-
const meta = await metascraper({ html, url }))
96-
should(meta.log).be.equal("open graph value")
113+
const meta = await metascraper({ html, url })
114+
should(meta.log).be.equal('open graph value')
97115
})
98116
})
99117
```
@@ -129,8 +147,8 @@ const metascraper = require('metascraper')([
129147
describe('metascraper-logo', () => {
130148
it('it resolves logo value', async () => {
131149
const html = fs.readFileSync('index.html', 'utf-8')
132-
const meta = await metascraper({ html, url }))
133-
should(meta.logo).be.equal("https://metascraper.js.org/static/logo.png")
150+
const meta = await metascraper({ html, url })
151+
should(meta.logo).be.equal('https://metascraper.js.org/static/logo.png')
134152
})
135153
})
136154
```

lerna.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"packages": [
33
"packages/*"
44
],
5-
"version": "5.45.29",
5+
"version": "5.46.0-beta.2",
66
"command": {
77
"bootstrap": {
88
"npmClientArgs": [

packages/metascraper-amazon/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
# [5.46.0-beta.0](https://github.com/microlinkhq/metascraper/compare/v5.45.29...v5.46.0-beta.0) (2025-01-10)
7+
8+
**Note:** Version bump only for package metascraper-amazon
9+
610
## [5.45.28](https://github.com/microlinkhq/metascraper/compare/v5.45.27...v5.45.28) (2025-01-01)
711

812
**Note:** Version bump only for package metascraper-amazon

packages/metascraper-amazon/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "metascraper-amazon",
33
"description": "Metascraper integration with Amazon",
44
"homepage": "https://github.com/microlinkhq/metascraper/packages/metascraper-amazon",
5-
"version": "5.45.28",
5+
"version": "5.46.0-beta.2",
66
"types": "src/index.d.ts",
77
"main": "src/index.js",
88
"author": {

packages/metascraper-amazon/src/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,7 @@ module.exports = () => {
6060

6161
rules.test = ({ url }) => test(url)
6262

63+
rules.pkgName = 'metascraper-amazon'
64+
6365
return rules
6466
}

packages/metascraper-audio/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
# [5.46.0-beta.0](https://github.com/microlinkhq/metascraper/compare/v5.45.29...v5.46.0-beta.0) (2025-01-10)
7+
8+
**Note:** Version bump only for package metascraper-audio
9+
610
## [5.45.28](https://github.com/microlinkhq/metascraper/compare/v5.45.27...v5.45.28) (2025-01-01)
711

812
**Note:** Version bump only for package metascraper-audio

packages/metascraper-audio/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "metascraper-audio",
33
"description": "Get audio property from HTML markup",
44
"homepage": "https://github.com/microlinkhq/metascraper/packages/metascraper-audio",
5-
"version": "5.45.28",
5+
"version": "5.46.0-beta.2",
66
"types": "src/index.d.ts",
77
"main": "src/index.js",
88
"author": {

packages/metascraper-audio/src/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ const _getIframe = (url, $, { src }) =>
7878
loadIframe(url, $.load(`<iframe src="${src}"></iframe>`))
7979

8080
module.exports = ({ getIframe = _getIframe } = {}) => {
81-
return {
81+
const rules = {
8282
audio: audioRules.concat(
8383
async ({ htmlDom: $, url }) => {
8484
const srcs = [
@@ -110,4 +110,8 @@ module.exports = ({ getIframe = _getIframe } = {}) => {
110110
}
111111
)
112112
}
113+
114+
rules.pkgName = 'metascraper-audio'
115+
116+
return rules
113117
}

packages/metascraper-author/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
# [5.46.0-beta.0](https://github.com/microlinkhq/metascraper/packages/metascraper-author/compare/v5.45.29...v5.46.0-beta.0) (2025-01-10)
7+
8+
**Note:** Version bump only for package metascraper-author
9+
610
## [5.45.28](https://github.com/microlinkhq/metascraper/packages/metascraper-author/compare/v5.45.27...v5.45.28) (2025-01-01)
711

812
**Note:** Version bump only for package metascraper-author

0 commit comments

Comments
 (0)