UNPKG

ng-zorro-antd-yj

Version:

An enterprise-class UI components based on Ant Design and Angular

120 lines 9.28 kB
/** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ import { TemplateRef, Type } from '@angular/core'; // tslint:disable-next-line:no-any /** * @param {?} value * @return {?} */ export function isNotNil(value) { return typeof value !== 'undefined' && value !== null; } // tslint:disable-next-line:no-any /** * @param {?} value * @return {?} */ export function isNil(value) { return typeof value === 'undefined' || value === null; } /** * Examine if two objects are shallowly equaled. * @param {?=} objA * @param {?=} objB * @return {?} */ export function shallowEqual(objA, objB) { if (objA === objB) { return true; } if (typeof objA !== 'object' || !objA || typeof objB !== 'object' || !objB) { return false; } /** @type {?} */ var keysA = Object.keys(objA); /** @type {?} */ var keysB = Object.keys(objB); if (keysA.length !== keysB.length) { return false; } /** @type {?} */ var bHasOwnProperty = Object.prototype.hasOwnProperty.bind(objB); // tslint:disable-next-line:prefer-for-of for (var idx = 0; idx < keysA.length; idx++) { /** @type {?} */ var key = keysA[idx]; if (!bHasOwnProperty(key)) { return false; } if (objA[key] !== objB[key]) { return false; } } return true; } /** * @param {?} value * @return {?} */ export function isInteger(value) { return typeof value === 'number' && isFinite(value) && Math.floor(value) === value; } /** * @param {?} element * @return {?} */ export function isEmpty(element) { /** @type {?} */ var nodes = element.childNodes; for (var i = 0; i < nodes.length; i++) { if (filterNotEmptyNode(nodes.item(i))) { return false; } } return true; } /** * @param {?} node * @return {?} */ export function filterNotEmptyNode(node) { if (node) { if (node.nodeType === 1 && ((/** @type {?} */ (node))).outerHTML.toString().trim().length !== 0) { // ELEMENT_NODE return node; } else if (node.nodeType === 3 && (/** @type {?} */ (node.textContent)).toString().trim().length !== 0) { // TEXT_NODE return node; } return null; } return null; } /** * @param {?} value * @return {?} */ export function isNonEmptyString(value) { // tslint:disable-line:no-any return typeof value === 'string' && value !== ''; } /** * @param {?} value * @return {?} */ export function isTemplateRef(value) { // tslint:disable-line:no-any return value instanceof TemplateRef; } /** * @param {?} value * @return {?} */ export function isComponent(value) { // tslint:disable-line:no-any return value instanceof Type; } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2hlY2suanMiLCJzb3VyY2VSb290Ijoibmc6Ly9uZy16b3Jyby1hbnRkLXlqLyIsInNvdXJjZXMiOlsiY29yZS91dGlsL2NoZWNrLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7QUFBQSxPQUFPLEVBQUUsV0FBVyxFQUFFLElBQUksRUFBRSxNQUFNLGVBQWUsQ0FBQzs7Ozs7O0FBSWxELE1BQU0sVUFBVSxRQUFRLENBQUMsS0FBVTtJQUNqQyxPQUFPLE9BQU8sS0FBSyxLQUFLLFdBQVcsSUFBSSxLQUFLLEtBQUssSUFBSSxDQUFDO0FBQ3hELENBQUM7Ozs7OztBQUdELE1BQU0sVUFBVSxLQUFLLENBQUMsS0FBVTtJQUM5QixPQUFPLE9BQU8sS0FBSyxLQUFLLFdBQVcsSUFBSSxLQUFLLEtBQUssSUFBSSxDQUFDO0FBQ3hELENBQUM7Ozs7Ozs7QUFLRCxNQUFNLFVBQVUsWUFBWSxDQUFDLElBQXNCLEVBQUUsSUFBc0I7SUFDekUsSUFBSSxJQUFJLEtBQUssSUFBSSxFQUFFO1FBQ2pCLE9BQU8sSUFBSSxDQUFDO0tBQ2I7SUFFRCxJQUFJLE9BQU8sSUFBSSxLQUFLLFFBQVEsSUFBSSxDQUFDLElBQUksSUFBSSxPQUFPLElBQUksS0FBSyxRQUFRLElBQUksQ0FBQyxJQUFJLEVBQUU7UUFDMUUsT0FBTyxLQUFLLENBQUM7S0FDZDs7UUFFSyxLQUFLLEdBQUcsTUFBTSxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUM7O1FBQ3pCLEtBQUssR0FBRyxNQUFNLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQztJQUUvQixJQUFJLEtBQUssQ0FBQyxNQ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