@tempots/std 0.10.7 → 0.12.0

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/number.d.ts CHANGED
@@ -4,98 +4,367 @@ export declare const TOLERANCE = 0.0001;
4
4
  **/
5
5
  export declare const EPSILON = 1e-9;
6
6
  /**
7
- Returns the angular distance between 2 angles.
8
- **/
7
+ * Calculates the minimum difference between two angles in degrees.
8
+ *
9
+ * @param a - The first angle in degrees.
10
+ * @param b - The second angle in degrees.
11
+ * @param turn - The total number of degrees in a full turn. Default is 360.0.
12
+ * @returns The difference between the two angles.
13
+ * @public
14
+ * @example
15
+ * ```ts
16
+ * angleDifference(0, 90) // returns 90
17
+ * angleDifference(90, 0) // returns -90
18
+ * angleDifference(0, 270) // returns -90
19
+ * angleDifference(270, 0) // returns 90
20
+ * ```
21
+ */
9
22
  export declare function angleDifference(a: number, b: number, turn?: number): number;
10
23
  /**
11
- Rounds a number up to the specified number of decimals.
12
- **/
24
+ * Rounds a number up to the specified number of decimals.
25
+ *
26
+ * @param v - The number to round up.
27
+ * @param decimals - The number of decimals to round up to.
28
+ * @returns The rounded up number.
29
+ * @public
30
+ * @example
31
+ * ```ts
32
+ * ceilTo(1.234, 2) // returns 1.24
33
+ * ceilTo(1.234, 1) // returns 1.3
34
+ * ceilTo(1.234, 0) // returns 2
35
+ * ```
36
+ */
13
37
  export declare function ceilTo(v: number, decimals: number): number;
14
38
  /**
15
- `clamp` restricts a value within the specified range.
16
- ```ts
17
- log(clamp(1.3, 0, 1)) // prints 1
18
- log(clamp(0.8, 0, 1)) // prints 0.8
19
- log(clamp(-0.5, 0, 1)) // prints 0.0
20
- ```
21
- **/
39
+ * `clamp` restricts a value within the specified range.
40
+ *
41
+ * @param value - The value to clamp.
42
+ * @param min - The minimum value.
43
+ * @param max - The maximum value.
44
+ * @returns The clamped value.
45
+ * @public
46
+ * @example
47
+ * ```ts
48
+ * clamp(1.3, 0, 1) // returns 1
49
+ * clamp(0.8, 0, 1) // returns 0.8
50
+ * clamp(-0.5, 0, 1) // returns 0.0
51
+ * ```
52
+ **/
22
53
  export declare function clamp(value: number, min: number, max: number): number;
54
+ /**
55
+ * Clamps a number to a specified range and returns an integer value.
56
+ *
57
+ * @param value - The number to clamp.
58
+ * @param min - The minimum value of the range.
59
+ * @param max - The maximum value of the range.
60
+ * @returns The clamped integer value.
61
+ * @public
62
+ * @example
63
+ * ```ts
64
+ * clampInt(5, 0, 10) // returns 5
65
+ * clampInt(15, 0, 10) // returns 10
66
+ * clampInt(-5, 0, 10) // returns 0
67
+ * ```
68
+ **/
23
69
  export declare function clampInt(value: number, min: number, max: number): number;
24
70
  /**
25
- Like clamp but you only pass one argument (`max`) that is used as the upper limit
26
- and the opposite (additive inverse or `-max`) as the lower limit.
27
- **/
71
+ * Like clamp but you only pass one argument (`max`) that is used as the upper limit
72
+ * and the opposite (additive inverse or `-max`) as the lower limit.
73
+ *
74
+ * @param v - The value to clamp.
75
+ * @param max - The maximum value.
76
+ * @returns The clamped value.
77
+ * @public
78
+ * @example
79
+ * ```ts
80
+ * clampSym(5, 10) // returns 5
81
+ * clampSym(15, 10) // returns 10
82
+ * clampSym(-5, 10) // returns -5
83
+ * clampSym(-15, 10) // returns -10
84
+ * ```
85
+ **/
28
86
  export declare function clampSym(v: number, max: number): number;
29
87
  /**
30
- It returns the comparison value (an integer number) between two `float` values.
31
- **/
88
+ * It returns the comparison value (an integer number) between two `float` values.
89
+ *
90
+ * @param a - The first value to compare.
91
+ * @param b - The second value to compare.
92
+ * @returns A number indicating the relative order of the two values.
93
+ * @public
94
+ * @example
95
+ * ```ts
96
+ * compare(5, 10) // returns -1
97
+ * compare(10, 5) // returns 1
98
+ * compare(5, 5) // returns 0
99
+ * ```
100
+ **/
32
101
  export declare function compare(a: number, b: number): number;
33
102
  /**
34
- Rounds a number down to the specified number of decimals.
35
- **/
103
+ * Rounds a number down to the specified number of decimals.
104
+ *
105
+ * @param v - The number to round down.
106
+ * @param decimals - The number of decimals to round down to.
107
+ * @returns The rounded down number.
108
+ * @public
109
+ * @example
110
+ * ```ts
111
+ * floorTo(1.234, 2) // returns 1.23
112
+ * floorTo(1.234, 1) // returns 1.2
113
+ * floorTo(1.234, 0) // returns 1
114
+ * ```
115
+ **/
36
116
  export declare function floorTo(v: number, decimals: number): number;
117
+ /**
118
+ * Converts a number to its hexadecimal representation.
119
+ *
120
+ * @param num - The number to convert.
121
+ * @param length - The desired length of the hexadecimal string. Defaults to 0.
122
+ * @returns The hexadecimal representation of the number.
123
+ * @public
124
+ * @example
125
+ * ```ts
126
+ * toHex(255) // returns 'ff'
127
+ * toHex(255, 4) // returns '00ff'
128
+ * toHex(255, 8) // returns '000000ff'
129
+ * ```
130
+ */
37
131
  export declare function toHex(num: number, length?: number): string;
38
132
  /**
39
- `interpolate` returns a value between `a` and `b` for any value of `t` (normally between 0 and 1).
40
- **/
133
+ * `interpolate` returns a value between `a` and `b` for any value of `t` (normally between 0 and 1).
134
+ *
135
+ * @param a - The first value.
136
+ * @param b - The second value.
137
+ * @param t - The interpolation value.
138
+ * @returns The interpolated value.
139
+ * @public
140
+ * @example
141
+ * ```ts
142
+ * interpolate(0, 10, 0.5) // returns 5
143
+ * interpolate(0, 10, 0.25) // returns 2.5
144
+ * interpolate(0, 10, 0.75) // returns 7.5
145
+ * ```
146
+ **/
41
147
  export declare function interpolate(a: number, b: number, t: number): number;
42
148
  /**
43
- Interpolates values in a polar coordinate system looking for the narrowest delta angle.
44
- It can be either clock-wise or counter-clock-wise.
45
- **/
149
+ * Interpolates values in a polar coordinate system looking for the narrowest delta angle.
150
+ * It can be either clock-wise or counter-clock-wise.
151
+ *
152
+ * @param a - The first angle in degrees.
153
+ * @param b - The second angle in degrees.
154
+ * @param t - The interpolation value.
155
+ * @param turn - The total number of degrees in a full turn. Default is 360.0.
156
+ * @returns The interpolated angle.
157
+ * @public
158
+ * @example
159
+ * ```ts
160
+ * interpolateAngle(0, 90, 0.5) // returns 45
161
+ * interpolateAngle(0, 270, 0.5) // returns 315
162
+ * interpolateAngle(0, 90, 0.25) // returns 22.5
163
+ * interpolateAngle(0, 270, 0.25) // returns 337.5
164
+ * ```
165
+ **/
46
166
  export declare function interpolateAngle(a: number, b: number, t: number, turn?: number): number;
167
+ /**
168
+ * Calculates the widest angle difference between two angles.
169
+ *
170
+ * @param a - The first angle in degrees.
171
+ * @param b - The second angle in degrees.
172
+ * @param turn - The total angle of a full turn. Defaults to 360 degrees.
173
+ * @returns The widest angle difference between `a` and `b`.
174
+ * @public
175
+ * @example
176
+ * ```ts
177
+ * widestAngleDifference(0, 90) // returns 90
178
+ * widestAngleDifference(90, 0) // returns -90
179
+ * widestAngleDifference(0, 270) // returns -90
180
+ * widestAngleDifference(270, 0) // returns 90
181
+ * ```
182
+ */
47
183
  export declare function widestAngleDifference(a: number, b: number, turn?: number): number;
48
184
  /**
49
- Interpolates values in a polar coordinate system looking for the wideset delta angle.
50
- It can be either clock-wise or counter-clock-wise.
51
- **/
185
+ * Interpolates values in a polar coordinate system looking for the wideset delta angle.
186
+ * It can be either clock-wise or counter-clock-wise.
187
+ *
188
+ * @param a - The first angle in degrees.
189
+ * @param b - The second angle in degrees.
190
+ * @param t - The interpolation value.
191
+ * @param turn - The total number of degrees in a full turn. Default is 360.0.
192
+ * @returns The interpolated angle.
193
+ * @public
194
+ * @example
195
+ * ```ts
196
+ * interpolateWidestAngle(0, 90, 0.5) // returns 45
197
+ * interpolateWidestAngle(0, 270, 0.5) // returns 315
198
+ * interpolateWidestAngle(0, 90, 0.25) // returns 22.5
199
+ * interpolateWidestAngle(0, 270, 0.25) // returns 337.5
200
+ * ```
201
+ **/
52
202
  export declare function interpolateWidestAngle(a: number, b: number, t: number, turn?: number): number;
53
203
  /**
54
- Interpolates values in a polar coordinate system always in clock-wise direction.
55
- **/
204
+ * Interpolates values in a polar coordinate system always in clock-wise direction.
205
+ *
206
+ * @param a - The first angle in degrees.
207
+ * @param b - The second angle in degrees.
208
+ * @param t - The interpolation value.
209
+ * @param turn - The total number of degrees in a full turn. Default is 360.0.
210
+ * @returns The interpolated angle.
211
+ * @public
212
+ * @example
213
+ * ```ts
214
+ * interpolateAngleCW(0, 90, 0.5) // returns 45
215
+ * interpolateAngleCW(0, 270, 0.5) // returns 315
216
+ * interpolateAngleCW(0, 90, 0.25) // returns 22.5
217
+ * interpolateAngleCW(0, 270, 0.25) // returns 337.5
218
+ * ```
219
+ **/
56
220
  export declare function interpolateAngleCW(a: number, b: number, t: number, turn?: number): number;
57
221
  /**
58
- Interpolates values in a polar coordinate system always in counter-clock-wise direction.
59
- **/
222
+ * Interpolates values in a polar coordinate system always in counter-clock-wise direction.
223
+ *
224
+ * @param a - The first angle in degrees.
225
+ * @param b - The second angle in degrees.
226
+ * @param t - The interpolation value.
227
+ * @param turn - The total number of degrees in a full turn. Default is 360.0.
228
+ * @returns The interpolated angle.
229
+ * @public
230
+ * @example
231
+ * ```ts
232
+ * interpolateAngleCCW(0, 90, 0.5) // returns 45
233
+ * interpolateAngleCCW(0, 270, 0.5) // returns 315
234
+ * interpolateAngleCCW(0, 90, 0.25) // returns 22.5
235
+ * interpolateAngleCCW(0, 270, 0.25) // returns 337.5
236
+ * ```
237
+ **/
60
238
  export declare function interpolateAngleCCW(a: number, b: number, t: number, turn?: number): number;
61
239
  /**
62
- number numbers can sometime introduce tiny errors even for simple operations.
63
- `nearEquals` compares two floats using a tiny tollerance (last optional
64
- argument). By default it is defined as `EPSILON`.
65
- **/
240
+ * number numbers can sometime introduce tiny errors even for simple operations.
241
+ * `nearEquals` compares two floats using a tiny tollerance (last optional
242
+ * argument). By default it is defined as `EPSILON`.
243
+ *
244
+ * @param a - The first number to compare.
245
+ * @param b - The second number to compare.
246
+ * @param tollerance - The tollerance value. Default is `EPSILON`.
247
+ * @returns `true` if the numbers are very close, `false` otherwise.
248
+ * @public
249
+ * @example
250
+ * ```ts
251
+ * nearEquals(5, 5.000000000000001) // returns true
252
+ * nearEquals(5, 5.000000000001) // returns false
253
+ * nearEquals(5, 5.000000000001, 1e-9) // returns true
254
+ * ```
255
+ **/
66
256
  export declare function nearEquals(a: number, b: number, tollerance?: number): boolean;
67
257
  /**
68
- number numbers can sometime introduce tiny errors even for simple operations.
69
- `nearEqualAngles` compares two angles (default is 360deg) using a tiny
70
- tollerance (last optional argument). By default the tollerance is defined as
71
- `EPSILON`.
72
- **/
258
+ * number numbers can sometime introduce tiny errors even for simple operations.
259
+ * `nearEqualAngles` compares two angles (default is 360deg) using a tiny
260
+ * tollerance (last optional argument). By default the tollerance is defined as
261
+ * `EPSILON`.
262
+ *
263
+ * @param a - The first angle in degrees.
264
+ * @param b - The second angle in degrees.
265
+ * @param turn - The total number of degrees in a full turn. Default is 360.0.
266
+ * @param tollerance - The tollerance value. Default is `EPSILON`.
267
+ * @returns `true` if the angles are very close, `false` otherwise.
268
+ * @public
269
+ * @example
270
+ * ```ts
271
+ * nearEqualAngles(0, 360) // returns true
272
+ * nearEqualAngles(0, 361) // returns false
273
+ * nearEqualAngles(0, 360.000000000001) // returns true
274
+ * nearEqualAngles(0, 361, 360, 1) // returns true
275
+ * ```
276
+ **/
73
277
  export declare function nearEqualAngles(a: number, b: number, turn?: number, tollerance?: number): boolean;
74
278
  /**
75
- `nearZero` finds if the passed number is zero or very close to it. By default
76
- `EPSILON` is used as the tollerance value.
77
- **/
279
+ * `nearZero` finds if the passed number is zero or very close to it. By default
280
+ * `EPSILON` is used as the tollerance value.
281
+ *
282
+ * @param n - The number to check.
283
+ * @param tollerance - The tollerance value. Default is `EPSILON`.
284
+ * @returns `true` if the number is zero or very close to it, `false` otherwise.
285
+ * @public
286
+ * @example
287
+ * ```ts
288
+ * nearZero(0.000000000000001) // returns true
289
+ * nearZero(0.000000001) // returns false
290
+ * nearZero(0.000000001, 1e-9) // returns true
291
+ * ```
292
+ **/
78
293
  export declare function nearZero(n: number, tollerance?: number): boolean;
79
294
  /**
80
- Computes the nth root (`index`) of `base`.
81
- **/
295
+ * Computes the nth root (`index`) of `base`.
296
+ *
297
+ * @param base - The base number.
298
+ * @param index - The index of the root.
299
+ * @returns The nth root of the base number.
300
+ * @public
301
+ * @example
302
+ * ```ts
303
+ * root(8, 3) // returns 2
304
+ * root(27, 3) // returns 3
305
+ * root(16, 4) // returns 2
306
+ * ```
307
+ **/
82
308
  export declare function root(base: number, index: number): number;
83
309
  /**
84
- Rounds a number to the specified number of decimals.
85
- **/
310
+ * Rounds a number to the specified number of decimals.
311
+ *
312
+ * @param f - The number to round.
313
+ * @param decimals - The number of decimals to round to.
314
+ * @returns The rounded number.
315
+ * @public
316
+ * @example
317
+ * ```ts
318
+ * roundTo(1.234, 2) // returns 1.23
319
+ * roundTo(1.234, 1) // returns 1.2
320
+ * roundTo(1.234, 0) // returns 1
321
+ * ```
322
+ **/
86
323
  export declare function roundTo(f: number, decimals: number): number;
87
324
  /**
88
- `sign` returns `-1` if `value` is a negative number, `1` otherwise.
89
- */
325
+ * `sign` returns `-1` if `value` is a negative number, `1` otherwise.
326
+ *
327
+ * @param value - The number to check.
328
+ * @returns `-1` if the number is negative, `1` otherwise.
329
+ * @public
330
+ * @example
331
+ * ```ts
332
+ * sign(-5) // returns -1
333
+ * sign(5) // returns 1
334
+ * ```
335
+ */
90
336
  export declare function sign<T extends number>(value: T): number;
91
337
  /**
92
- Passed two boundaries values (`min`, `max`), `wrap` ensures that the passed value `v` will
93
- be included in the boundaries. If the value exceeds `max`, the value is reduced by `min`
94
- repeatedely until it falls within the range. Similar and inverted treatment is performed if
95
- the value is below `min`.
96
- **/
338
+ * Passed two boundaries values (`min`, `max`), `wrap` ensures that the passed value `v` will
339
+ * be included in the boundaries. If the value exceeds `max`, the value is reduced by `min`
340
+ * repeatedely until it falls within the range. Similar and inverted treatment is performed if
341
+ * the value is below `min`.
342
+ *
343
+ * @param v - The value to wrap.
344
+ * @param min - The minimum value of the range.
345
+ * @param max - The maximum value of the range.
346
+ * @returns The wrapped value.
347
+ * @public
348
+ * @example
349
+ * ```ts
350
+ * wrap(5, 0, 10) // returns 5
351
+ * wrap(15, 0, 10) // returns 5
352
+ * wrap(-5, 0, 10) // returns 5
353
+ * ```
354
+ **/
97
355
  export declare function wrap(v: number, min: number, max: number): number;
98
356
  /**
99
- Similar to `wrap`, it works for numbers between 0 and `max`.
100
- **/
357
+ * Similar to `wrap`, it works for numbers between 0 and `max`.
358
+ *
359
+ * @param v - The value to wrap.
360
+ * @param max - The maximum value of the range.
361
+ * @returns The wrapped value.
362
+ * @public
363
+ * @example
364
+ * ```ts
365
+ * wrapCircular(5, 10) // returns 5
366
+ * wrapCircular(15, 10) // returns 5
367
+ * wrapCircular(-5, 10) // returns 5
368
+ * ```
369
+ **/
101
370
  export declare function wrapCircular(v: number, max: number): number;
package/object.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function s(e){return Object.keys(e)}function c(e,t){const u=s(e),r=s(t);if(u.length!==r.length)return!1;for(const n of u)if(!(n in t))return!1;return!0}function i(e){return e!=null&&Object.getPrototypeOf(e)===Object.prototype}function o(e,...t){return s(e).reduce((r,n)=>(t.includes(n)||(r[n]=e[n]),r),{})}function f(e,t){return Object.assign({},e,t)}function l(e){return e==null||i(e)&&Object.keys(e).length===0}exports.isEmpty=l;exports.isObject=i;exports.keys=s;exports.merge=f;exports.removeFields=o;exports.sameKeys=c;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function c(e){return Object.keys(e)}function o(e,t){const s=c(e),r=c(t);if(s.length!==r.length)return!1;for(const n of s)if(!(n in t))return!1;return!0}function u(e){return e!=null&&Object.getPrototypeOf(e)===Object.prototype}function i(e,...t){return c(e).reduce((r,n)=>(t.includes(n)||(r[n]=e[n]),r),{})}function b(e,t){return Object.assign({},e,t)}function j(e){return Object.keys(e).length===0}exports.isEmptyObject=j;exports.isObject=u;exports.mergeObjects=b;exports.objectKeys=c;exports.removeObjectFields=i;exports.sameObjectKeys=o;
package/object.d.ts CHANGED
@@ -1,8 +1,56 @@
1
1
  import { IndexKey, Merge, TupleToUnion } from './domain';
2
2
 
3
- export declare function keys<T extends object>(obj: T): Array<keyof T>;
4
- export declare function sameKeys<T extends object>(a: T, b: T): boolean;
3
+ /**
4
+ * Returns an array of keys from the given object.
5
+ *
6
+ * @param obj - The object from which to extract keys.
7
+ * @returns An array of keys from the object.
8
+ * @public
9
+ */
10
+ export declare function objectKeys<T extends object>(obj: T): Array<keyof T>;
11
+ /**
12
+ * Checks if two objects have the same keys.
13
+ *
14
+ * @param a - The first object.
15
+ * @param b - The second object.
16
+ * @returns `true` if both objects have the same keys, `false` otherwise.
17
+ * @public
18
+ */
19
+ export declare function sameObjectKeys<T extends object>(a: T, b: T): boolean;
20
+ /**
21
+ * Checks if the given value is an object.
22
+ *
23
+ * @param obj - The value to check.
24
+ * @returns `true` if the value is an object, `false` otherwise.
25
+ * @public
26
+ */
5
27
  export declare function isObject(obj: unknown): obj is Record<IndexKey, unknown>;
6
- export declare function removeFields<T extends object, F extends Array<keyof T>>(ob: T, ...fields: F): Omit<T, TupleToUnion<F>>;
7
- export declare function merge<A extends Record<IndexKey, unknown>, B extends Record<IndexKey, unknown>>(a: A, b: B): Merge<A, B>;
8
- export declare function isEmpty(obj: object): boolean;
28
+ /**
29
+ * Removes specified fields from an object and returns a new object without those fields.
30
+ *
31
+ * @param ob - The object from which fields will be removed.
32
+ * @param fields - The fields to be removed from the object.
33
+ * @returns A new object without the specified fields.
34
+ * @public
35
+ */
36
+ export declare function removeObjectFields<T extends object, F extends Array<keyof T>>(ob: T, ...fields: F): Omit<T, TupleToUnion<F>>;
37
+ /**
38
+ * Merges two objects together.
39
+ *
40
+ * @typeParam A - The type of the first object.
41
+ * @typeParam B - The type of the second object.
42
+ * @param a - The first object to merge.
43
+ * @param b - The second object to merge.
44
+ * @returns The merged object.
45
+ * @public
46
+ */
47
+ export declare function mergeObjects<A extends Record<IndexKey, unknown>, B extends Record<IndexKey, unknown>>(a: A, b: B): Merge<A, B>;
48
+ /**
49
+ * Checks if an object is empty.
50
+ * An object is considered empty if it has no own enumerable properties.
51
+ *
52
+ * @param obj - The object to check.
53
+ * @returns `true` if the object is empty, `false` otherwise.
54
+ * @public
55
+ */
56
+ export declare function isEmptyObject(obj: object): boolean;
package/object.js CHANGED
@@ -1,30 +1,30 @@
1
1
  function s(e) {
2
2
  return Object.keys(e);
3
3
  }
4
- function i(e, t) {
5
- const u = s(e), r = s(t);
6
- if (u.length !== r.length) return !1;
7
- for (const n of u)
4
+ function u(e, t) {
5
+ const c = s(e), r = s(t);
6
+ if (c.length !== r.length) return !1;
7
+ for (const n of c)
8
8
  if (!(n in t)) return !1;
9
9
  return !0;
10
10
  }
11
- function c(e) {
11
+ function o(e) {
12
12
  return e != null && Object.getPrototypeOf(e) === Object.prototype;
13
13
  }
14
- function f(e, ...t) {
14
+ function i(e, ...t) {
15
15
  return s(e).reduce((r, n) => (t.includes(n) || (r[n] = e[n]), r), {});
16
16
  }
17
- function o(e, t) {
17
+ function f(e, t) {
18
18
  return Object.assign({}, e, t);
19
19
  }
20
- function l(e) {
21
- return e == null || c(e) && Object.keys(e).length === 0;
20
+ function O(e) {
21
+ return Object.keys(e).length === 0;
22
22
  }
23
23
  export {
24
- l as isEmpty,
25
- c as isObject,
26
- s as keys,
27
- o as merge,
28
- f as removeFields,
29
- i as sameKeys
24
+ O as isEmptyObject,
25
+ o as isObject,
26
+ f as mergeObjects,
27
+ s as objectKeys,
28
+ i as removeObjectFields,
29
+ u as sameObjectKeys
30
30
  };
package/package.json CHANGED
@@ -1,8 +1,30 @@
1
1
  {
2
2
  "name": "@tempots/std",
3
- "version": "0.10.7",
3
+ "version": "0.12.0",
4
+ "priority": 8,
5
+ "description": "Std library for TypeScript. Natural complement to the Tempo libraries.",
6
+ "keywords": [
7
+ "tempo",
8
+ "tempots",
9
+ "framework",
10
+ "std",
11
+ "library"
12
+ ],
13
+ "homepage": "https://github.com/fponticelli/tempots",
14
+ "bugs": {
15
+ "url": "https://github.com/fponticelli/tempots/issues"
16
+ },
17
+ "author": {
18
+ "name": "Franco Ponticelli",
19
+ "email": "franco.ponticelli@gmail.com",
20
+ "url": "https://github.com/fponticelli"
21
+ },
4
22
  "type": "module",
5
23
  "exports": {
24
+ ".": {
25
+ "import": "./index.js",
26
+ "require": "./index.cjs"
27
+ },
6
28
  "./array": {
7
29
  "import": "./array.js",
8
30
  "require": "./array.cjs"
@@ -31,18 +53,10 @@
31
53
  "import": "./function.js",
32
54
  "require": "./function.cjs"
33
55
  },
34
- "./index": {
35
- "import": "./index.js",
36
- "require": "./index.cjs"
37
- },
38
56
  "./json": {
39
57
  "import": "./json.js",
40
58
  "require": "./json.cjs"
41
59
  },
42
- "./maybe": {
43
- "import": "./maybe.js",
44
- "require": "./maybe.cjs"
45
- },
46
60
  "./number": {
47
61
  "import": "./number.js",
48
62
  "require": "./number.cjs"
@@ -73,12 +87,11 @@
73
87
  "type": "git",
74
88
  "url": "git+https://github.com/fponticelli/tempots.git"
75
89
  },
76
- "bugs": {
77
- "url": "https://github.com/fponticelli/tempots/issues"
78
- },
79
- "homepage": "https://github.com/fponticelli/tempots#readme",
80
90
  "typesVersions": {
81
91
  "*": {
92
+ ".": [
93
+ "./index.d.ts"
94
+ ],
82
95
  "array": [
83
96
  "./array.d.ts"
84
97
  ],
@@ -100,15 +113,9 @@
100
113
  "function": [
101
114
  "./function.d.ts"
102
115
  ],
103
- "index": [
104
- "./index.d.ts"
105
- ],
106
116
  "json": [
107
117
  "./json.d.ts"
108
118
  ],
109
- "maybe": [
110
- "./maybe.d.ts"
111
- ],
112
119
  "number": [
113
120
  "./number.d.ts"
114
121
  ],
package/regexp.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function g(i,s,u){const n=[];let l=0,e;if(s.global)for(s.lastIndex=0;(e=s.exec(i))!==null;)n.push(i.substring(l,e.index)),n.push(u(...e)),l=e.index+e[0].length;else for(;(e=s.exec(i.substring(l)))!==null;)n.push(i.substring(l,l+e.index)),n.push(u(...e)),l+=e.index+e[0].length;return n.push(i.substring(l)),n.join("")}exports.map=g;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function g(i,s,u){const n=[];let l=0,e;if(s.global)for(s.lastIndex=0;(e=s.exec(i))!==null;)n.push(i.substring(l,e.index)),n.push(u(...e)),l=e.index+e[0].length;else for(;(e=s.exec(i.substring(l)))!==null;)n.push(i.substring(l,l+e.index)),n.push(u(...e)),l+=e.index+e[0].length;return n.push(i.substring(l)),n.join("")}exports.mapRegExp=g;
package/regexp.d.ts CHANGED
@@ -3,8 +3,9 @@
3
3
  */
4
4
  /**
5
5
  * Map the function `f` on each occurance matched by the pattern.
6
- * @param f
7
- * @param pattern
8
- * @param subject
6
+ * @param f - The function to apply to each match.
7
+ * @param pattern - The pattern to match.
8
+ * @param subject - The string to search.
9
+ * @public
9
10
  */
10
- export declare function map(subject: string, pattern: RegExp, f: (...s: string[]) => string): string;
11
+ export declare function mapRegExp(subject: string, pattern: RegExp, f: (...s: string[]) => string): string;
package/regexp.js CHANGED
@@ -1,14 +1,14 @@
1
- function h(e, i, u) {
2
- const s = [];
1
+ function h(s, i, u) {
2
+ const e = [];
3
3
  let n = 0, l;
4
4
  if (i.global)
5
- for (i.lastIndex = 0; (l = i.exec(e)) !== null; )
6
- s.push(e.substring(n, l.index)), s.push(u(...l)), n = l.index + l[0].length;
5
+ for (i.lastIndex = 0; (l = i.exec(s)) !== null; )
6
+ e.push(s.substring(n, l.index)), e.push(u(...l)), n = l.index + l[0].length;
7
7
  else
8
- for (; (l = i.exec(e.substring(n))) !== null; )
9
- s.push(e.substring(n, n + l.index)), s.push(u(...l)), n += l.index + l[0].length;
10
- return s.push(e.substring(n)), s.join("");
8
+ for (; (l = i.exec(s.substring(n))) !== null; )
9
+ e.push(s.substring(n, n + l.index)), e.push(u(...l)), n += l.index + l[0].length;
10
+ return e.push(s.substring(n)), e.join("");
11
11
  }
12
12
  export {
13
- h as map
13
+ h as mapRegExp
14
14
  };