当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript lodash.startsWith函数代码示例

本文整理汇总了TypeScript中lodash.startsWith函数的典型用法代码示例。如果您正苦于以下问题:TypeScript startsWith函数的具体用法?TypeScript startsWith怎么用?TypeScript startsWith使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了startsWith函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: _getSuperType

 private _getSuperType(cls: IClass, superName: string) {
     var superClass = projectTypeMap[_.kebabCase(superName)] && projectTypeMap[_.kebabCase(superName)][this.name] || getMappedType(cls, superName);
     if (_.startsWith(superClass, this._project.displayName + '.')) {
         superClass = superClass.split('.')[1];
     }
     return superClass;
 }
开发者ID:david-driscoll,项目名称:atom-typescript-generator,代码行数:7,代码来源:Class.ts

示例2:

 _.forOwn(assignFunctions, (value, key) => {
     if (_.startsWith(t, key)) {
         af = value;
         afKey = key;
         return false;
     }
 });
开发者ID:OyeBenny,项目名称:sarad,代码行数:7,代码来源:parser.ts

示例3: summarize

export function summarize(statement: string): StatementSummary {
  for (const keyword in keywords) {
    if (_.startsWith(_.toLower(statement), _.toLower(keyword))) {
      const tablePattern = keywords[keyword];
      const tableMatch = tablePattern.exec(statement);

      if (!tableMatch) {
        return {
          error: "unable to find table for " + keyword + " statement",
        };
      }

      let table = tableMatch[1];
      if (table[0] === "\"" && table[table.length - 1] === "\"") {
        table = table.slice(1, table.length - 1);
      }

      return {
        statement: keyword,
        table: table,
      };
    }
  }

  return {
    error: "unimplemented",
  };
}
开发者ID:a6802739,项目名称:cockroach,代码行数:28,代码来源:summarize.ts

示例4:

 return _.filter(templates, (template) => {
     if (_.startsWith((template as any).name, collection.collection)) {
         (template as any).label = _.replace((template as any).name, collection.collection + '/', '');
         return template;
     }
     return false;
 });
开发者ID:mactanxin,项目名称:gui,代码行数:7,代码来源:docker-collection-repository.ts

示例5: curryParams

function curryParams(
    baseName: string,
    sourceOverloadId: number,
    sourceOverload: Overload,
    interfaceIndex: number,
): Interface {
    const params = getInterfaceParams(sourceOverload, interfaceIndex);
    const interfaceTypeParams = getInterfaceTypeParams(sourceOverload, interfaceIndex);

    const prevParams = _.without(sourceOverload.params, ...params);
    const prevTypeParams = getUsedTypeParams(prevParams, sourceOverload.typeParams);
    const typeParams = _.without(sourceOverload.typeParams, ...prevTypeParams);
    // 1st overload takes no parameters and just returns the same interface (effectively a no-op)
    // HACK: omit the parameterless overload because it's not very useful, and it causes the build to run out of memory
    // This assumes params.length > 0, which is true because curryParams is only called when params.length >= 2.
    /*const overloads: Overload[] = [{
        typeParams: [],
        params: [],
        returnType: getInterfaceName(baseName, sourceOverloadId, interfaceIndex, interfaceTypeParams),
        jsdoc: sourceOverload.jsdoc,
    }];*/
    const overloads: Overload[] = [];
    const lastOverload = (1 << params.length) - 1;
    for (let i = 1; i <= lastOverload; ++i) {
        // xxxx i = number of parameters used by this overload
        // const totalCombinations = nCk(params.length, i);
        // i = binary representation of which parameters are used for this overload (reversed), e.g.
        //   1 = 0001 -> 1000 = 1st parameter
        //   6 = 1010 -> 0101 = 2nd and 4th parameters
        const currentParams = params.map((p, j) => (i & (1 << j)) ? p : `${getParamName(p)}: __`);
        while (currentParams.length > 0 && _.last(currentParams)!.endsWith("__"))
            currentParams.pop(); // There's no point in passing a placeholder as the last parameter, so don't allow it.

        const usedTypeParams = i < lastOverload ? getUsedTypeParams(currentParams, typeParams) : typeParams;
        const combinedIndex = combineIndexes(interfaceIndex, i);
        const passTypeParams = getInterfaceTypeParams(sourceOverload, combinedIndex);
        const currentReturnType = i < lastOverload ? getInterfaceName(baseName, sourceOverloadId, combinedIndex, passTypeParams) : sourceOverload.returnType;

        overloads.push({
            typeParams: _.cloneDeep(usedTypeParams),
            params: currentParams,
            returnType: currentReturnType,
            jsdoc: interfaceIndex === 0 ? sourceOverload.jsdoc : "",
        });
    }
    const interfaceDef: Interface = {
        name: getInterfaceName(baseName, sourceOverloadId, interfaceIndex, []),
        typeParams: _.cloneDeep(interfaceTypeParams),
        overloads,
        constants: [],
    };
    // Remove the `extends` constraint from interface type parameters, because sometimes they extend things that aren't passed to the interface.
    for (const typeParam of interfaceDef.typeParams) {
        // 1. retain `extends keyof X` constraints so that TObject[TKey] still works.
        // 2. retain `any[]` constraints so that variadic generics work.
        if (!_.startsWith(typeParam.extends, "keyof ") && typeParam.extends !== "any[]")
            delete typeParam.extends;
    }
    return interfaceDef;
}
开发者ID:csrakowski,项目名称:DefinitelyTyped,代码行数:60,代码来源:generate-fp.ts

示例6: BigNumber

 const wrapIfBigNumber = (value: ContractEventArg): ContractEventArg => {
     // HACK: The old version of BigNumber used by Web3@0.19.0 does not support the `isBigNumber`
     // and checking for a BigNumber instance using `instanceof` does not work either. We therefore
     // check if the value constructor is a bignumber constructor.
     const isWeb3BigNumber = _.startsWith(value.constructor.toString(), 'function BigNumber(');
     return isWeb3BigNumber ?  new BigNumber(value) : value;
 };
开发者ID:linki,项目名称:0x.js,代码行数:7,代码来源:event_utils.ts

示例7: function

        var fetch = function() {
          var action = last(actionName.match(/(\$[c|m]:)?(.*)/))
          var promise
          if (startsWith(actionName, '$m')) {
            promise = subject.$m(action, params)
          }
          else {
            promise = subject.$c(action, params)
          }

          promise
            .then(function(pageResult) {
              page = page + 1
              merge(params, { page: page })
              result.objects = result.objects.concat(pageResult.objects)

              if ((page <= 100) && (page <= (pageResult.headers && pageResult.headers['x-total-pages'] || 0))) {
                fetch()
              }
              else {
                resolve(result)
              }
              return true
            }, function() {
              reject(null)
            })
        }
开发者ID:mediapeers,项目名称:chinchilla,代码行数:27,代码来源:chinchilla.ts

示例8: convertSchemaIdToKey

function convertSchemaIdToKey(schemaId: string) {
    let result = schemaId;
    if (_.startsWith(result, '/')) {
        result = result.substr(1);
    }
    result = `${result}Schema`;
    return result;
}
开发者ID:ewingrj,项目名称:0x-monorepo,代码行数:8,代码来源:postman_environment_factory.ts

示例9: function

  $('#manifest_url').on('keyup', function () {
    let url: string = $(this).val().trim();
    const $result = $('#manifest_key');

    // oldSheet: 'https://docs.google.com/spreadsheet/ccc?key={key}'
    // newSheet: 'https://docs.google.com/spreadsheets/d/{key}'

    if (!_.startsWith(url, 'https://docs.google.com/spreadsheet')) {
      if (_.startsWith('https://docs.google.com/spreadsheet', url)) {
        $result.val('');
      } else {
        $result.val('Invalid URL');
      }

      return;
    }

    url = url.slice(35); // 'https://docs.google.com/spreadsheet'.length

    let gidMatch = url.match(/[#?&]gid=(.*)([#&]|$)/);
    let gid: string = '';
    if (gidMatch) {
      gid = gid[1];
      if (0 !== +gid) {
        gid = `&gid=${gid}`;
      } else {
        gid = '';
      }
    }

    if (_.startsWith(url, '/ccc?')) {
      // ye olde URL style
      const matches = url.match(/\?(.*&)?key=([^&#]*)([#&]|$)/)

      if (matches) {
        $result.val(matches[2] + gid);
      } else {
        $result.val('Invalid URL');
      }
    } else if (_.startsWith(url, '/s/d')) {
      // new URL style
      url = url.slice(4); // 's/d/'.length

      $result.val(url.replace(/[#?/].*$/, '')) + gid
    }
  });
开发者ID:bgotink,项目名称:IngressIdentity,代码行数:46,代码来源:help.ts

示例10: function

			sails.router.bind(route, function (req: any, res: any, next: Function) {

				let protocol: any = _.startsWith(swagger.host, 'http') ? '' : 'http://';
				let targetUrlTemplate: any = protocol + swagger.host + ( swagger.basePath || '' ) + path;
				let templateFn: any = _.template(targetUrlTemplate, {
					interpolate: /{([\s\S]+?)}/g
				});

				let params: any = req.allParams();

				let targetUrl: any = templateFn(params);

				let headers: any = req.headers;

				_.unset(headers, 'cookie');
				_.unset(headers, 'host');
				_.unset(headers, 'user-agent');
				_.unset(headers, 'referer');

				let reqOut: any = {
					url: targetUrl,
					method: vertex,
					body: ( req.body || null ),
					qs: req.transport != 'socket.io' ? req.query : req.body,
					json: true,
					headers: headers
				};

				let $request: any = sails.$request(req.session) || request;
				$request(reqOut, function (err: Error, message: any, body: any): void {

					console.log('*************************');
					console.log('' + vertex + ' ' + targetUrl);
					console.log('-------------------------');
					console.dir(headers);
					console.log('=========================');
					console.dir(body);

					if (params && body && !params.id && !_.isArray(body)) {
						body.id = body.id || uuid.v4();
						body = [body];
					}
					else if (_.isArray(body)) {
						_.each(body, function (item: any) {
							item.id = item.id || uuid.v4();
						});
					}

					if (!err) {
						res
							.status(message.statusCode)
							.send(body);
					}
					else {
						res.serverError(err);
					}
				})
			})
开发者ID:pmoelgaard,项目名称:nx-sails-swagger-api,代码行数:58,代码来源:index.ts


注:本文中的lodash.startsWith函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。