DEV Community

Michael Di Prisco
Michael Di Prisco

Posted on

My Journey in Open Source - force-return

Link to the repo

What is it?

A library allowing a function or a class method to forcibly return a specified value.

How do I install it?

You can install it by using the following command:

npm install force-return
Enter fullscreen mode Exit fullscreen mode

How do I use it?

The library exposes a single function (forceReturn) that can be used to force a function or a class method to return a specified value.

The function accepts three parameters:

  • fn: The function or class method to be forced to return a specified value.
  • returnValue: The forced value to be returned by the function or class method. It must return a value that is compatible with the return type of fn.
  • _config_: An optional object containing the following properties:
    • amountOfTimesToCall: The amount of times the returnValue will be returned. If not specified, the returnValue will be returned indefinitely.

Tests

You can run the tests by using the following command:

npm test
Enter fullscreen mode Exit fullscreen mode

Postgres on Neon - Get the Free Plan

No credit card required. The database you love, on a serverless platform designed to help you build faster.

Get Postgres on Neon

Top comments (0)

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post