@bccampus/utils 0.2.0 → 0.2.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.
Files changed (59) hide show
  1. package/dist/array/chunk.cjs +9 -0
  2. package/dist/array/index.cjs +4 -0
  3. package/dist/date/index.cjs +8 -0
  4. package/dist/date/iso-date-time.cjs +256 -0
  5. package/dist/duration/add-durations.cjs +12 -0
  6. package/dist/duration/index.cjs +8 -0
  7. package/dist/duration/is-duration.cjs +7 -0
  8. package/dist/duration/to-number.cjs +14 -0
  9. package/dist/format/formatter.cjs +40 -0
  10. package/dist/format/index.cjs +13 -0
  11. package/dist/format/stringify.cjs +42 -0
  12. package/dist/format/template.cjs +35 -0
  13. package/dist/index.cjs +4 -0
  14. package/dist/index.d.ts +1 -0
  15. package/dist/index.js +4 -0
  16. package/dist/object/get.cjs +7 -0
  17. package/dist/object/index.cjs +12 -0
  18. package/dist/object/is-object.cjs +4 -0
  19. package/dist/object/omit.cjs +18 -0
  20. package/dist/object/pick.cjs +11 -0
  21. package/dist/object/set.cjs +14 -0
  22. package/dist/path/file-url-to-path.cjs +10 -0
  23. package/dist/path/index.cjs +6 -0
  24. package/dist/path/normalize.cjs +32 -0
  25. package/dist/set/difference.cjs +10 -0
  26. package/dist/set/index.cjs +12 -0
  27. package/dist/set/intersection.cjs +13 -0
  28. package/dist/set/is-superset.cjs +12 -0
  29. package/dist/set/symmetric-difference.cjs +14 -0
  30. package/dist/set/union.cjs +10 -0
  31. package/dist/string/capitalize.cjs +4 -0
  32. package/dist/string/index.cjs +14 -0
  33. package/dist/string/normalize.cjs +6 -0
  34. package/dist/string/pluralize/index.cjs +6 -0
  35. package/dist/string/pluralize/pluralize.cjs +210 -0
  36. package/dist/string/pluralize/rules/index.cjs +10 -0
  37. package/dist/string/pluralize/rules/irregular.cjs +62 -0
  38. package/dist/string/pluralize/rules/pluralization.cjs +39 -0
  39. package/dist/string/pluralize/rules/singularization.cjs +47 -0
  40. package/dist/string/pluralize/rules/uncountable.cjs +113 -0
  41. package/dist/string/pluralize/types.cjs +1 -0
  42. package/dist/string/slugify/index.cjs +2263 -0
  43. package/dist/string/strip-html-tags.cjs +7 -0
  44. package/dist/string/to-int.cjs +10 -0
  45. package/dist/string/to-sentence-case.cjs +8 -0
  46. package/dist/string/trim.cjs +11 -0
  47. package/dist/string/truncate.cjs +20 -0
  48. package/dist/value/index.cjs +4 -0
  49. package/dist/value/index.d.ts +1 -0
  50. package/dist/value/index.js +4 -0
  51. package/dist/value/is-empty.cjs +14 -0
  52. package/dist/value/is-empty.d.ts +17 -0
  53. package/dist/value/is-empty.js +14 -0
  54. package/package.json +31 -11
  55. package/src/format/index.ts +3 -3
  56. package/src/index.ts +1 -0
  57. package/src/value/index.ts +1 -0
  58. package/src/value/is-empty.ts +31 -0
  59. package/vite.config.ts +76 -77
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ function chunk(arr, size = 5) {
4
+ const chunks = [];
5
+ for (let i = 0; i < arr.length; i += size)
6
+ chunks.push(arr.slice(i, i + size));
7
+ return chunks;
8
+ }
9
+ exports.chunk = chunk;
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const array_chunk = require("./chunk.cjs");
4
+ exports.chunk = array_chunk.chunk;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const date_isoDateTime = require("./iso-date-time.cjs");
4
+ exports.DefaultDateFormat = date_isoDateTime.DefaultDateFormat;
5
+ exports.DefaultTimeFormat = date_isoDateTime.DefaultTimeFormat;
6
+ exports.DefaultTimezone = date_isoDateTime.DefaultTimezone;
7
+ exports.ISODateTime = date_isoDateTime.ISODateTime;
8
+ exports.InvalidDate = date_isoDateTime.InvalidDate;
@@ -0,0 +1,256 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const isoDateTimeRegEx = new RegExp("^([0-9-]+)(T([0-9:.,]+)(Z|[+-]([0-9:]+))?)?$");
4
+ const dateRegEx = new RegExp("^(\\d{4})-?(\\d{2})?-?(\\d{2})?$");
5
+ const timeRegEx = new RegExp("^(\\d{2}):?(\\d{2})?:?(\\d{2})?(\\.(\\d{3}))?$");
6
+ const timezoneRegEx = new RegExp("^Z|^[+-]((\\d{2}):?(\\d{2})?)$");
7
+ const InvalidDate = /* @__PURE__ */ Symbol("Invalid Date");
8
+ const DefaultDateFormat = {
9
+ year: "numeric",
10
+ month: "long",
11
+ day: "2-digit"
12
+ };
13
+ const DefaultTimeFormat = {
14
+ hour: "2-digit",
15
+ minute: "2-digit",
16
+ timeZoneName: "short"
17
+ };
18
+ const DefaultTimezone = "America/Vancouver";
19
+ class ISODateTime {
20
+ #parsed;
21
+ #date;
22
+ #string;
23
+ constructor(isoDatetime) {
24
+ if (typeof isoDatetime === "string") {
25
+ this.#parsed = ISODateTime.parse(isoDatetime);
26
+ if (this.#parsed) {
27
+ this.#date = new Date(ISODateTime.toString(this));
28
+ } else {
29
+ this.#date = InvalidDate;
30
+ console.error(`Failed to parse date for value: ${isoDatetime}`);
31
+ }
32
+ } else if (typeof isoDatetime === "number" && Number.isFinite(isoDatetime)) {
33
+ this.#date = new Date(isoDatetime);
34
+ this.#parsed = ISODateTime.parse(this.#date.toISOString());
35
+ } else {
36
+ this.#date = /* @__PURE__ */ new Date();
37
+ this.#parsed = ISODateTime.parse(this.#date.toISOString());
38
+ }
39
+ if (this.#date !== InvalidDate) this.#string = this.#date.toISOString();
40
+ else this.#string = "Invalid Date";
41
+ }
42
+ /**
43
+ * Get date and time components
44
+ */
45
+ get parts() {
46
+ return this.#parsed;
47
+ }
48
+ /**
49
+ * Get timezone
50
+ */
51
+ get timezone() {
52
+ return this.parts?.timezone ?? "UTC";
53
+ }
54
+ /**
55
+ * Parse a string in ISO DateTime format.
56
+ * If the input is valid, returns date and time components;
57
+ * otherwise, returns `undefined`.
58
+ */
59
+ static parse(isoDatetime) {
60
+ const isoDatetimeParts = isoDatetime.match(isoDateTimeRegEx);
61
+ if (isoDatetimeParts) {
62
+ const dateParts = isoDatetimeParts[1] && isoDatetimeParts[1].match(dateRegEx);
63
+ if (!dateParts) return void 0;
64
+ const parsedDateTime = {
65
+ date: { year: dateParts[1], month: dateParts[2], day: dateParts[3] }
66
+ };
67
+ const timeParts = isoDatetimeParts[3] && isoDatetimeParts[3].match(timeRegEx);
68
+ if (timeParts) {
69
+ parsedDateTime.time = {
70
+ hours: timeParts[1],
71
+ minutes: timeParts[2],
72
+ seconds: timeParts[3],
73
+ milliseconds: timeParts[5]
74
+ };
75
+ }
76
+ const tzParts = isoDatetimeParts[4] && isoDatetimeParts[4].match(timezoneRegEx);
77
+ if (tzParts) {
78
+ parsedDateTime.timezone = tzParts[0];
79
+ }
80
+ return parsedDateTime;
81
+ }
82
+ return void 0;
83
+ }
84
+ static getISOString(parts) {
85
+ if (!parts) return "Invalid Date";
86
+ return `${parts.date.year}-${parts.date.month ?? "01"}-${parts.date.day ?? "01"}T${parts.time?.hours ?? "00"}:${parts.time?.minutes ?? "00"}:${parts.time?.seconds ?? "00"}.${parts.time?.milliseconds ?? "000"}${parts.timezone ?? "Z"}`;
87
+ }
88
+ static toString(dateTime) {
89
+ const _p = typeof dateTime === "string" ? ISODateTime.parse(dateTime) : dateTime.parts;
90
+ return ISODateTime.getISOString(_p);
91
+ }
92
+ /**
93
+ * Returns the stored time value in milliseconds since midnight, January 1, 1970 UTC.
94
+ */
95
+ valueOf() {
96
+ if (this.#date === InvalidDate) return Number.NaN;
97
+ return this.#date.valueOf();
98
+ }
99
+ /**
100
+ * Retruns ISO date and time string
101
+ */
102
+ toString() {
103
+ return this.#string;
104
+ }
105
+ /**
106
+ * Retruns Javascript date object
107
+ */
108
+ toDate() {
109
+ return this.#date;
110
+ }
111
+ get [Symbol.toStringTag]() {
112
+ return "ISODateTime";
113
+ }
114
+ [Symbol.toPrimitive](hint) {
115
+ if (hint === "string") return this.toString();
116
+ return this.valueOf();
117
+ }
118
+ toJSON() {
119
+ return this.toString();
120
+ }
121
+ static getFormatter(isoDatetime, config) {
122
+ let _format = {};
123
+ if (config?.customFormat?.dateStyle || config?.customFormat?.timeStyle) {
124
+ _format = {
125
+ dateStyle: config?.customFormat?.dateStyle,
126
+ timeStyle: config?.customFormat?.timeStyle
127
+ };
128
+ } else {
129
+ if (config?.noDate === true && config?.noTime === true) {
130
+ _format = { ...config.customFormat };
131
+ } else if (config?.noDate === true && !config?.noTime) {
132
+ _format = { ...DefaultTimeFormat, ...config.customFormat };
133
+ } else if (config?.noTime === true && !config.noDate) {
134
+ _format = { ...DefaultDateFormat, ...config.customFormat };
135
+ } else {
136
+ _format = { ...DefaultDateFormat, ...DefaultTimeFormat, ...config?.customFormat };
137
+ }
138
+ }
139
+ if (config?.customFormat?.timeZone) _format.timeZone = config.customFormat.timeZone;
140
+ else if (isoDatetime.parts?.time === void 0) _format.timeZone = "UTC";
141
+ else _format.timeZone = DefaultTimezone;
142
+ return new Intl.DateTimeFormat("en", _format);
143
+ }
144
+ static format(isoDatetime, config) {
145
+ const _isoDatetime = typeof isoDatetime === "string" ? new ISODateTime(isoDatetime) : isoDatetime;
146
+ const _date = _isoDatetime.toDate();
147
+ if (_date === InvalidDate) return _isoDatetime.toString();
148
+ const formatter = ISODateTime.getFormatter(_isoDatetime, config);
149
+ return formatter.format(_date);
150
+ }
151
+ static formatRange(startDate, endDate, config) {
152
+ const _startISODateTime = typeof startDate === "string" ? new ISODateTime(startDate) : startDate;
153
+ const _startDate = _startISODateTime.toDate();
154
+ if (_startDate === InvalidDate) return _startISODateTime.toString();
155
+ const _endISODateTime = typeof endDate === "string" ? new ISODateTime(endDate) : endDate;
156
+ const _endDate = _endISODateTime.toDate();
157
+ if (_endDate === InvalidDate) return _endISODateTime.toString();
158
+ if (_startISODateTime.timezone !== _endISODateTime.timezone) throw "Start and end dates in different time zones";
159
+ const formatter = ISODateTime.getFormatter(_startISODateTime, config);
160
+ const formatedRange = formatter.formatRange(_startDate, _endDate).replace(/\s/g, " ");
161
+ return formatedRange.replace(/\s/g, " ");
162
+ }
163
+ /**
164
+ * Returns formated date and time string
165
+ */
166
+ format(config) {
167
+ return ISODateTime.format(this, config);
168
+ }
169
+ /**
170
+ * Adds milliseconds to the date and returns it as a new ISODateTime object
171
+ */
172
+ addMillisecond(milliseconds) {
173
+ return new ISODateTime(this.valueOf() + milliseconds);
174
+ }
175
+ /**
176
+ * Adds seconds to the date and returns it as a new ISODateTime object
177
+ */
178
+ addSecond(seconds) {
179
+ return this.addMillisecond(seconds * 1e3);
180
+ }
181
+ /**
182
+ * Adds minutes to the date and returns it as a new ISODateTime object
183
+ */
184
+ addMinute(minutes) {
185
+ return this.addMillisecond(minutes * 6e4);
186
+ }
187
+ /**
188
+ * Adds hours to the date and returns it as a new ISODateTime object
189
+ */
190
+ addHour(hours) {
191
+ return this.addMillisecond(hours * 36e5);
192
+ }
193
+ /**
194
+ * Adds days to the date and returns it as a new ISODateTime object
195
+ */
196
+ addDay(days) {
197
+ return this.addMillisecond(days * 864e5);
198
+ }
199
+ /**
200
+ * Returns the start of the previous month as a new ISODateTime object
201
+ */
202
+ static getPrevMonthStart(date) {
203
+ if (date.parts) {
204
+ const month = date.parts.date.month ? Number(date.parts.date.month) : 1;
205
+ const prevMonth = month === 1 ? 12 : month - 1;
206
+ const year = month === 1 ? (Number(date.parts.date.year) - 1).toString() : date.parts.date.year;
207
+ const prevParts = {
208
+ date: {
209
+ year,
210
+ month: prevMonth.toString().padStart(2, "0"),
211
+ day: "01"
212
+ },
213
+ timezone: date.parts.timezone
214
+ };
215
+ return new ISODateTime(ISODateTime.getISOString(prevParts));
216
+ }
217
+ return date;
218
+ }
219
+ /**
220
+ * Returns the start of the previous month as a new ISODateTime object
221
+ */
222
+ getPrevMonthStart() {
223
+ return ISODateTime.getPrevMonthStart(this);
224
+ }
225
+ /**
226
+ * Returns the start of the next month as a new ISODateTime object
227
+ */
228
+ static getNextMonthStart(date) {
229
+ if (date.parts) {
230
+ const month = date.parts.date.month ? Number(date.parts.date.month) : 1;
231
+ const nextMonth = month % 12 + 1;
232
+ const year = month === 12 ? (Number(date.parts.date.year) + 1).toString() : date.parts.date.year;
233
+ const nextParts = {
234
+ date: {
235
+ year,
236
+ month: nextMonth.toString().padStart(2, "0"),
237
+ day: "01"
238
+ },
239
+ timezone: date.parts.timezone
240
+ };
241
+ return new ISODateTime(ISODateTime.getISOString(nextParts));
242
+ }
243
+ return date;
244
+ }
245
+ /**
246
+ * Returns the start of the next month as a new ISODateTime object
247
+ */
248
+ getNextMonthStart() {
249
+ return ISODateTime.getNextMonthStart(this);
250
+ }
251
+ }
252
+ exports.DefaultDateFormat = DefaultDateFormat;
253
+ exports.DefaultTimeFormat = DefaultTimeFormat;
254
+ exports.DefaultTimezone = DefaultTimezone;
255
+ exports.ISODateTime = ISODateTime;
256
+ exports.InvalidDate = InvalidDate;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ require("./is-duration.cjs");
4
+ const duration_toNumber = require("./to-number.cjs");
5
+ function addDuration(left, right) {
6
+ const totalDurationInSeconds = duration_toNumber.toNumber(left, "second") + duration_toNumber.toNumber(right, "second");
7
+ const hours = Math.floor(totalDurationInSeconds / 3600).toString().padStart(2, "0");
8
+ const minutes = Math.floor(totalDurationInSeconds % 3600 / 60).toString().padStart(2, "0");
9
+ const seconds = (totalDurationInSeconds % 60).toString().padStart(2, "0");
10
+ return `${hours}:${minutes}:${seconds}`;
11
+ }
12
+ exports.addDuration = addDuration;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const duration_isDuration = require("./is-duration.cjs");
4
+ const duration_toNumber = require("./to-number.cjs");
5
+ const duration_addDurations = require("./add-durations.cjs");
6
+ exports.isDuration = duration_isDuration.isDuration;
7
+ exports.toNumber = duration_toNumber.toNumber;
8
+ exports.addDuration = duration_addDurations.addDuration;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const durationRegExp = /^\d{2}:\d{2}:\d{2}$/;
4
+ function isDuration(duration) {
5
+ return durationRegExp.test(duration);
6
+ }
7
+ exports.isDuration = isDuration;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const duration_isDuration = require("./is-duration.cjs");
4
+ function toNumber(duration, unit = "hour") {
5
+ if (!duration_isDuration.isDuration(duration)) {
6
+ console.error(new Error(`Malformed duration value: ${duration}`));
7
+ return 0;
8
+ }
9
+ const parts = duration.split(":").map((p) => Number(p));
10
+ if (unit === "minute") return parts[0] * 60 + parts[1] + parts[2] / 60;
11
+ if (unit === "second") return parts[0] * 3600 + parts[1] * 60 + parts[2];
12
+ return parts[0] + parts[1] / 60 + parts[2] / 3600;
13
+ }
14
+ exports.toNumber = toNumber;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const dateFormatter = new Intl.DateTimeFormat("en", {
4
+ dateStyle: "full",
5
+ timeStyle: "short",
6
+ timeZone: "America/Vancouver"
7
+ });
8
+ const formatDate = (date) => {
9
+ if (date) return dateFormatter.format(date);
10
+ return "";
11
+ };
12
+ const listFormatter = new Intl.ListFormat("en", {
13
+ style: "long",
14
+ type: "conjunction"
15
+ });
16
+ const formatList = (list) => {
17
+ if (Array.isArray(list)) return listFormatter.format(list);
18
+ return "";
19
+ };
20
+ const numberFormatter = new Intl.NumberFormat("en", {
21
+ maximumFractionDigits: 2
22
+ });
23
+ const formatNumber = (num) => {
24
+ if (num) return numberFormatter.format(num);
25
+ return "";
26
+ };
27
+ const currencyFormatter = new Intl.NumberFormat("en", {
28
+ style: "currency",
29
+ currency: "CAD",
30
+ maximumFractionDigits: 2
31
+ });
32
+ const formatCurrency = (num) => {
33
+ if (num) return currencyFormatter.format(num);
34
+ return "";
35
+ };
36
+ exports.dateFormatter = dateFormatter;
37
+ exports.formatCurrency = formatCurrency;
38
+ exports.formatDate = formatDate;
39
+ exports.formatList = formatList;
40
+ exports.formatNumber = formatNumber;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const format_formatter = require("./formatter.cjs");
4
+ const format_stringify = require("./stringify.cjs");
5
+ const format_template = require("./template.cjs");
6
+ exports.dateFormatter = format_formatter.dateFormatter;
7
+ exports.formatCurrency = format_formatter.formatCurrency;
8
+ exports.formatDate = format_formatter.formatDate;
9
+ exports.formatList = format_formatter.formatList;
10
+ exports.formatNumber = format_formatter.formatNumber;
11
+ exports.stringify = format_stringify.stringify;
12
+ exports.template = format_template.template;
13
+ exports.templateObject = format_template.templateObject;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const format_formatter = require("./formatter.cjs");
4
+ const date_isoDateTime = require("../date/iso-date-time.cjs");
5
+ const stringify = (value, options) => {
6
+ const _options = {
7
+ invalidValueString: "\0",
8
+ // Unicode NUL
9
+ withTypeInfo: options?.verbose,
10
+ prettyObjects: options?.verbose,
11
+ ...options
12
+ };
13
+ if (value === void 0)
14
+ return _options.withTypeInfo ? "[undefined]" : _options.invalidValueString;
15
+ if (value === null)
16
+ return _options.withTypeInfo ? "[null]" : _options.invalidValueString;
17
+ if (typeof value === "string")
18
+ return `${_options.withTypeInfo ? "[string] " : ""}${value}`;
19
+ if (typeof value === "number")
20
+ return `${_options.withTypeInfo ? "[number] " : ""}${format_formatter.formatNumber(value)}`;
21
+ if (typeof value === "bigint")
22
+ return `${_options.withTypeInfo ? "[bigint] " : ""}${value}`;
23
+ if (typeof value === "boolean")
24
+ return `${_options.withTypeInfo ? "[boolean] " : ""}${value}`;
25
+ if (typeof value === "object") {
26
+ if (Array.isArray(value)) {
27
+ const stringfiedValue = value.map((el) => stringify(el, _options));
28
+ return `${_options.withTypeInfo ? "[array] " : ""}${_options.verbose ? stringfiedValue.join(", ") : format_formatter.formatList(stringfiedValue)}`;
29
+ }
30
+ if (value instanceof Date)
31
+ return `${_options.withTypeInfo ? "[date] " : ""}${format_formatter.dateFormatter.format(value)}`;
32
+ if (value instanceof date_isoDateTime.ISODateTime)
33
+ return `${_options.withTypeInfo ? "[date] " : ""}${value.format()}`;
34
+ return `${_options.withTypeInfo ? "[object] " : ""}${JSON.stringify(value, null, _options.prettyObjects ? 2 : void 0)}`;
35
+ }
36
+ if (typeof value === "function")
37
+ return `${_options.withTypeInfo ? "[function] " : ""}${_options.callFunctions && value.length === 0 ? stringify(value(), _options) : value.toString()}`;
38
+ if (typeof value === "symbol")
39
+ return `${_options.withTypeInfo ? "[symbol] " : ""}${value.toString()}`;
40
+ return _options.invalidValueString;
41
+ };
42
+ exports.stringify = stringify;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ require("./formatter.cjs");
4
+ const format_stringify = require("./stringify.cjs");
5
+ const object_get = require("../object/get.cjs");
6
+ const tagRegExp = new RegExp(/\${([a-zA-Z0-9_.]+)}/gm);
7
+ const template = (text, templateVars) => {
8
+ return text.replace(tagRegExp, (match, key) => {
9
+ const templateVar = object_get.get(templateVars, key);
10
+ const value = typeof templateVar === "function" ? templateVar() : templateVar;
11
+ if (value === void 0) return match;
12
+ if (value === null) return "";
13
+ return format_stringify.stringify(value, { invalidValueString: "" });
14
+ });
15
+ };
16
+ const templateObject = (obj, templateVars) => {
17
+ const _objClone = {};
18
+ for (const [key, value] of Object.entries(obj)) {
19
+ const _key = template(key, templateVars);
20
+ if (typeof value === "string") {
21
+ _objClone[_key] = template(value, templateVars);
22
+ } else if (value && typeof value === "object") {
23
+ if (Array.isArray(value))
24
+ _objClone[_key] = value.map(
25
+ (valueItem) => typeof valueItem === "string" ? template(valueItem, templateVars) : valueItem
26
+ );
27
+ else _objClone[_key] = templateObject(value, templateVars);
28
+ } else {
29
+ _objClone[_key] = value;
30
+ }
31
+ }
32
+ return _objClone;
33
+ };
34
+ exports.template = template;
35
+ exports.templateObject = templateObject;
package/dist/index.cjs ADDED
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const USE_SUBPATH_EXPORTS = true;
4
+ exports.USE_SUBPATH_EXPORTS = USE_SUBPATH_EXPORTS;
@@ -0,0 +1 @@
1
+ export declare const USE_SUBPATH_EXPORTS = true;
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ const USE_SUBPATH_EXPORTS = true;
2
+ export {
3
+ USE_SUBPATH_EXPORTS
4
+ };
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const get = (object, prop) => prop.split(".").reduce(
4
+ (reducedObject, key) => reducedObject && key in reducedObject ? reducedObject[key] : void 0,
5
+ object
6
+ );
7
+ exports.get = get;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const object_isObject = require("./is-object.cjs");
4
+ const object_get = require("./get.cjs");
5
+ const object_set = require("./set.cjs");
6
+ const object_omit = require("./omit.cjs");
7
+ const object_pick = require("./pick.cjs");
8
+ exports.isObject = object_isObject.isObject;
9
+ exports.get = object_get.get;
10
+ exports.set = object_set.set;
11
+ exports.omit = object_omit.omit;
12
+ exports.pick = object_pick.pick;
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const isObject = (object) => typeof object === "object" && !Array.isArray(object) && object !== null;
4
+ exports.isObject = isObject;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const omit = (object, props) => {
4
+ const result = { ...object };
5
+ props.forEach((prop) => {
6
+ const propChunks = prop.split(".");
7
+ const lastChunk = propChunks.pop();
8
+ if (lastChunk) {
9
+ const ref = propChunks.reduce(
10
+ (reducedObject, key) => reducedObject && key in reducedObject ? reducedObject[key] : void 0,
11
+ result
12
+ );
13
+ if (ref && lastChunk in ref) delete ref[lastChunk];
14
+ }
15
+ });
16
+ return result;
17
+ };
18
+ exports.omit = omit;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const object_get = require("./get.cjs");
4
+ const object_set = require("./set.cjs");
5
+ const pick = (object, props) => {
6
+ return props.reduce((result, key) => {
7
+ object_set.set(result, key, object_get.get(object, key));
8
+ return result;
9
+ }, {});
10
+ };
11
+ exports.pick = pick;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const set = (object, prop, value) => {
4
+ const propChunks = prop.split(".");
5
+ const lastChunk = propChunks.pop();
6
+ if (!lastChunk) return object;
7
+ const ref = propChunks.reduce((reducedObject, key) => {
8
+ if (reducedObject[key] === void 0) reducedObject[key] = {};
9
+ return reducedObject[key];
10
+ }, object);
11
+ ref[lastChunk] = value;
12
+ return object;
13
+ };
14
+ exports.set = set;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const windowsDriveRegExp = /^\/[a-zA-Z1-9_-]+:\//;
4
+ function fileURLToPath(fileUrl) {
5
+ const url = new URL(fileUrl);
6
+ let path = decodeURIComponent(url.pathname);
7
+ if (windowsDriveRegExp.test(path)) path = path.slice(1);
8
+ return path;
9
+ }
10
+ exports.fileURLToPath = fileURLToPath;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const path_normalize = require("./normalize.cjs");
4
+ const path_fileUrlToPath = require("./file-url-to-path.cjs");
5
+ exports.normalize = path_normalize.normalize;
6
+ exports.fileURLToPath = path_fileUrlToPath.fileURLToPath;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const path_fileUrlToPath = require("./file-url-to-path.cjs");
4
+ const defaultOptions = {
5
+ leadingSlash: "always",
6
+ trailingSlash: "never"
7
+ };
8
+ const windowsPathSepRegExp = /[\\]+/g;
9
+ const unixPathSepRegExp = /[/]+/g;
10
+ const windowsDriveRegExp = /^[a-zA-Z1-9_-]+:\//;
11
+ const fileProtocolRegExp = /^file:\/\//;
12
+ const leadingSlashRegExp = /^\//g;
13
+ const trailingSlashRegExp = /\/$/g;
14
+ function normalize(path, options) {
15
+ const conf = { ...defaultOptions, ...options };
16
+ const sep = "\\";
17
+ let normalPath = path.trim();
18
+ if (fileProtocolRegExp.test(normalPath))
19
+ normalPath = path_fileUrlToPath.fileURLToPath(normalPath);
20
+ normalPath = normalPath.replace(windowsPathSepRegExp, sep).replace(unixPathSepRegExp, sep);
21
+ if (conf.leadingSlash !== "as-is") {
22
+ normalPath = normalPath.replace(leadingSlashRegExp, "");
23
+ if (conf.leadingSlash === "always" && !windowsDriveRegExp.test(normalPath))
24
+ normalPath = `${sep}${normalPath}`;
25
+ }
26
+ if (conf.trailingSlash !== "as-is") {
27
+ normalPath = normalPath.replace(trailingSlashRegExp, "");
28
+ if (conf.trailingSlash === "always") normalPath = `${normalPath}${sep}`;
29
+ }
30
+ return normalPath;
31
+ }
32
+ exports.normalize = normalize;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ function difference(setA, setB) {
4
+ const _difference = new Set(setA);
5
+ for (const elem of setB) {
6
+ _difference.delete(elem);
7
+ }
8
+ return _difference;
9
+ }
10
+ exports.difference = difference;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const set_union = require("./union.cjs");
4
+ const set_intersection = require("./intersection.cjs");
5
+ const set_isSuperset = require("./is-superset.cjs");
6
+ const set_difference = require("./difference.cjs");
7
+ const set_symmetricDifference = require("./symmetric-difference.cjs");
8
+ exports.union = set_union.union;
9
+ exports.intersection = set_intersection.intersection;
10
+ exports.isSuperset = set_isSuperset.isSuperset;
11
+ exports.difference = set_difference.difference;
12
+ exports.symmetricDifference = set_symmetricDifference.symmetricDifference;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ function intersection(setA, setB) {
4
+ const _setA = setA instanceof Set ? setA : new Set(setA);
5
+ const _intersection = /* @__PURE__ */ new Set();
6
+ for (const elem of setB) {
7
+ if (_setA.has(elem)) {
8
+ _intersection.add(elem);
9
+ }
10
+ }
11
+ return _intersection;
12
+ }
13
+ exports.intersection = intersection;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ function isSuperset(set, subset) {
4
+ const _set = set instanceof Set ? set : new Set(set);
5
+ for (const elem of subset) {
6
+ if (!_set.has(elem)) {
7
+ return false;
8
+ }
9
+ }
10
+ return true;
11
+ }
12
+ exports.isSuperset = isSuperset;