New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

rundef

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rundef

Remove undefined properties from object

  • 1.2.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

rundef

Remove undefined properties from object.

Build Status codecov Codacy Badge CodeFactor Test Coverage Maintainability NSP Status Known Vulnerabilities Greenkeeper badge FOSSA Status

N.B. Does not remove null or falsy values, just undefined.

Install

NPM

$ npm install rundef
$ yarn add rundef

Usage

const rundef = require('rundef');
import rundef from 'rundef';

For the most accurate examples, see the test.js file

Basic

const input = {
  a: undefined,
  b: 1
}

rundef(input); // { b: 1 }

Advanced

rundef supports two options:

  • mutate boolean - if truthy, the original object will be mutated; if falsy, a new object will be constructed and returned. Defaults to false
  • recursive boolean | int - whether rundef should recursively process nested objects. If it's an integer, it will specify the number of nested layers, or levels, to process. If it is set to true, it will recursively process all layers. Defaults to 0, which is equivalent to false.
const input = {
  a: undefined,     // Level 0
  b: {
    c: 1,
    d: undefined,   // Level 1
    e: {
      f: undefined  // Level 2
    }
  }
}

const output = rundef(
  input,
  false, // mutate - whether to mutate the original object or return a new one
  1,     // recursive - whether to apply recursively
);

output;

{                   // Level 0
  b: {
    c: 1,           // Level 1
    e: {
      f: undefined  // Level 2 - Not removed as level 1 was specified
    }
  }
}

License

FOSSA Status

Keywords

FAQs

Package last updated on 13 Jul 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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