unprint 0.9.3 → 0.9.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/app.js +10 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "unprint",
3
- "version": "0.9.3",
3
+ "version": "0.9.5",
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
@@ -535,6 +535,14 @@ function queryDates(context, selector, format, customOptions) {
535
535
  }));
536
536
  }
537
537
 
538
+ function formatDate(dateValue, format, inputFormat) {
539
+ if (inputFormat) {
540
+ return moment(dateValue, inputFormat).format(format);
541
+ }
542
+
543
+ return moment(dateValue).format(format);
544
+ }
545
+
538
546
  function extractDuration(durationString, match) {
539
547
  const durationMatch = durationString?.match(match || /(\d+:)?\d+:\d+/);
540
548
 
@@ -765,6 +773,7 @@ async function request(url, body, customOptions = {}, method = 'GET') {
765
773
 
766
774
  const contextOptions = {
767
775
  ...defaultOptions,
776
+ ...customOptions,
768
777
  origin: url,
769
778
  };
770
779
 
@@ -798,6 +807,7 @@ module.exports = {
798
807
  extractDate,
799
808
  extractDuration,
800
809
  extractTimestamp,
810
+ formatDate,
801
811
  prefixUrl,
802
812
  options: configure,
803
813
  query: initQueryFns(queryFns),