swc/crates/swc_bundler/tests/.cache/deno/fdf87e565ee7a426282f93a7ec28ea663c7e5db4.ts
2021-11-09 20:42:49 +09:00

30 lines
993 B
TypeScript

// Loaded from https://deno.land/x/segno@v1.1.0/lib/validations/isIn.ts
// @ts-ignore allowing typedoc to build
import { assertString } from '../helpers/assertString.ts';
// @ts-ignore allowing typedoc to build
import { toString } from '../helpers/toString.ts';
//! change later
export const isIn = (str: string, options?: any) => {
assertString(str);
let i;
if (Object.prototype.toString.call(options) === '[object Array]') {
const array: any = [];
for (i in options) {
// https://github.com/gotwarlost/istanbul/blob/master/ignoring-code-for-coverage.md#ignoring-code-for-coverage-purposes
// istanbul ignore else
if ({}.hasOwnProperty.call(options, i)) {
array[i] = toString(options[i]);
}
}
return array.indexOf(str) >= 0;
} else if (typeof options === 'object') {
return options.hasOwnProperty(str);
} else if (options && typeof options.indexOf === 'function') {
return options.indexOf(str) >= 0;
}
return false;
};