当前位置: 首页>>代码示例>>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;未经允许,请勿转载。