GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - kenberkeley/reject-empty: Omit empty values of an array | object

BranchesTags
Open more actions menu

Latest commit

 

History

7 Commits
7 Commits

Folders and files

NameName
Last commit message
Last commit date
test
test
 
 
.gitignore
.gitignore
 
 
.npmignore
.npmignore
 
 
.travis.yml
.travis.yml
 
 
README.md
README.md
 
 
index.js
index.js
 
 
package.json
package.json
 
 

Repository files navigation

rejectEmpty(sth <Array|Object>, omitZero <Boolean>)

npm version npm download build

Omit empty values of an array | object

Installation

npm i reject-empty -S

Usage

Let's take a look at the test examples

test('omit empty values except zero of an array', t => {
  t.deepEqual(
    rejectEmpty(
      [0, '0', undefined, null, NaN, false, '', true, 1, 'hello', { a: 1 }, [2]]
    ),
    [0, '0', true, 1, 'hello', { a: 1 }, [2]]
  )
})

test('omit empty values of an array', t => {
  t.deepEqual(
    rejectEmpty(
      [0, '0', undefined, null, NaN, false, '', true, 1, 'hello', { a: 1 }, [2]],
      true // omit zero
    ),
    [true, 1, 'hello', { a: 1 }, [2]]
  )
})

test('omit empty values except zero of an object', t => {
  t.deepEqual(
    rejectEmpty(
      { a: 0, b: undefined, c: null, d: NaN, e: false, f: '', g: true, h: 'hello', i: { a: 1 }, j: [2] }
    ),
    { a: 0, g: true, h: 'hello', i: { a: 1 }, j: [2] }
  )
})

test('omit empty values of an object', t => {
  t.deepEqual(
    rejectEmpty(
      { a: '0', b: undefined, c: null, d: NaN, e: false, f: '', g: true, h: 'hello', i: { a: 1 }, j: [2] },
      true // omit zero
    ),
    { g: true, h: 'hello', i: { a: 1 }, j: [2] }
  )
})

Test & Coverage

npm test & npm run cov

About

Omit empty values of an array | object

Topics

cleardeleteemptyfilteromitpickrejectremovevalue

Resources

Readme
Activity

Stars

1 star

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.