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

24 lines
546 B
TypeScript

// Loaded from https://deno.land/x/segno@v1.1.0/lib/validations/isEmpty.ts
// @ts-ignore allowing typedoc to build
import { assertString } from '../helpers/assertString.ts';
type EmptyOptions = {
ignoreWhitespace?: boolean;
};
/**
* @ignore
*/
const defaultEmptyOptions: EmptyOptions = {
ignoreWhitespace: false,
};
export const isEmpty = (str: string, options?: EmptyOptions) => {
assertString(str);
options = { ...defaultEmptyOptions, ...options };
return (options.ignoreWhitespace ? str.trim().length : str.length) === 0;
};