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

function-overloader

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

function-overloader - npm Package Compare versions

Comparing version 1.2.1 to 1.3.0

2

package.json
{
"name": "function-overloader",
"version": "1.2.1",
"version": "1.3.0",
"description": "improve overloading functions and methods in js",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

import debug from "debug";
/**
* Class representing helper for methods for simplify overloading
*/
export default class Overload {

@@ -63,2 +61,16 @@ static set() {

else(callback) {
this._debug("else");
if (this._enabled) {
this._debug("execute function");
this._enabled = false;
let result = callback(...this._args);
this._debug("function sync result", result);
this._result = result;
}
return this;
}
/**

@@ -65,0 +77,0 @@ * Should be called at the end. It will return result from called use callback

@@ -50,2 +50,15 @@ import Overload from "./Overload";

it("invoke else and correct response when no condition met", () => {
let result = Overload.set(10, 10)
.when("number", "string")
.do(() => "wrong result")
.when()
.do(() => "wrong result")
.when("number", "object")
.do(() => "wrong result")
.else(() => "correct result")
.done();
expect(result).to.be.equal("correct result");
});
it("return sync result for classes", () => {

@@ -52,0 +65,0 @@ class Test1 {}

Sorry, the diff of this file is not supported yet

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