cafe-utility 23.7.0 → 23.8.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.
Files changed (3) hide show
  1. package/index.d.ts +2 -0
  2. package/index.js +7 -1
  3. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -57,6 +57,7 @@ declare function haversineDistanceToMeters(lat1: number, lon1: number, lat2: num
57
57
  declare function roundToNearest(value: number, nearest: number): number;
58
58
  declare function formatDistance(meters: number): string;
59
59
  declare function triangularNumber(n: number): number;
60
+ declare function searchFloat(string: string): number;
60
61
  declare function isObject(value: any, checkForPlainObject?: boolean): value is object;
61
62
  declare function isStrictlyObject(value: any): value is object;
62
63
  declare function isEmptyArray(value: any): boolean;
@@ -673,6 +674,7 @@ export declare const Numbers: {
673
674
  roundToNearest: typeof roundToNearest;
674
675
  formatDistance: typeof formatDistance;
675
676
  triangularNumber: typeof triangularNumber;
677
+ searchFloat: typeof searchFloat;
676
678
  };
677
679
  export declare const Promises: {
678
680
  raceFulfilled: typeof raceFulfilled;
package/index.js CHANGED
@@ -288,6 +288,11 @@ function formatDistance(n) {
288
288
  function triangularNumber(n) {
289
289
  return (n * (n + 1)) / 2
290
290
  }
291
+ function searchFloat(n) {
292
+ const e = n.match(/-?\d+(\.\d+)?/)
293
+ if (!e) throw Error('No float found in ' + n)
294
+ return parseFloat(e[0])
295
+ }
291
296
  function isObject(n, e = !0) {
292
297
  return !n ||
293
298
  (e && !isUndefined(n._readableState)) ||
@@ -2511,7 +2516,8 @@ class PubSubChannel {
2511
2516
  haversineDistanceToMeters,
2512
2517
  roundToNearest,
2513
2518
  formatDistance,
2514
- triangularNumber
2519
+ triangularNumber,
2520
+ searchFloat
2515
2521
  }),
2516
2522
  (exports.Promises = { raceFulfilled, invert: invertPromise, runInParallelBatches, makeAsyncQueue }),
2517
2523
  (exports.Dates = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cafe-utility",
3
- "version": "23.7.0",
3
+ "version": "23.8.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "exports": {