本文整理汇总了TypeScript中lodash.camelCase函数的典型用法代码示例。如果您正苦于以下问题:TypeScript camelCase函数的具体用法?TypeScript camelCase怎么用?TypeScript camelCase使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了camelCase函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: processFile
async function processFile(filePath) {
if (!fs.existsSync(filePath)) {
return
}
const dirname = path.dirname(filePath)
const distDirname = dirname.replace(sourceDir, tempDir)
let distPath = path.format({dir: distDirname, base: path.basename(filePath)})
const code = fs.readFileSync(filePath, 'utf-8')
if (REG_STYLE.test(filePath)) {
// do something
} else if (REG_SCRIPTS.test(filePath)) {
if (REG_TYPESCRIPT.test(filePath)) {
distPath = distPath.replace(/\.(tsx|ts)(\?.*)?$/, '.js')
}
Util.printLog(processTypeEnum.COMPILE, _.camelCase(path.extname(filePath)).toUpperCase(), filePath)
// transformJSCode
const transformResult = transformJSCode({code, filePath, isEntryFile: isEntryFile(filePath), projectConfig})
const jsCode = transformResult.code
fs.ensureDirSync(distDirname)
fs.writeFileSync(distPath, Buffer.from(jsCode))
// compileDepStyles
const styleFiles = transformResult.styleFiles
depTree[filePath] = styleFiles
await compileDepStyles(filePath, styleFiles)
} else {
fs.ensureDirSync(distDirname)
fs.copySync(filePath, distPath)
Util.printLog(processTypeEnum.COPY, _.camelCase(path.extname(filePath)).toUpperCase(), filePath)
}
}
示例2: initProjectFile
function initProjectFile() {
// generator app.json
const appJsonObject = Object.assign({
name: _.camelCase(require(path.join(process.cwd(), 'package.json')).name)
}, rnConfig.appJson)
// generator .${tempPath}/package.json TODO JSON.parse 这种写法可能会有隐患
const pkgTempObj = JSON.parse(
ejs.render(pkgTmpl, {
projectName: _.camelCase(projectConfig.projectName),
version: Util.getPkgVersion()
}
).replace(/(\r\n|\n|\r|\s+)/gm, '')
)
const dependencies = require(path.join(process.cwd(), 'package.json')).dependencies
pkgTempObj.dependencies = Object.assign({}, pkgTempObj.dependencies, dependencies)
const indexJsStr = `
import {AppRegistry} from 'react-native';
import App from './${entryBaseName}';
import {name as appName} from './app.json';
AppRegistry.registerComponent(appName, () => App);`
fs.writeFileSync(path.join(tempDir, 'index.js'), indexJsStr)
Util.printLog(processTypeEnum.GENERATE, 'index.js', path.join(tempPath, 'index.js'))
fs.writeFileSync(path.join(tempDir, 'app.json'), JSON.stringify(appJsonObject, null, 2))
Util.printLog(processTypeEnum.GENERATE, 'app.json', path.join(tempPath, 'app.json'))
fs.writeFileSync(path.join(tempDir, 'package.json'), JSON.stringify(pkgTempObj, null, 2))
Util.printLog(processTypeEnum.GENERATE, 'package.json', path.join(tempPath, 'package.json'))
}
示例3: parseFunctionMetadata
export function parseFunctionMetadata({ prefixMap, name }) {
let typeName;
let methodName;
const matchedPrefix = Object.keys(prefixMap).find(
prefix => name.indexOf(prefix) === 0
);
if (matchedPrefix) {
typeName = prefixMap[matchedPrefix];
methodName = camelCase(name.replace(matchedPrefix, ''));
} else {
// The type name is the word before the first dash capitalized. If the type
// is Vim, then it a editor-global method which will be attached to the Nvim
// class.
const parts = name.split('_');
typeName = capitalize(parts[0]);
methodName = camelCase(
(typeName === 'Ui' ? parts : parts.slice(1)).join('_')
);
}
return {
typeName,
methodName,
};
}
示例4:
return this.builderReady.then(() => {
this.form.title = this.formTitle.nativeElement.value;
this.form.display = this.formType.nativeElement.value;
this.form.components = this.builder.formio.schema.components;
if (this.config.tag) {
this.form.tags = this.form.tags || [];
this.form.tags.push(this.config.tag);
this.form.tags = _.uniq(this.form.tags);
}
if (!this.form._id) {
this.form.name = _.camelCase(this.form.title).toLowerCase();
this.form.path = this.form.name;
}
return this.service.formio.saveForm(this.form).then(form => {
this.form = this.service.setForm(form);
this.loading = false;
return this.form;
}).catch(err => {
this.loading = false;
// Catch if a form is returned as an error. This is a conflict.
if (err._id && err.type) {
throw err;
}
this.alerts.setAlert({type: 'danger', message: (err.message || err)});
});
});
示例5: getFieldData
function getFieldData(field: Field): IColumnFieldData {
const fieldName = field.fieldName;
const fieldProps: IFieldProperties = field.properties;
const modelMeta: IFieldMeta = getFieldMeta(config.model, fieldName);
if (!modelMeta.list) { return null as IColumnFieldData; }
let columnCode = "";
const prefixCode = "";
let hasValue = true;
let render = null;
let isRenderInline = true;
switch (fieldProps.type) {
case FieldType.Text:
case FieldType.Password:
case FieldType.File:
case FieldType.Relation:
case FieldType.List:
case FieldType.Object:
hasValue = false;
break;
// case FieldType.String:
// case FieldType.Tel:
// case FieldType.EMail:
// case FieldType.URL:
// case FieldType.Number:
// case FieldType.Integer:
// case FieldType.Float:
// break;
case FieldType.Timestamp:
isRenderInline = false;
render = `dateTime.setTime(r.${fieldName});
return dateTime.format("Y/m/d");`;
break;
case FieldType.Boolean:
render = `tr(r.${fieldName} ? "yes" : "no")`;
break;
case FieldType.Enum:
if (modelMeta.enum) {
// const listClass = file.getClass();
const enumName = camelCase(modelMeta.enum.options[0].split(".")[0]) + "Options";
const options = modelMeta.enum.options.map((option, index) => `${fieldProps.enum[index]}: tr("enum_${option.split(".")[1].toLowerCase()}")`);
// code = `const ${enumName} = {${options.join(', ')}};`;
render = `tr(${enumName}[r.${fieldName}])`;
// listClass.addProperty({ name: enumName, access: "private", defaultValue: `{${options.join(", ")}}` });
}
break;
}
if (hasValue) {
if (render) {
columnCode = isRenderInline ? `{ title: tr("fld_${fieldName}"), render: (r: ${model.interfaceName}) => ${render} }` : `{
title: tr("fld_${fieldName}"),
render: (r: ${model.interfaceName}) => {
${render}
}
}`;
} else {
columnCode = `{ name: "${fieldName}", title: tr("fld_${fieldName}") }`;
}
}
return { column: columnCode, code: prefixCode };
}
示例6: mapToActionCreator
mapToActionCreator(stream, actionType) {
const actionCreator = this.actionCreators[camelCase(actionType)];
if (!!actionCreator === false) {
throw new Error(`No action creator defined for this action: ${actionType}`);
}
return stream.map(actionCreator);
}
示例7: getId
createCustomElement: ({ selectedNodes }: Props) => (
name = '',
description = '',
image = ''
): void => {
if (selectedNodes.length) {
const content = JSON.stringify({ selectedNodes });
const customElement = {
id: getId('custom-element'),
name: camelCase(name),
displayName: name,
help: description,
image,
content,
};
customElementService
.create(customElement)
.then(() =>
notify.success(
`Custom element '${customElement.displayName || customElement.id}' was saved`
)
)
.catch((result: Http2ServerResponse) =>
notify.warning(result, {
title: `Custom element '${customElement.displayName ||
customElement.id}' was not saved`,
})
);
}
},
示例8: init
(async function init() {
for (const commandPath of commandsPath) {
const className = upperFirst(camelCase(commandPath.replace(/\./g, '-')));
if (
process.env.NODE_ENV !== 'production' &&
filter &&
`${filter}.command` !== commandPath
) {
continue;
}
const classInterface = (await import(`./commands/${commandPath}`))[
className
];
const commandObject = new classInterface();
try {
yargs.command(commandObject);
} catch (e) {
console.log('ERROR ON COMMAND');
console.log(e);
}
}
yargs
.demandCommand(1)
.strict()
.help('h')
.alias('v', 'version').argv;
})();
示例9:
source.split(/\s*;\s*/g).forEach(kv => {
const [name, value] = kv.split(":");
if (!name || !value) {
return;
}
style[camelCase(name.trim())] = value.trim();
});
示例10: compose
export function compose(): FrontendLibs {
const api = new AxiosRestAPIAdapter(chrome.getXsrfToken(), chrome.getBasePath());
const esAdapter = new RestElasticsearchAdapter(api, INDEX_NAMES.BEATS);
const elasticsearchLib = new ElasticsearchLib(esAdapter);
const configBlocks = new ConfigBlocksLib(
new RestConfigBlocksAdapter(api),
translateConfigSchema(configBlockSchemas)
);
const tags = new TagsLib(new RestTagsAdapter(api), elasticsearchLib);
const tokens = new RestTokensAdapter(api);
const beats = new BeatsLib(new RestBeatsAdapter(api), elasticsearchLib);
const framework = new FrameworkLib(
new KibanaFrameworkAdapter(
camelCase(PLUGIN.ID),
management,
routes,
chrome.getBasePath,
onKibanaReady,
XPackInfoProvider,
chrome.getKibanaVersion()
)
);
const libs: FrontendLibs = {
framework,
elasticsearch: elasticsearchLib,
tags,
tokens,
beats,
configBlocks,
};
return libs;
}