Skip to content

value-fallback/SYMVL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SYMVL

license npm npm Travis ESLint Gluons

Fallback when a value is not Symbol.

Installation

Via NPM:

NPM

npm install symvl

Via Yarn:

yarn add symvl

Usage

const symvl = require('symvl');

// When a value is not Symbol, it will return fallback value.
let a = symvl(null, 0); // a = 0
let b = symvl({}, 'x'); // b = 'x'

// When a value is Symbol, it will return that value.
let c = symvl(Symbol(), 1); // c = Symbol()
let d = symvl(Symbol('SYMBOL'), 'abc'); // d = Symbol(SYMBOL)

API

symvl(value, fallbackValue)

value

A main value.

fallbackValue

A fallback value.