MCPcopy Index your code
hub / github.com/javascriptdata/danfojs / throwErrorOnWrongParams

Method throwErrorOnWrongParams

src/danfojs-base/shared/utils.ts:536–552  ·  view source on GitHub ↗

* Throws error when a required parameter is missing. * @param paramsObject The parameters passed to the function * @param paramsNeeded The required parameters in the function

(paramsObject: object, paramsNeeded: Array<string>)

Source from the content-addressed store, hash-verified

534 * @param paramsNeeded The required parameters in the function
535 */
536 throwErrorOnWrongParams(paramsObject: object, paramsNeeded: Array<string>) {
537 const keys = Object.keys(paramsObject);
538 const bool = [];
539 for (let i = 0; i < keys.length; i++) {
540 if (paramsNeeded.includes(keys[i])) {
541 bool.push(true);
542 } else {
543 bool.push(false);
544 }
545 }
546 const truthy = (element: boolean) => element == false;
547 if (bool.some(truthy)) {
548 throw Error(
549 `Params Error: Required parameter not found. Your params must include the following [${paramsNeeded}]`
550 );
551 }
552 }
553
554 /**
555 * Maps integer values (0, 1) to boolean (false, true)

Callers 2

utils.test.jsFile · 0.80
utils.test.tsFile · 0.80

Calls 1

includesMethod · 0.80

Tested by

no test coverage detected