unprint 0.4.1 → 0.4.2

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/README.md CHANGED
@@ -74,7 +74,12 @@ Options
74
74
  Returns
75
75
  ```javascript
76
76
  {
77
- query, // (object) unprint querying methods
77
+ context: { // using select or no option
78
+ query, // (object) unprint querying methods
79
+ },
80
+ context: [{ // using selectAll
81
+ query,
82
+ }],
78
83
  html, // (string) HTML body
79
84
  data, // (object) parsed JSON response
80
85
  status, // (number) HTTP status code
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "unprint",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "Simplify common web scraping tasks while staying in control of the data.",
5
5
  "main": "src/app.js",
6
6
  "scripts": {
package/src/app.js CHANGED
@@ -508,7 +508,7 @@ function initAll(context, selector, options) {
508
508
  return initAll(window.document, selector, { ...options, window });
509
509
  }
510
510
 
511
- if (!(context instanceof globalWindow.HTMLElement)) {
511
+ if (!isDomObject(context)) {
512
512
  // the context is not a valid
513
513
  return handleError(new Error('Init context is not a DOM element, HTML or an array'), 'INVALID_CONTEXT');
514
514
  }
package/tests/init.js CHANGED
@@ -12,7 +12,8 @@ const port = process.env.PORT || 3101;
12
12
  async function initTest() {
13
13
  unprint.options({ headers: { 'user-agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36' } });
14
14
 
15
- const res = await unprint.get(`http://127.0.0.1:${port}/html`, { select: 'body' });
15
+ const res = await unprint.get(`http://127.0.0.1:${port}/html`, { selectAll: 'body' });
16
+
16
17
  // const jsonRes = await unprint.get(`http://127.0.0.1:${port}/json`);
17
18
  // const errorRes = await unprint.get(`http://127.0.0.1:${port}/error/404`);
18
19