unprint 0.11.7 → 0.11.8
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/package.json +1 -1
- package/src/app.js +10 -17
package/package.json
CHANGED
package/src/app.js
CHANGED
|
@@ -200,11 +200,18 @@ function queryDatasets(context, selector, dataAttribute, customOptions) {
|
|
|
200
200
|
|
|
201
201
|
const defaultNumberRegexp = /\d+([.,]\d+)?/;
|
|
202
202
|
|
|
203
|
-
function extractNumber(rawNumberString,
|
|
203
|
+
function extractNumber(rawNumberString, customOptions) {
|
|
204
204
|
if (!rawNumberString) {
|
|
205
205
|
return null;
|
|
206
206
|
}
|
|
207
207
|
|
|
208
|
+
const options = {
|
|
209
|
+
match: defaultNumberRegexp,
|
|
210
|
+
matchIndex: 0,
|
|
211
|
+
separator: '.',
|
|
212
|
+
...customOptions,
|
|
213
|
+
};
|
|
214
|
+
|
|
208
215
|
const numberString = options.separator === ','
|
|
209
216
|
? rawNumberString.replace(',', '.')
|
|
210
217
|
: rawNumberString.replace(',', '');
|
|
@@ -223,32 +230,18 @@ function extractNumber(rawNumberString, options) {
|
|
|
223
230
|
function queryNumber(context, selector, customOptions) {
|
|
224
231
|
const numberString = queryContent(context, selector, customOptions);
|
|
225
232
|
|
|
226
|
-
|
|
227
|
-
match: defaultNumberRegexp,
|
|
228
|
-
matchIndex: 0,
|
|
229
|
-
separator: '.',
|
|
230
|
-
...customOptions,
|
|
231
|
-
};
|
|
232
|
-
|
|
233
|
-
return extractNumber(numberString, options);
|
|
233
|
+
return extractNumber(numberString, customOptions);
|
|
234
234
|
}
|
|
235
235
|
|
|
236
236
|
function queryNumbers(context, selector, customOptions) {
|
|
237
237
|
const numberStrings = queryContents(context, selector, customOptions);
|
|
238
238
|
|
|
239
|
-
const options = {
|
|
240
|
-
match: defaultNumberRegexp,
|
|
241
|
-
matchIndex: 0,
|
|
242
|
-
separator: '.',
|
|
243
|
-
...customOptions,
|
|
244
|
-
};
|
|
245
|
-
|
|
246
239
|
if (!numberStrings) {
|
|
247
240
|
return null;
|
|
248
241
|
}
|
|
249
242
|
|
|
250
243
|
return numberStrings
|
|
251
|
-
.map((numberString) => extractNumber(numberString,
|
|
244
|
+
.map((numberString) => extractNumber(numberString, customOptions))
|
|
252
245
|
.filter(Boolean);
|
|
253
246
|
}
|
|
254
247
|
|