Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nco

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

nco

Applies a default value to a variable if it is null or undefined.

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
34K
decreased by-1.61%
Maintainers
1
Weekly downloads
 
Created
Source

nco

A function that acts as a Null-Coalescing Operator (nco) for npm and node. This is a terse way of setting default values.

You can read more about null-coalescing operators here: https://en.wikipedia.org/wiki/Null_coalescing_operator

Usage:

const nco = require('nco');
function myFunction(var1, var2) {
  var1 = nco(var1, 'default1');
  //if var1 was null or undefined, it will now be 'default1'
  var2 = nco(var2, 'default2');
  //etc.
}

The example usage written in C#, which uses ?? as a null-coalescing operator:

void MyFunction(string var1, string var2) {
  var1 = var1 ?? "default1";
  var2 = var2 ?? "default2";
  //etc.
}

Keywords

FAQs

Package last updated on 15 Feb 2016

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