filter-obj
Advanced tools
Comparing version 6.0.0 to 6.1.0
@@ -36,3 +36,3 @@ /** | ||
object: ObjectType, | ||
keys: readonly IncludedKeys[] | ||
keys: readonly IncludedKeys[] | ReadonlySet<IncludedKeys> | ||
): Pick<ObjectType, IncludedKeys>; | ||
@@ -75,5 +75,5 @@ | ||
object: ObjectType, | ||
keys: readonly ExcludedKeys[] | ||
keys: readonly ExcludedKeys[] | ReadonlySet<ExcludedKeys> | ||
): DistributiveOmit<ObjectType, ExcludedKeys>; | ||
type DistributiveOmit<Value, Key extends PropertyKey> = Value extends unknown ? Omit<Value, Key> : never; |
@@ -0,5 +1,8 @@ | ||
// https://github.com/sindresorhus/is/tree/main?tab=readme-ov-file#why-not-just-use-instanceof-instead-of-this-package | ||
const isSet = input => Object.prototype.toString.call(input) === '[object Set]'; | ||
export function includeKeys(object, predicate) { | ||
const result = {}; | ||
if (Array.isArray(predicate)) { | ||
if (Array.isArray(predicate) || isSet(predicate)) { | ||
for (const key of predicate) { | ||
@@ -39,3 +42,7 @@ const descriptor = Object.getOwnPropertyDescriptor(object, key); | ||
if (isSet(predicate)) { | ||
return includeKeys(object, key => !predicate.has(key)); | ||
} | ||
return includeKeys(object, (key, value, object) => !predicate(key, value, object)); | ||
} |
{ | ||
"name": "filter-obj", | ||
"version": "6.0.0", | ||
"version": "6.1.0", | ||
"description": "Filter object keys and values into a new object", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -55,5 +55,5 @@ # filter-obj | ||
Type: `Array<string | symbol>` | ||
Type: `Array<string | symbol> | Set<string | symbol>` | ||
An array of property keys to be filtered. | ||
An array or [`Set`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set) of property keys to be filtered. | ||
@@ -60,0 +60,0 @@ ## Related |
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
6608
102