https://github.com/montumodi/falsy-finder
A simple utility to find out falsy values from an object or arrays.
https://github.com/montumodi/falsy-finder
array falsy finder json null object truthy undefined
Last synced: 22 days ago
JSON representation
A simple utility to find out falsy values from an object or arrays.
- Host: GitHub
- URL: https://github.com/montumodi/falsy-finder
- Owner: montumodi
- Created: 2018-05-18T21:37:57.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2021-05-10T09:19:55.000Z (over 4 years ago)
- Last Synced: 2025-06-04T13:54:28.418Z (5 months ago)
- Topics: array, falsy, finder, json, null, object, truthy, undefined
- Language: JavaScript
- Homepage:
- Size: 540 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Falsy Finder
[](https://snyk.io/test/github/montumodi/falsy-finder)
[](https://coveralls.io/github/montumodi/falsy-finder?branch=master)
[](https://travis-ci.org/montumodi/falsy-finder)
[](https://david-dm.org/montumodi/falsy-finder#info=dependencies)
[](https://david-dm.org/montumodi/falsy-finder#info=devDependencies)[](https://www.npmjs.com/package/falsy-finder/)
A simple utility to find out falsy values from an object or arrays. It returns all the keys along with values in an array. By default it will look for following falsy values:
```
"",
null,
undefined,
NaN
```This behavior can be customized by passing options while creating finder. See [options](#options)
## How to install
```
npm install falsy-finder -S
```## Getting Started
The basic syntax is:
```js
const createFinder = require("falsy-finder");const finder = createFinder();
const someJsonWithNullValues = {
firstName: "firstName",
lastName: "lastName",
address: {
City: "",
Street: "London"
},
tags: [
"Hi",
"hello",
"",
null,
[
{
nested: null,
none: "vallue"
}
]
]
};
const result = finder.getFalsyValues(someJsonWithNullValues);Result: [
{
key: "address.City",
value: ""
},
{
key: "tags.[2]",
value: ""
},
{
key: "tags.[3]",
value: null
},
{
key: "tags.[4].[0].nested",
value: null
}
];
```Ths syntax using options:
```js
const createFinder = require("falsy-finder");
const options = { falsyValues: ["my", "custom", null, "and", undefined] };const finder = createFinder(options);
```### Options
The `getFinder` method supports following options:
* `falsyValues`: (array) The custom falsy values array to check against. - default: `["", null, undefined, NaN]`