Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including not-available with all npm packages installed. Try it out:

var notAvailable = require("not-available")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

not-available v1.1.1

Converts empty object,empty array, empty string,NaN,null or undefined into the string "N/A" else return the input as-is

not-available

Converts empty object,empty array, empty string,NaN,null or undefined into the string "N/A" else return the input as-is.

const NA = require("not-available")
console.log('true => ' + NA(true)) // true
console.log('false => ' + NA(false)) // false
console.log('Empty object => ' + NA({})) // N/A
console.log('Empty Array => ' + NA([])) // N/A
console.log('0 => ' + NA(0)) // 0
console.log('NaN => ' + NA(NaN)) // N/A
console.log('Empty string => ' + NA('')) // N/A
console.log('undefined => ' + NA(undefined)) // N/A
console.log('null => ' + NA(null)) // N/A
console.log('Object => ', NA({a:'b'})) // {a:'b'}
console.log('Array => ' + NA(['a'])) // a

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free