本文整理汇总了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');
}
}
示例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";
}
示例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 }];
}
}
}
示例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
}
};
}
示例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);
});
示例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);
});
示例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 }]);
};
示例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);
});
示例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);
});
}
});
示例10: query
query(sql: string, data?: any[]): Promise<Object> {
if (util.isArray(data)) {
return mysql.query(sql, data);
} else {
return mysql.query(sql);
}
}