0.0.5 • Published 9 years ago

optcase v0.0.5

Weekly downloads
3
License
MIT
Repository
github
Last release
9 years ago

optcase

.

Build Status

Installation

$ npm install --save optcase

Usage

import optcase from "optcase";

function who(){
	optcase(arguments)
	.case("string", (name) => {
		console.log(`My name is ${name}.`);
	})
	.case("string", "number", (name, age) => {
		if (age === 1)
			console.log(`My name is ${name}, I'm ${age} year old.`);
		else if (age > 1)
			console.log(`My name is ${name}, I'm ${age} years old.`);
		else
			console.log("I wasn't born yet.");
	})
	.default(() => {
		console.log("Who am I?");
	});
}

who("haruna"); // My name is haruna.
who("haruna", 102); // My name is haruna, I'm 102 years old.
who("girlfriend", -Infinity); // I wasn't born yet.
who(); // Who am I?
0.0.5

9 years ago

0.0.4

9 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago

0.0.0

9 years ago