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


TypeScript util.isString函數代碼示例

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


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

示例1: 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

示例2: generateSqlFromTemplate

export async function generateSqlFromTemplate(dialect: SqlDialect, sqlTemplate: string, paramsObj: any = {}): Promise<string> {
    if (!isString(sqlTemplate))
        throwError( "adminExecuteSql(): параметр 'sqlTemplate' должен быть строкой");

    if (!isString(dialect))
        throwError( "adminExecuteSql(): параметр 'dialect' должен быть строкой");

    let req = {
        sessionId:appState.sessionId,
        windowId:appState.windowId,
        authToken:appState.authToken,
        dialect: dialect,
        sqlTemplate: sqlTemplate,
//        paramsObj: XJSON_stringify(paramsObj),
        paramsObj: paramsObj,
    };

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

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

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

示例3: assertValidRequest

 private static assertValidRequest(rawRequest: any, opts: ValidatorOptions) {
   if (rawRequest === undefined) {
     throw new Error('No data has been provided for favorite');
   }
   if (opts.checkAllRequiredFields || opts.checkAllRequiredFieldsButId && !utils.isString(rawRequest.name)) {
     throw new Error('Name must be specified and of type String');
   }
   if (opts.checkAllRequiredFields || opts.checkAllRequiredFieldsButId && !utils.isString(rawRequest.folderPath)) {
     throw new Error('folderPath must be specified and of type String');
   }
 }
開發者ID:sebthieti,項目名稱:jogplayer-online,代碼行數:11,代碼來源:favorite.validator.ts

示例4: 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

示例5: formatDocument

export async function formatDocument(params: DocumentFormattingParams) {
  const edits: TextEdit[] = []
  const co = await clientAndObjfromUrl(params.textDocument.uri, true)
  if (co) {
    const newText = await co.client.prettyPrinter(co.source)
    if (isString(newText) && newText) {
      const diff = Math.abs(newText.length - co.source.length) / newText.length
      // sanity check: if length changed more than 20% ingore
      if (diff <= 0.2) {
        const lines = co.source.split(/\n/)
        const character = lines[lines.length - 1].length
        edits.push({
          range: {
            start: { line: 0, character: 0 },
            end: {
              line: lines.length,
              character
            }
          },
          newText
        })
      }
    }
  }
  return edits
}
開發者ID:valdirmendesgt,項目名稱:vscode_abap_remote_fs,代碼行數:26,代碼來源:documentformatter.ts

示例6: toInt

export function toInt(raw: any): number {
  if (isNaN(raw)) return 0
  if (isNumber(raw)) return Math.floor(raw)
  if (!raw && !isString(raw)) return 0
  const n = Number.parseInt(raw, 10)
  if (isNaN(n)) return 0
  return n
}
開發者ID:valdirmendesgt,項目名稱:vscode_abap_remote_fs,代碼行數:8,代碼來源:utilities.ts

示例7: assertValidRequest

 private static assertValidRequest(rawRequest: any, opts: ValidatorOptions) {
   if (rawRequest === undefined) {
     throw new Error('No data has been provided for user');
   }
   if (rawRequest.isActive && !utils.isBoolean(rawRequest.isActive)) {
     throw new Error('isActive must be of type Boolean');
   }
   if (rawRequest.username && !utils.isString(rawRequest.username)) {
     throw new Error('username must be of type String');
   }
   if (rawRequest.fullName && !utils.isString(rawRequest.fullName)) {
     throw new Error('username must be of type String');
   }
   if (rawRequest.email && !utils.isString(rawRequest.email)) {
     throw new Error('email must be of type String');
   }
   if (rawRequest.password && !utils.isString(rawRequest.password)) {
     throw new Error('hashedPassword must be of type String');
   }
 }
開發者ID:sebthieti,項目名稱:jogplayer-online,代碼行數:20,代碼來源:user.validator.ts

示例8: executeSql

export async function executeSql(sqlTemplatePath: string, paramsObj: any = {}, dbName: string = config.mainDatabaseName): Promise<ISqlDataset[]> {
    if (!isString(sqlTemplatePath)) {
        let msg = "executeSql(): параметр 'sqlTemplatePath' должен быть строкой";
        console.error(msg, sqlTemplatePath);
        throwError( msg);
    }

    if (!isString(dbName)) {
        let msg = "executeSql(): параметр 'dbName' должен быть строкой";
        console.error(msg, dbName);
        throwError( msg);
    }

    if (typeof paramsObj !== "object") {
        throwError("executeSql(): параметр 'paramsObj' должен быть объектом", paramsObj);
        // let msg = "executeSql(): параметр 'paramsObj' должен быть объектом";
        // console.error(msg, paramsObj);
        // throw msg;
    }

    let req = {
        sessionId:appState.sessionId,
        windowId:appState.windowId,
        authToken:appState.authToken,
        sqlTemplatePath: sqlTemplatePath,
//        paramsObj: XJSON_stringify(paramsObj),
        paramsObj: paramsObj,
        dbName: dbName
    };

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

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

    throw "fake";

}
開發者ID:KostiaSA,項目名稱:BuhtaClient2019,代碼行數:40,代碼來源:executeSql.ts

示例9: isString

export const log = (...params: any) => {
  let msg = ""
  for (const x of params) {
    try {
      if (isError(x)) msg += `\nError ${x.name}\n${x.message}\n\n${x.stack}\n`
      else msg += isString(x) ? x : JSON.stringify(x)
    } catch (e) {
      msg += x.toString()
    }
    msg += " "
  }
  connection.console.log(msg)
}
開發者ID:valdirmendesgt,項目名稱:vscode_abap_remote_fs,代碼行數:13,代碼來源:clientManager.ts

示例10: dump

function dump(out: any): void {
    let outText = "";
    if (isBoolean(out)) {
        outText = "| Boolean: ";
    }
    if (isNumber(out)) {
        outText = "| Number: ";
    }
    if (isString(out)) {
        outText = "| String: ";
    }
    if (isArray(out)) {
        outText = "| Array: ";
    }

    console.log(outText, out);
}
開發者ID:zsala,項目名稱:testing_typescript,代碼行數:17,代碼來源:types.ts


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