Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

positive-or-zero

trystal4ISC1.0.0

Converts negatives to zero, leaves positives alone

readme

positive-or-zero

A Node.js package that returns VALUE if VALUE is positive, zero in every other case

Usage

First, install the package using npm:

npm install positive-or-zero --save

Then, require the package and use it like so:

var positiveOrZero = require('positive-or-zero')

console.log(positiveOrZero(100))  // 100

console.log(positiveOrZero(0))    // 0
console.log(positiveOrZero(-100)) // 0
console.log(positiveOrZero(null)) // 0
console.log(positiveOrZero())     // 0

Licence

Apache 2.0