本文整理匯總了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),
}),
]);
};
示例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);
}
示例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;
}
示例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);
}
//.........這裏部分代碼省略.........