cafe-utility 23.0.0 → 23.1.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 +3 -1
  2. package/index.js +5 -1
  3. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -55,6 +55,7 @@ declare function rgbToHex(rgb: [number, number, number]): string;
55
55
  declare function haversineDistanceToMeters(lat1: number, lon1: number, lat2: number, lon2: number): number;
56
56
  declare function roundToNearest(value: number, nearest: number): number;
57
57
  declare function formatDistance(meters: number): string;
58
+ declare function triangularNumber(n: number): number;
58
59
  declare function isObject(value: any, checkForPlainObject?: boolean): value is object;
59
60
  declare function isStrictlyObject(value: any): value is object;
60
61
  declare function isEmptyArray(value: any): boolean;
@@ -540,7 +541,7 @@ declare function raycast(origin: Point, lines: Line[], angle: number): Point | n
540
541
  declare function raycastCircle(origin: Point, lines: Line[], corners: Point[]): Point[];
541
542
  export declare class PubSubChannel<T> {
542
543
  private subscribers;
543
- subscribe(callback: (data: unknown) => void): () => void;
544
+ subscribe(callback: (data: T) => void): () => void;
544
545
  publish(data: T): void;
545
546
  }
546
547
  export declare const Binary: {
@@ -649,6 +650,7 @@ export declare const Numbers: {
649
650
  haversineDistanceToMeters: typeof haversineDistanceToMeters;
650
651
  roundToNearest: typeof roundToNearest;
651
652
  formatDistance: typeof formatDistance;
653
+ triangularNumber: typeof triangularNumber;
652
654
  };
653
655
  export declare const Promises: {
654
656
  raceFulfilled: typeof raceFulfilled;
package/index.js CHANGED
@@ -276,6 +276,9 @@ function formatDistance(n) {
276
276
  ? roundToNearest(n, 50) + ' m'
277
277
  : roundToNearest(n, 10) + ' m'
278
278
  }
279
+ function triangularNumber(n) {
280
+ return (n * (n + 1)) / 2
281
+ }
279
282
  function isObject(n, t = !0) {
280
283
  return !n ||
281
284
  (t && !isUndefined(n._readableState)) ||
@@ -2464,7 +2467,8 @@ class PubSubChannel {
2464
2467
  rgbToHex,
2465
2468
  haversineDistanceToMeters,
2466
2469
  roundToNearest,
2467
- formatDistance
2470
+ formatDistance,
2471
+ triangularNumber
2468
2472
  }),
2469
2473
  (exports.Promises = { raceFulfilled, invert: invertPromise, runInParallelBatches, makeAsyncQueue }),
2470
2474
  (exports.Dates = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cafe-utility",
3
- "version": "23.0.0",
3
+ "version": "23.1.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "exports": {