UNPKG

@vnmfify/core

Version:

```shell npm i @vnmfify/core -S ```

39 lines (34 loc) 1.2 kB
import _endsWith from "lodash/endsWith"; import _isEmpty from "lodash/isEmpty"; import _isFunction from "lodash/isFunction"; import _get from "lodash/get"; import _isArray from "lodash/isArray"; import _isObject from "lodash/isObject"; import _isString from "lodash/isString"; import _isNumber from "lodash/isNumber"; import _isNull from "lodash/isNull"; import _isUndefined from "lodash/isUndefined"; import { isValidElement } from "react"; export function isNoneElement(node) { return _isUndefined(node) || _isNull(node); } export function isTextElement(node) { return _isNumber(node) || _isString(node); } export function isObjectElement(node) { return ! /*#__PURE__*/isValidElement(node) && _isObject(node) && !_isArray(node); } export function isElementOf(node, type) { if ( /*#__PURE__*/isValidElement(node)) { var element = node; if (element.type === type) { return true; } var displayName = _get(element.type, "displayName"); if (_isFunction(element.type) && !_isEmpty(displayName) && _endsWith(displayName, _get(type, "displayName"))) { return true; } } return false; } //# sourceMappingURL=index.js.map