UNPKG

701 BJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6/**
7 * Check if an array contains a constructor with a certain name
8 */
9var constructorIndexInArray = function constructorIndexInArray(array, name) {
10 // The first argument has to be an array
11 if (!Array.isArray(array)) {
12 // eslint-disable-next-line max-len
13 throw new Error('[CarteBlanche] constructorIndexInArray: The first argument must be an array.');
14 }
15 for (var i = 0; i < array.length; i++) {
16 // Check the constructor name of the current array element
17 if (array[i] && array[i].constructor.name === name) {
18 return i;
19 }
20 }
21 return false;
22};
23
24exports.default = constructorIndexInArray;
\No newline at end of file