@drawbridge/drawbridge-utils 0.0.1 → 0.0.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/dist/index.d.mts CHANGED
@@ -54,6 +54,7 @@ const formatCurrency = ({
54
54
  const formatDateString = ({
55
55
  date,
56
56
  locale,
57
+ time = false,
57
58
  options = {
58
59
  day : 'numeric',
59
60
  month : 'long',
@@ -62,9 +63,13 @@ const formatDateString = ({
62
63
  }
63
64
  }) => {
64
65
 
65
- return new Date( date ).toLocaleDateString(
66
+ const resolved = time
67
+ ? { ...options, hour : 'numeric', minute : '2-digit' }
68
+ : options;
69
+
70
+ return new Date( date ).toLocaleString(
66
71
  locale,
67
- options
72
+ resolved
68
73
  );
69
74
 
70
75
  };
@@ -95,8 +100,9 @@ const getPlanFeature = ( plan, key ) => {
95
100
  };
96
101
 
97
102
  const regex = {
98
- url : /^(https:\/\/)/,
99
- protocols : /^(https?:\/\/)?(www\.)?/
103
+ domain : /^([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}$/,
104
+ protocols : /^(https?:\/\/)?(www\.)?/,
105
+ url : /^(https:\/\/)/
100
106
  };
101
107
 
102
108
  const shareUrls = ({
package/dist/index.d.ts CHANGED
@@ -54,6 +54,7 @@ const formatCurrency = ({
54
54
  const formatDateString = ({
55
55
  date,
56
56
  locale,
57
+ time = false,
57
58
  options = {
58
59
  day : 'numeric',
59
60
  month : 'long',
@@ -62,9 +63,13 @@ const formatDateString = ({
62
63
  }
63
64
  }) => {
64
65
 
65
- return new Date( date ).toLocaleDateString(
66
+ const resolved = time
67
+ ? { ...options, hour : 'numeric', minute : '2-digit' }
68
+ : options;
69
+
70
+ return new Date( date ).toLocaleString(
66
71
  locale,
67
- options
72
+ resolved
68
73
  );
69
74
 
70
75
  };
@@ -95,8 +100,9 @@ const getPlanFeature = ( plan, key ) => {
95
100
  };
96
101
 
97
102
  const regex = {
98
- url : /^(https:\/\/)/,
99
- protocols : /^(https?:\/\/)?(www\.)?/
103
+ domain : /^([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}$/,
104
+ protocols : /^(https?:\/\/)?(www\.)?/,
105
+ url : /^(https:\/\/)/
100
106
  };
101
107
 
102
108
  const shareUrls = ({
package/dist/index.js CHANGED
@@ -36,6 +36,7 @@ var formatCurrency = ({
36
36
  var formatDateString = ({
37
37
  date,
38
38
  locale,
39
+ time = false,
39
40
  options = {
40
41
  day: "numeric",
41
42
  month: "long",
@@ -43,9 +44,10 @@ var formatDateString = ({
43
44
  year: "numeric"
44
45
  }
45
46
  }) => {
46
- return new Date(date).toLocaleDateString(
47
+ const resolved = time ? { ...options, hour: "numeric", minute: "2-digit" } : options;
48
+ return new Date(date).toLocaleString(
47
49
  locale,
48
- options
50
+ resolved
49
51
  );
50
52
  };
51
53
  var formatNumber = (number, digits = 0) => {
@@ -65,8 +67,9 @@ var getPlanFeature = (plan, key) => {
65
67
  };
66
68
  };
67
69
  var regex = {
68
- url: /^(https:\/\/)/,
69
- protocols: /^(https?:\/\/)?(www\.)?/
70
+ domain: /^([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}$/,
71
+ protocols: /^(https?:\/\/)?(www\.)?/,
72
+ url: /^(https:\/\/)/
70
73
  };
71
74
  var shareUrls = ({
72
75
  formUri,
package/dist/index.mjs CHANGED
@@ -43,6 +43,7 @@ var require_index = __commonJS({
43
43
  var formatDateString = ({
44
44
  date,
45
45
  locale,
46
+ time = false,
46
47
  options = {
47
48
  day: "numeric",
48
49
  month: "long",
@@ -50,9 +51,10 @@ var require_index = __commonJS({
50
51
  year: "numeric"
51
52
  }
52
53
  }) => {
53
- return new Date(date).toLocaleDateString(
54
+ const resolved = time ? { ...options, hour: "numeric", minute: "2-digit" } : options;
55
+ return new Date(date).toLocaleString(
54
56
  locale,
55
- options
57
+ resolved
56
58
  );
57
59
  };
58
60
  var formatNumber = (number, digits = 0) => {
@@ -72,8 +74,9 @@ var require_index = __commonJS({
72
74
  };
73
75
  };
74
76
  var regex = {
75
- url: /^(https:\/\/)/,
76
- protocols: /^(https?:\/\/)?(www\.)?/
77
+ domain: /^([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}$/,
78
+ protocols: /^(https?:\/\/)?(www\.)?/,
79
+ url: /^(https:\/\/)/
77
80
  };
78
81
  var shareUrls = ({
79
82
  formUri,
package/package.json CHANGED
@@ -24,5 +24,5 @@
24
24
  "build": "tsup ./index.js && npm publish"
25
25
  },
26
26
  "types": "dist/index.d.ts",
27
- "version": "0.0.1"
27
+ "version": "0.0.2"
28
28
  }