當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript util.isArray函數代碼示例

本文整理匯總了TypeScript中util.isArray函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript isArray函數的具體用法?TypeScript isArray怎麽用?TypeScript isArray使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了isArray函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: assertValidRequest

  private static assertValidRequest(rawRequest: any, opts: ValidatorOptions) {
    if (rawRequest === undefined) {
      throw new Error('No data has been provided for user');
    }

    if (rawRequest.canWrite && !utils.isBoolean(rawRequest.canWrite)) {
      throw new Error('canWrite must be of type Boolean');
    }
    if (rawRequest.isAdmin && !utils.isBoolean(rawRequest.isAdmin)) {
      throw new Error('isAdmin must be of type Boolean');
    }
    if (rawRequest.homePath && !utils.isString(rawRequest.homePath)) {
      throw new Error('homePath must be of type String');
    }
    if (rawRequest.allowPaths && !utils.isArray(rawRequest.allowPaths)) {
      throw new Error('allowPaths must be of type String');
    }
    if (rawRequest.allowPaths && rawRequest.allowPaths.some(x => !utils.isString(x))) {
      throw new Error('allowPaths must contain only Strings');
    }
    if (rawRequest.denyPaths && !utils.isArray(rawRequest.denyPaths)) {
      throw new Error('allowPaths must be of type String');
    }
    if (rawRequest.denyPaths && rawRequest.denyPaths.some(x => !utils.isString(x))) {
      throw new Error('denyPaths must contain only Strings');
    }
  }
開發者ID:sebthieti,項目名稱:jogplayer-online,代碼行數:27,代碼來源:permissions.validator.ts

示例2: adminExecuteSql

export async function adminExecuteSql(database: string, sql: SqlBatch): Promise<ISqlDataset[]>|never {
    if (!isString(database))
        throwError("adminExecuteSql(): database должен быть строкой");

    let req: any = {
        sessionId:appState.sessionId,
        windowId:appState.windowId,
        authToken:appState.authToken,
        database:database
    };

    if (isString(sql))
        req.sql = [sql];
    else if (isArray(sql))
        req.sql = sql;
    else
        throwError("adminExecuteSql(): sql должен быть строкой или массивом строк");

    let response: any = await axios.post("api/admin/adminExecuteSql", {xjson:XJSON_stringify(req)});

    if (response.data.error)
        throwError(response.data.error);
    else
        return postProcessSqlResult(response.data);

    throw "fake";
}
開發者ID:KostiaSA,項目名稱:BuhtaClient2019,代碼行數:27,代碼來源:adminExecuteSql.ts

示例3: conf_iterator

//展開object
function* conf_iterator(obj, father = null) {
    //console.log(obj);

    if (typeof obj === 'object') {
        if (!obj.hasOwnProperty('type')) {
            let keys = Object.keys(obj);
            for (let i = 0; i < keys.length; i++) {
                let key = keys[i];
                let newname = "";
                if (father) {
                    newname = [father, key].join('_');
                }
                else {
                    newname = key;
                }
                if (obj[key] !== null) {
                    yield* conf_iterator(obj[key], newname);
                }
            }
        }
        else {
                yield [father, obj];
        }
    }
    else {
        if (util.isArray(obj)) {
            let innerobj = obj[0];
            yield [father, { type: Array, innertype: innerobj.type, required: innerobj.required ? true : false, default: innerobj.default ? [innerobj.default] : [] }];
        }
        else {
            yield [father, { type: obj }];
        }
        
    }
}
開發者ID:goumang2010,項目名稱:NetTxtNote,代碼行數:36,代碼來源:_common_method.ts

示例4: getFares

  public getFares(): SearchResults {
    const prices: FaresIndex = {};
    let cheapestOutwardJourneyPrice = Number.MAX_SAFE_INTEGER;
    let cheapestOutward = "";
    let cheapestInward = "";

    for (const journeyId of Object.keys(this.response.data.fares)) {
      prices[journeyId] = isArray(this.response.data.fares[journeyId])
        ? this.getJourneyFaresForSingle(this.response.data.fares[journeyId] as string[])
        : this.getJourneyFares(this.response.data.fares[journeyId] as JourneyFareMap);

      if (prices[journeyId].price < cheapestOutwardJourneyPrice) {
        cheapestOutwardJourneyPrice = prices[journeyId].price;
        cheapestOutward = journeyId;
        cheapestInward = (prices[journeyId] as ReturnJourneyFares).cheapestInward || "";
      }
    }

    return {
      links: this.response.links,
      query: this.query,
      data: {
        outward: this.response.data.outward,
        inward: this.response.data.inward,
        fares: this.response.data.fares,
        prices,
        cheapestOutward,
        cheapestInward
      }
    };
  }
開發者ID:linusnorton,項目名稱:traintickets.to-frontend,代碼行數:31,代碼來源:JourneyPlanner.ts

示例5: function

 node.on("input", function (msg) {
   var values = [];
   var value;
   if (node.useMappings || (msg.payload && !util.isArray(msg.payload))) {
     // use mappings file to map values to array
     for (var i = 0, len = node.mappings.length; i < len; i++) {
       try {
         value = resolvePath(msg.payload, node.mappings[i]);
       } catch (err) {
         value = null;
       }
       values.push(value);
     }
   } else {
     values = msg.payload;
   }
   var query;
   if (node.useQuery || !msg.query) {
     query = node.query;
   } else {
     query = msg.query;
   }
   var resultAction = msg.resultAction || node.resultAction;
   var resultSetLimit = parseInt(msg.resultSetLimit || node.resultLimit, 10);
   node.server.query(node, query, values, resultAction, resultSetLimit);
 });
開發者ID:markrey,項目名稱:node-red-contrib-oracledb,代碼行數:26,代碼來源:oracledb.ts

示例6: function

     this.parser.parseString(response, function (err, result) {
       if (err) return callback(err);
 
       let messageheaders = result.messageheaders;
 
       if (!isArray(messageheaders.messageheader))
         messageheaders.messageheader = [messageheaders.messageheader];
 
       callback(err, messageheaders);
     });
開發者ID:Codesleuth,項目名稱:esendex-node,代碼行數:10,代碼來源:messages.ts

示例7: expect

 const testSimplePaste = (value: string | string[]) => {
     let text = value;
     let expected = text + "\n";
     if (isArray(text)) {
         [text, expected] = value;
         expected = expected === undefined ? text + "\n" : expected + "\n";
     }
     clipboard.dangerouslyPasteHTML(text);
     expect(quill.getContents().ops).deep.eq([{ insert: expected }]);
 };
開發者ID:vanilla,項目名稱:vanilla,代碼行數:10,代碼來源:ClipboardModule.test.ts

示例8: function

     this.parser.parseString(response, function (err, result) {
       if (err) return callback(err);
       if (accountId) return callback(null, result.account);
       
       let accounts = result.accounts;
 
       if (!isArray(accounts.account))
         accounts.account = [accounts.account];
 
       callback(null, accounts);
     });
開發者ID:Codesleuth,項目名稱:esendex-node,代碼行數:11,代碼來源:accounts.ts

示例9: fsPath

	util.getDartWorkspaceFolders().forEach((f) => {
		const excludedForWorkspace = config.for(f.uri).analysisExcludedFolders;
		const workspacePath = fsPath(f.uri);
		if (excludedForWorkspace && isArray(excludedForWorkspace)) {
			excludedForWorkspace.forEach((folder) => {
				// Handle both relative and absolute paths.
				if (!path.isAbsolute(folder))
					folder = path.join(workspacePath, folder);
				excludeFolders.push(folder);
			});
		}
	});
開發者ID:DanTup,項目名稱:Dart-Code,代碼行數:12,代碼來源:extension.ts

示例10: query

    query(sql: string, data?: any[]): Promise<Object> {


        if (util.isArray(data)) {

            return mysql.query(sql, data);
        } else {

            return mysql.query(sql);

        }


    }
開發者ID:zcg331793187,項目名稱:DownloadYouLike,代碼行數:14,代碼來源:mysqlBase.ts


注:本文中的util.isArray函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。