oberknecht-utils
Advanced tools
Comparing version 0.2.1 to 0.2.2
@@ -29,2 +29,3 @@ require("./lib/utils/cleanChannelName"); | ||
require("./lib/utils/returnOnNumber"); | ||
require("./lib/utils/isNullUndefined"); | ||
@@ -31,0 +32,0 @@ require("./lib/variables/regex"); |
@@ -30,2 +30,3 @@ class oberknechtUtils { | ||
static returnOnNumber = require("./returnOnNumber"); | ||
static isNullUndefined = require("./isNullUndefined"); | ||
@@ -32,0 +33,0 @@ static regex = require("../variables/regex"); |
const extendedTypeof = require("./extendedTypeof"); | ||
const isNullUndefined = require("./isNullUndefined"); | ||
/** @param {string | Array | Object | number | bigint} input @param {Number} targetNumber @param {any} returnOnGreater @param {any} returnOnGreaterEquals @param {any} returnOnSmaller @param {any} returnOnSmallerEquals @param {any} returnDefault */ | ||
function returnOnNumber(input, targetNumber, returnOnGreater, returnOnGreaterEquals, returnOnSmaller, returnOnSmallerEquals, returnDefault) { | ||
if (["null", "undefined"].includes(extendedTypeof(input))) return undefined; | ||
targetNumber = (["null", "undefined"].includes(extendedTypeof(targetNumber)) ? 2 : targetNumber); | ||
if (isNullUndefined(extendedTypeof(input))) return undefined; | ||
targetNumber = (isNullUndefined(extendedTypeof(targetNumber)) ? 2 : targetNumber); | ||
@@ -18,10 +19,10 @@ let parsedSearchNumber; | ||
if (returnOnGreater && (parsedSearchNumber > targetNumber)) return returnOnGreater; | ||
if (returnOnGreaterEquals && (parsedSearchNumber >= targetNumber)) return returnOnGreaterEquals; | ||
if (returnOnSmaller && (parsedSearchNumber < targetNumber)) return returnOnSmaller; | ||
if (returnOnSmallerEquals && (parsedSearchNumber <= targetNumber)) return returnOnSmallerEquals; | ||
if (!isNullUndefined(returnOnGreater) && (parsedSearchNumber > targetNumber)) return returnOnGreater; | ||
if (!isNullUndefined(returnOnGreaterEquals) && (parsedSearchNumber >= targetNumber)) return returnOnGreaterEquals; | ||
if (!isNullUndefined(returnOnSmaller) && (parsedSearchNumber < targetNumber)) return returnOnSmaller; | ||
if (!isNullUndefined(returnOnSmallerEquals) && (parsedSearchNumber <= targetNumber)) return returnOnSmallerEquals; | ||
return (returnDefault ?? ""); | ||
return (!isNullUndefined(returnDefault) ? returnDefault : ""); | ||
}; | ||
module.exports = returnOnNumber; |
{ | ||
"name": "oberknecht-utils", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "Utils for oberknecht packages", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
35757
35
372