当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript is.is_Array函数代码示例

本文整理汇总了TypeScript中@utils/is.is_Array函数的典型用法代码示例。如果您正苦于以下问题:TypeScript is_Array函数的具体用法?TypeScript is_Array怎么用?TypeScript is_Array使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了is_Array函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: _resolvePlaceholders

function _resolvePlaceholders(root, node, placeholders) {
    if (node == null)
        return placeholders;

    if (is_Array(node)) {
        var imax = node.length,
            i = -1;
        while (++i < imax) {
            _resolvePlaceholders(node === root ? node[i] : root, node[i], placeholders);
        }
        return placeholders;
    }

    var type = node.type;
    if (type === dom_TEXTNODE)
        return placeholders;

    if (type === dom_NODE) {
        var tagName = node.tagName;
        if (tagName != null && tagName.charCodeAt(0) === 64) {
            // @
            placeholders.$count++;
            var id = tagName.substring(1);
            // if DEBUG
            if (RESERVED.indexOf(' ' + id + ' ') !== -1)
                log_error('MaskMerge. Reserved Name', id);
            // endif
            var x = {
                tagName: node.tagName,
                parent: _getParentModifiers(root, node),
                nodes: node.nodes,
                attr: node.attr,
                expression: node.expression,
                type: node.type
            };
            if (placeholders[id] == null) {
                placeholders[id] = x;
            } else {
                var current = placeholders[id];
                if (is_Array(current)) {
                    current.push(x);
                }
                else {
                    placeholders[id] = [current, x];
                }
            }
            return placeholders;
        }
    }

    var count = placeholders.$count;
    var out = _resolvePlaceholders(root, node.nodes, placeholders);
    if (root === node && count === placeholders.$count) {
        placeholders.$extra.push(root);
    }
    return out;
}
开发者ID:atmajs,项目名称:MaskJS,代码行数:57,代码来源:merge.ts

示例2: getAwaitables

function getAwaitables (mix, out) {
    if (is_Array(mix)) {
        for(var i = 0; i < mix.length; i++) {
            getAwaitables (mix[i], out);
        }
        return;
    }
    var expr = mix;
    var type = expr.type;
    if (type === type_Statement && expr.async === true) {
        expr.preResultIndex = out.length;
        out.push(new AsyncStat(expr));
        return;
    }
    if (type === type_Body) {
        getAwaitables(expr.body, out);
        return;
    }
    if (type === type_FunctionRef) {
        getAwaitables(expr.arguments, out);
        return;
    }

    switch (type) {
        case type_Statement:
        case type_UnaryPrefix:
        case type_Ternary:
            getAwaitables(expr.body, out);
            return;
    }
}
开发者ID:atmajs,项目名称:MaskJS,代码行数:31,代码来源:eval_async.ts

示例3: _merge

function _merge(node, placeholders, tmplNode, clonedParent?) {
    if (node == null)
        return null;

    var fn;
    if (is_Array(node)) {
        fn = _mergeArray;
    } else {
        switch (node.type) {
            case dom_TEXTNODE:
                fn = _cloneTextNode;
                break;
            case dom_DECORATOR:
                fn = _cloneDecorator;
                break;
            case dom_NODE:
            case dom_STATEMENT:
                fn = _mergeNode;
                break;
            case dom_FRAGMENT:
                fn = _mergeFragment;
                break;
            case dom_COMPONENT:
                fn = _mergeComponent;
                break;
        }
    }
    if (fn !== void 0) {
        return fn(node, placeholders, tmplNode, clonedParent);
    }
    log_warn('Unknown type', node.type);
    return null;
}
开发者ID:atmajs,项目名称:MaskJS,代码行数:33,代码来源:merge.ts

示例4: function

 render: function(model, ctx, container, ctr, children){
     var directive = For.parseFor(this.expression),
         attr = this.attr;
     
     attr[attr_PROP_1] = directive[0];
     attr[attr_PROP_2] = directive[1];
     attr[attr_TYPE] = directive[2];
     attr[attr_EXPR] = directive[3];
     
     var value = expression_eval(directive[3], model, ctx, ctr);
     if (value == null) 
         return;
     
     if (is_Array(value)) 
         arr_createRefs(value);
     
     For.build(
         value,
         directive,
         this.nodes,
         model,
         ctx,
         container,
         this,
         children
     );
 },
开发者ID:atmajs,项目名称:MaskJS,代码行数:27,代码来源:for.ts

示例5: mask_merge

export function mask_merge(a, b, owner?, opts?, stats?) {
    if (typeof a === 'string') {
        a = parser_parse(a);
    }
    if (typeof b === 'string') {
        b = parser_parse(b);
    }
    if (a == null || (is_ArrayLike(a) && a.length === 0)) {
        return b;
    }
    var placeholders = _resolvePlaceholders(b, b, new Placeholders(null, b, opts));
    var out = _merge(a, placeholders, owner);
    if (stats != null) {
        stats.placeholders = placeholders;
    }

    var extra = placeholders.$extra;
    if (extra != null && extra.length !== 0) {
        if (is_Array(out)) {
            return out.concat(extra);
        }
        return [out].concat(extra);
    }
    return out;
};
开发者ID:atmajs,项目名称:MaskJS,代码行数:25,代码来源:merge.ts

示例6: clone_

/*! Circular references are not handled */
function clone_(a) {
    if (a == null) 
        return null;
    
    if (typeof a !== 'object') 
        return a;
    
    if (is_Array(a)) {
        var imax = a.length,
            i = -1,
            arr = new Array(imax)
            ;
        while( ++i < imax ){
            arr[i] = clone_(a[i]);
        }
        return arr;
    }
    
    var object = obj_create(a),
        key, val;
    for(key in object){
        val = object[key];
        if (val == null || typeof val !== 'object') 
            continue;
        object[key] = clone_(val);
    }
    return object;
}
开发者ID:atmajs,项目名称:MaskJS,代码行数:29,代码来源:compo_inherit.ts

示例7: find_findSingle

export function find_findSingle (node, matcher) {
    if (node == null) {
        return null;
    }
    if (is_Array(node)) {
        var arr = node,
            imax = arr.length,
            i = -1;

        while (++i < imax) {
            var x = find_findSingle(node[i], matcher);
            if (x != null)
                return x;
        }
        return null;
    }
    if (selector_match(node, matcher)){
        return node;
    }
    node = node[matcher.nextKey];
    return node == null
        ? null
        : find_findSingle(node, matcher)
        ;
};
开发者ID:atmajs,项目名称:MaskJS,代码行数:25,代码来源:traverse.ts

示例8: function

 els_toggleVisibility = function(mix, state) {
     if (mix == null) return;
     if (is_Array(mix)) {
         _arr(mix, state);
         return;
     }
     _single(mix, state);
 };
开发者ID:atmajs,项目名称:MaskJS,代码行数:8,代码来源:utils.ts

示例9: safe_getNodes

	function safe_getNodes(node) {
		var nodes = node.nodes;
		if (nodes == null)
			return null;

		return is_Array(nodes)
			? (nodes)
			: (node.nodes = [ nodes ]);
	}
开发者ID:atmajs,项目名称:MaskJS,代码行数:9,代码来源:TreeWalker.ts

示例10: safe_getType

	function safe_getType(node) {
		var type = node.type;
		if (type != null)
			return type;

		if (is_Array(node)) return Dom.FRAGMENT;
		if (node.tagName != null) return Dom.NODE;
		if (node.content != null) return Dom.TEXTNODE;

		return Dom.NODE;
	}
开发者ID:atmajs,项目名称:MaskJS,代码行数:11,代码来源:TreeWalker.ts


注:本文中的@utils/is.is_Array函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。