本文整理匯總了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)
}