Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

deffy

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

deffy

Small and fast library to set default values.

  • 2.2.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
57K
decreased by-38.8%
Maintainers
1
Weekly downloads
 
Created
Source

deffy

deffy PayPal Version Downloads Get help on Codementor

Small and fast library to set default values.

Installation

$ npm i --save deffy

Example

// Dependencies
var Deffy = require("deffy");

console.log(Deffy(undefined, "Hello World"));
// => "Hello World"

console.log(Deffy("Hello World", 42));
// => 42

console.log(Deffy("Hello", "World"));
// => "World"

console.log(Deffy("", "World", true));
// => "World"

console.log(Deffy("", "World"));
// => ""

console.log(Deffy("foo", function (input) {
    return input === "foo" ? "bar" : "foo";
}));
// => "bar"

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: The empty value or an object containing the following fields:

  • empty (Boolean): Handles the input value as empty field (input || default). Default is false.

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. :sparkles:

License

MIT © Ionică Bizău

Keywords

FAQs

Package last updated on 14 Jan 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc