5.13.0 • Published 3 years ago

falsy-finder v5.13.0

Weekly downloads
4
License
ISC
Repository
github
Last release
3 years ago

Falsy Finder

Known Vulnerabilities Coverage Status Build Status Deps devDependency Status

NPM

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

How to install

npm install falsy-finder -S

Getting Started

The basic syntax is:

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:

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]
5.13.0

3 years ago

5.12.0

3 years ago

5.11.0

3 years ago

5.9.0

4 years ago

5.6.0

4 years ago

5.4.1

4 years ago

5.5.0

4 years ago

5.1.0

4 years ago

5.0.0

4 years ago

4.0.1

4 years ago

4.0.0

4 years ago

3.3.0

4 years ago

3.2.0

5 years ago

3.1.0

5 years ago

3.0.0

6 years ago

2.2.3

6 years ago

2.2.2

6 years ago

2.2.1

6 years ago

2.2.0

6 years ago

2.1.0

6 years ago

2.0.3

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.2.0

6 years ago

1.1.0

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago