當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。