本文整理汇总了TypeScript中lodash.lowerFirst函数的典型用法代码示例。如果您正苦于以下问题:TypeScript lowerFirst函数的具体用法?TypeScript lowerFirst怎么用?TypeScript lowerFirst使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了lowerFirst函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getAST
export const addModuleToState = (pathToAppActions: string, moduleName: string): void => {
try {
let file = fs.readFileSync(pathToAppActions, 'utf-8');
getAST(file);
file = insertAt(
file,
findAstNodes(sourceFile, ts.SyntaxKind.ObjectLiteralExpression, true).pop().end + 1,
`\n ${lowerFirst(moduleName)}: {\n ...${upperFirst(moduleName)}DefaultState,\n },`,
);
const interfaces: ts.Node[] = findAstNodes(sourceFile, ts.SyntaxKind.InterfaceDeclaration, true);
file = insertAt(
file,
interfaces.shift().end - 2,
`\n ${lowerFirst(moduleName)}?: I${upperFirst(moduleName)}State;`,
);
file = insertAt(
file,
findAstNodes(sourceFile, ts.SyntaxKind.ImportDeclaration, true).pop().end,
`\nimport { ${upperFirst(moduleName)}DefaultState, I${upperFirst(moduleName)}State } from './${lowerFirst(moduleName)}/state';`,
);
fs.writeFileSync(pathToAppActions, file, { encoding: 'utf-8' });
} catch (e) {
throw new Error(e);
}
};
示例2: parseOptions
// Parse the options in argv and split them into global options and renderer options,
// according to each option definition's `renderer` field. If `partial` is false this
// will throw if it encounters an unknown option.
function parseOptions(definitions: OptionDefinition[], argv: string[], partial: boolean): Partial<CLIOptions> {
let opts: { [key: string]: any };
try {
opts = commandLineArgs(definitions, { argv, partial });
} catch (e) {
assert(!partial, "Partial option parsing should not have failed");
return messageError("DriverCLIOptionParsingFailed", { message: e.message });
}
const options: { rendererOptions: RendererOptions; [key: string]: any } = { rendererOptions: {} };
for (const o of definitions) {
if (!hasOwnProperty(opts, o.name)) continue;
const v = opts[o.name] as string;
if (o.renderer !== undefined) options.rendererOptions[o.name] = v;
else {
const k = _.lowerFirst(
o.name
.split("-")
.map(_.upperFirst)
.join("")
);
options[k] = v;
}
}
return options;
}
示例3: forOwn
forOwn(tokens, (value: any, key: string) => {
urlTemplate = this.replaceRouteTokens(urlTemplate, key, value);
urlTemplate = this.replaceRouteTokens(urlTemplate, lowerFirst(key), value);
});
示例4: lowerFirst
export function lowerFirst(val: string): string {
if (!val) return ''
return _.lowerFirst(val)
}