Repository
Current version released
4 years ago
Versions
Deno port of IonicaBizau/deffy
deffy
Small and fast library to set default values.
๐ Example
// Dependencies
import {Deffy} from "https://deno.land/x/deffy/lib/deffy.ts"
console.log(Deffy(undefined, "Hello World"));
// => "Hello World"
console.log(Deffy("Hello World", 42));
// => 42
console.log(Deffy("Hello", "World"));
// => "Hello"
console.log(Deffy("", "World", true));
// => "World"
console.log(Deffy("", "World"));
// => ""
console.log(Deffy("foo", function (input: string) {
return input === "foo" ? "bar" : "foo";
}));
// => "bar"
:question: Get Help
There are few ways to get help:
- Please post questions on Stack Overflow. You can open issues with questions, as long you add a link to your Stack Overflow question.
- For bug reports and feature requests, open issues. ๐
๐ Documentation
Deffy(input, def, options)
Computes a final value by providing the input and default values.
Params
Anything
input: The input value.Anything|Function
def: The default value or a function getting the input value as first argument.Object|Boolean
options: Theemptyvalue or an object containing the following fields:empty(Boolean): Handles the input value as empty field (input || default). Default isfalse.
Return
- Anything The computed value.
๐ How to contribute
Have an idea? Found a bug? See how to contribute.
๐ซ Where is this library used?
If you are using this library in one of your projects, add it in this list. โจ
๐ License
MIT ยฉ Ionicฤ Bizฤu MIT ยฉ Hunter Paulson
