filter-obj
Advanced tools
Comparing version 2.0.2 to 3.0.0
/** | ||
Filter object keys and values into a new object. | ||
@param object - Source object to filter properties from. | ||
@param object - The source object to filter properties from. | ||
@param predicate - Predicate function that detemines whether a property should be assigned to the new object. | ||
@@ -10,3 +10,3 @@ @param includeKeys - Property names that should be assigned to the new object. | ||
``` | ||
import filterObject = require('filter-obj'); | ||
import filterObject from 'filter-obj'; | ||
@@ -25,3 +25,3 @@ const object = { | ||
*/ | ||
declare function filterObject<ObjectType extends {[key: string]: any}>( | ||
export default function filterObject<ObjectType extends Record<string, any>>( | ||
object: ObjectType, | ||
@@ -33,10 +33,8 @@ predicate: ( | ||
): Partial<ObjectType>; | ||
declare function filterObject< | ||
ObjectType extends {[key: string]: any}, | ||
IncludedKeys extends keyof ObjectType | ||
export default function filterObject< | ||
ObjectType extends Record<string, any>, | ||
IncludedKeys extends keyof ObjectType, | ||
>( | ||
object: ObjectType, | ||
includeKeys: ReadonlyArray<IncludedKeys> | ||
includeKeys: readonly IncludedKeys[] | ||
): Pick<ObjectType, IncludedKeys>; | ||
export = filterObject; |
@@ -1,4 +0,2 @@ | ||
'use strict'; | ||
module.exports = (object, predicate) => { | ||
export default function filterObject(object, predicate) { | ||
const result = {}; | ||
@@ -13,3 +11,3 @@ const isArray = Array.isArray(predicate); | ||
enumerable: true, | ||
configurable: true | ||
configurable: true, | ||
}); | ||
@@ -20,2 +18,2 @@ } | ||
return result; | ||
}; | ||
} |
{ | ||
"name": "filter-obj", | ||
"version": "2.0.2", | ||
"version": "3.0.0", | ||
"description": "Filter object keys and values into a new object", | ||
"license": "MIT", | ||
"repository": "sindresorhus/filter-obj", | ||
"funding": "https://github.com/sponsors/sindresorhus", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
"url": "https://sindresorhus.com" | ||
}, | ||
"type": "module", | ||
"exports": "./index.js", | ||
"engines": { | ||
"node": ">=8" | ||
"node": "^12.20.0 || ^14.13.1 || >=16.0.0" | ||
}, | ||
@@ -33,6 +36,6 @@ "scripts": { | ||
"devDependencies": { | ||
"ava": "^2.4.0", | ||
"tsd": "^0.9.0", | ||
"xo": "^0.25.3" | ||
"ava": "^3.15.0", | ||
"tsd": "^0.17.0", | ||
"xo": "^0.44.0" | ||
} | ||
} |
@@ -5,3 +5,2 @@ # filter-obj | ||
## Install | ||
@@ -13,7 +12,6 @@ | ||
## Usage | ||
```js | ||
const filterObject = require('filter-obj'); | ||
import filterObject from 'filter-obj'; | ||
@@ -32,3 +30,2 @@ const object = { | ||
## API | ||
@@ -43,3 +40,3 @@ | ||
Source object to filter properties from. | ||
The source object to filter properties from. | ||
@@ -56,7 +53,6 @@ #### filter | ||
Array of property names that should be assigned to the new object. | ||
An array of property names that should be assigned to the new object. | ||
## Related | ||
- [map-obj](https://github.com/sindresorhus/map-obj) - Map object keys and values into a new object |
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
4168
Yes
47
54