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


TypeScript strings.camelize方法代碼示例

本文整理匯總了TypeScript中@angular-devkit/core.strings.camelize方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript strings.camelize方法的具體用法?TypeScript strings.camelize怎麽用?TypeScript strings.camelize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在@angular-devkit/core.strings的用法示例。


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

示例1: return

  return (tree: Tree, context: SchematicContext) => {
    if (!options.name) {
      throw new SchematicsException('name option is required.');
    }

    let collectionPath: Path | undefined;
    try {
      const packageJsonContent = tree.read('/package.json');
      if (packageJsonContent) {
        const packageJson = JSON.parse(packageJsonContent.toString('utf-8'));
        if ('schematics' in packageJson) {
          const p = normalize(packageJson['schematics']);
          if (tree.exists(p)) {
            collectionPath = p;
          }
        }
      }
    } catch (_) {
    }

    let source = apply(url('./schematic-files'), [
        applyTemplates({
          ...options as object,
          coreVersion,
          schematicsVersion,
          dot: '.',
          camelize: strings.camelize,
          dasherize: strings.dasherize,
        }),
      ]);

    // Simply create a new schematic project.
    if (!collectionPath) {
      collectionPath = normalize('/' + options.name + '/src/collection.json');
      source = apply(url('./project-files'), [
        applyTemplates({
          ...options as object,
          coreVersion,
          schematicsVersion,
          dot: '.',
          camelize: strings.camelize,
          dasherize: strings.dasherize,
        }),
        mergeWith(source),
        move(options.name),
      ]);

      context.addTask(new NodePackageInstallTask(options.name));
    }

    return chain([
      mergeWith(source),
      addSchematicToCollectionJson(collectionPath, strings.dasherize(options.name), {
        description: 'A blank schematic.',
        factory: './' + strings.dasherize(options.name) + '/index#' +
          strings.camelize(options.name),
      }),
    ]);
  };
開發者ID:angular,項目名稱:angular-cli,代碼行數:59,代碼來源:factory.ts

示例2: buildSelector

function buildSelector(options: DirectiveOptions, projectPrefix: string) {
  let selector = options.name;
  if (options.prefix) {
    selector = `${options.prefix}-${selector}`;
  } else if (options.prefix === undefined && projectPrefix) {
    selector = `${projectPrefix}-${selector}`;
  }

  return strings.camelize(selector);
}
開發者ID:angular,項目名稱:angular-cli,代碼行數:10,代碼來源:index.ts

示例3: _getOptionFromName

function _getOptionFromName(name: string, options: Option[]): Option | undefined {
  const cName = strings.camelize(name);

  for (const option of options) {
    if (option.name == name || option.name == cName) {
      return option;
    }

    if (option.aliases.some(x => x == name || x == cName)) {
      return option;
    }
  }

  return undefined;
}
開發者ID:baconwaffles,項目名稱:angular-cli,代碼行數:15,代碼來源:parser.ts

示例4: _assignOption

function _assignOption(
  arg: string,
  nextArg: string | undefined,
  { options, parsedOptions, leftovers, ignored, errors, warnings }: {
    options: Option[],
    parsedOptions: Arguments,
    positionals: string[],
    leftovers: string[],
    ignored: string[],
    errors: string[],
    warnings: string[],
  },
) {
  const from = arg.startsWith('--') ? 2 : 1;
  let consumedNextArg = false;
  let key = arg.substr(from);
  let option: Option | null = null;
  let value: string | undefined = '';
  const i = arg.indexOf('=');

  // If flag is --no-abc AND there's no equal sign.
  if (i == -1) {
    if (key.startsWith('no')) {
      // Only use this key if the option matching the rest is a boolean.
      const from = key.startsWith('no-') ? 3 : 2;
      const maybeOption = _getOptionFromName(strings.camelize(key.substr(from)), options);
      if (maybeOption && maybeOption.type == 'boolean') {
        value = 'false';
        option = maybeOption;
      }
    }

    if (option === null) {
      // Set it to true if it's a boolean and the next argument doesn't match true/false.
      const maybeOption = _getOptionFromName(key, options);
      if (maybeOption) {
        value = nextArg;
        let shouldShift = true;

        if (value && value.startsWith('-')) {
          // Verify if not having a value results in a correct parse, if so don't shift.
          if (_coerce(undefined, maybeOption) !== undefined) {
            shouldShift = false;
          }
        }

        // Only absorb it if it leads to a better value.
        if (shouldShift && _coerce(value, maybeOption) !== undefined) {
          consumedNextArg = true;
        } else {
          value = '';
        }
        option = maybeOption;
      }
    }
  } else {
    key = arg.substring(0, i);
    option = _getOptionFromName(_removeLeadingDashes(key), options) || null;
    if (option) {
      value = arg.substring(i + 1);
    }
  }

  if (option === null) {
    if (nextArg && !nextArg.startsWith('-')) {
      leftovers.push(arg, nextArg);
      consumedNextArg = true;
    } else {
      leftovers.push(arg);
    }
  } else {
    const v = _coerce(value, option, parsedOptions[option.name]);
    if (v !== undefined) {
      if (parsedOptions[option.name] !== v) {
        if (parsedOptions[option.name] !== undefined) {
          warnings.push(
            `Option ${JSON.stringify(option.name)} was already specified with value `
            + `${JSON.stringify(parsedOptions[option.name])}. The new value ${JSON.stringify(v)} `
            + `will override it.`,
          );
        }

        parsedOptions[option.name] = v;

        if (option.deprecated !== undefined && option.deprecated !== false) {
          warnings.push(`Option ${JSON.stringify(option.name)} is deprecated${
            typeof option.deprecated == 'string' ? ': ' + option.deprecated : '.'}`);
        }
      }
    } else {
      let error = `Argument ${key} could not be parsed using value ${JSON.stringify(value)}.`;
      if (option.enum) {
        error += ` Valid values are: ${option.enum.map(x => JSON.stringify(x)).join(', ')}.`;
      } else {
        error += `Valid type(s) is: ${(option.types || [option.type]).join(', ')}`;
      }

      errors.push(error);
      ignored.push(arg);
    }
//.........這裏部分代碼省略.........
開發者ID:DevIntent,項目名稱:angular-cli,代碼行數:101,代碼來源:parser.ts

示例5:

 .map(b => coreStrings.camelize(b))
開發者ID:rexebin,項目名稱:angular-cli,代碼行數:1,代碼來源:command-runner.ts


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