@homebound/activesupport
Advanced tools
Comparing version 1.2.0 to 1.3.0
@@ -70,2 +70,7 @@ type KeysOfType<T, TProp> = { | ||
count(f: (el: T, index: number, array: T[]) => boolean): number; | ||
/** | ||
* Compares every element in the array to each other and returns true if they all match `fn(el)` and | ||
* false otherwise. Shorthand for `array.every((el, _, [first]) => el.some.id === first.some.id)` | ||
*/ | ||
everyHasSame(fn: (el: T) => unknown): boolean; | ||
} | ||
@@ -132,2 +137,7 @@ interface ReadonlyArray<T> { | ||
count(f: (el: T, index: number, array: readonly T[]) => boolean): number; | ||
/** | ||
* Compares every element in the array to each other and returns true if they all match `fn(el)` and | ||
* false otherwise. Shorthand for `array.every((el, _, [first]) => el.some.id === first.some.id)` | ||
*/ | ||
everyHasSame(fn: (el: T) => unknown): boolean; | ||
} | ||
@@ -134,0 +144,0 @@ } |
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
@@ -202,2 +203,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
}; | ||
Array.prototype.everyHasSame = function(fn) { | ||
let cached; | ||
return this.every((el, _, [first]) => fn(el) === (cached ??= fn(first))); | ||
}; | ||
Object.defineProperty(Array.prototype, "isEmpty", { | ||
@@ -204,0 +209,0 @@ enumerable: false, |
{ | ||
"name": "@homebound/activesupport", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"main": "./dist/index.js", | ||
@@ -5,0 +5,0 @@ "module": "./dist/index.mjs", |
@@ -68,2 +68,7 @@ import type { KeysOfType } from "./utils"; | ||
count(f: (el: T, index: number, array: T[]) => boolean): number; | ||
/** | ||
* Compares every element in the array to each other and returns true if they all match `fn(el)` and | ||
* false otherwise. Shorthand for `array.every((el, _, [first]) => el.some.id === first.some.id)` | ||
*/ | ||
everyHasSame(fn: (el: T) => unknown): boolean; | ||
} | ||
@@ -136,2 +141,7 @@ | ||
count(f: (el: T, index: number, array: readonly T[]) => boolean): number; | ||
/** | ||
* Compares every element in the array to each other and returns true if they all match `fn(el)` and | ||
* false otherwise. Shorthand for `array.every((el, _, [first]) => el.some.id === first.some.id)` | ||
*/ | ||
everyHasSame(fn: (el: T) => unknown): boolean; | ||
} | ||
@@ -406,2 +416,7 @@ } | ||
Array.prototype.everyHasSame = function <T>(this: T[], fn: (el: T) => unknown): boolean { | ||
let cached: unknown; | ||
return this.every((el, _, [first]) => fn(el) === (cached ??= fn(first))); | ||
}; | ||
Object.defineProperty(Array.prototype, "isEmpty", { | ||
@@ -408,0 +423,0 @@ enumerable: false, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
96703
1115