unprint 0.11.5 → 0.11.7

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/app.js +10 -9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "unprint",
3
- "version": "0.11.5",
3
+ "version": "0.11.7",
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
@@ -31,10 +31,6 @@ function handleError(error, code) {
31
31
  virtualConsole.on('error', (message) => handleError(message, 'JSDOM'));
32
32
  virtualConsole.on('jsdomError', (message) => handleError(message, 'JSDOM'));
33
33
 
34
- const defaultOptions = {
35
- trim: true,
36
- };
37
-
38
34
  let globalOptions = {};
39
35
 
40
36
  function configure(newOptions) {
@@ -154,7 +150,12 @@ function extractContent(element, options) {
154
150
  }
155
151
 
156
152
  function queryContent(context, selector, customOptions) {
157
- const options = { ...context.options, ...customOptions };
153
+ const options = {
154
+ ...context.options,
155
+ trim: true,
156
+ ...customOptions,
157
+ };
158
+
158
159
  const target = queryElement(context, selector, options);
159
160
 
160
161
  return extractContent(target, options);
@@ -199,7 +200,7 @@ function queryDatasets(context, selector, dataAttribute, customOptions) {
199
200
 
200
201
  const defaultNumberRegexp = /\d+([.,]\d+)?/;
201
202
 
202
- function matchNumberString(rawNumberString, options) {
203
+ function extractNumber(rawNumberString, options) {
203
204
  if (!rawNumberString) {
204
205
  return null;
205
206
  }
@@ -229,7 +230,7 @@ function queryNumber(context, selector, customOptions) {
229
230
  ...customOptions,
230
231
  };
231
232
 
232
- return matchNumberString(numberString, options);
233
+ return extractNumber(numberString, options);
233
234
  }
234
235
 
235
236
  function queryNumbers(context, selector, customOptions) {
@@ -247,7 +248,7 @@ function queryNumbers(context, selector, customOptions) {
247
248
  }
248
249
 
249
250
  return numberStrings
250
- .map((numberString) => matchNumberString(numberString, options))
251
+ .map((numberString) => extractNumber(numberString, options))
251
252
  .filter(Boolean);
252
253
  }
253
254
 
@@ -894,7 +895,6 @@ async function request(url, body, customOptions = {}, method = 'GET') {
894
895
  }
895
896
 
896
897
  const contextOptions = {
897
- ...defaultOptions,
898
898
  ...customOptions,
899
899
  origin: url,
900
900
  };
@@ -928,6 +928,7 @@ module.exports = {
928
928
  initAll,
929
929
  extractDate,
930
930
  extractDuration,
931
+ extractNumber,
931
932
  extractTimestamp,
932
933
  formatDate,
933
934
  dateConstants: {