Socket
Socket
Sign inDemoInstall

filter-obj

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

filter-obj - npm Package Compare versions

Comparing version 2.0.2 to 3.0.0

16

index.d.ts
/**
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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc