本文整理汇总了TypeScript中lodash.kebabCase函数的典型用法代码示例。如果您正苦于以下问题:TypeScript kebabCase函数的具体用法?TypeScript kebabCase怎么用?TypeScript kebabCase使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了kebabCase函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: _getSuperType
private _getSuperType(cls: IClass, superName: string) {
var superClass = projectTypeMap[_.kebabCase(superName)] && projectTypeMap[_.kebabCase(superName)][this.name] || getMappedType(cls, superName);
if (_.startsWith(superClass, this._project.displayName + '.')) {
superClass = superClass.split('.')[1];
}
return superClass;
}
示例2: build
function build(name: string) {
var arr = name.split('/')
var filename = _.kebabCase(name.split('/')[0]) + '.js'
if (arr.length === 3) {
filename = _.kebabCase(name.split('/')[1]) + '.js'
}
var options: any = {
errorDetails: true,
debug: false,
output: {
filename: filename.toLowerCase()
},
resolve: {
extensions: ['', '.webpack.js', '.web.js', '.js']
},
module: {
loaders: [
{ test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader' },
{ test: /\.less$/, exclude: /node_modules/, loader: 'style!css!less' }
]
},
plugins: [
new webpack.optimize.UglifyJsPlugin({minimize: true})
]
}
return gulp.src('./' + name + '.js')
.pipe(webpackStream(options))
.pipe(gulp.dest('./public/assets/js'))
}
示例3: dev
function dev(name: string, callback: () => void) {
//var filename = name.split('/')[1].substr(0, 3) + '-' + name.split('/')[1].substr(3) + '.js'
var filename = _.kebabCase(name.split('/')[1]) + '.js'
var options: any = {
entry: './' + name + '.js',
output: {
path: path.join(__dirname, '../../../public/assets/js'),
publicPath: "/assets/",
filename: "bundle.js"
},
resolve: {
extensions: ['', '.webpack.js', '.web.js', '.js']
},
module: {
loaders: [
{ test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader' },
{ test: /\.less$/, exclude: /node_modules/, loader: 'style!css!less' }
]
},
devtool: "sourcemap",
debug: true
}
var port = 7070
var compiler = webpack(options)
return new WebpackDevServer(compiler, {
stats: {
colors: true
},
historyApiFallback: true
}).listen(port, "localhost", function(err) {
if (err) throw err
callback()
})
}
示例4: createComponent
function* createComponent(req: express.Request, res: express.Response) {
const { name } = yield getPostData(req);
const state: ApplicationState = yield select();
const componentId = kebabCase(name);
const content = `` +
`<component id="${componentId}">\n` +
` <style>\n` +
` </style>\n` +
` <template>\n` +
` Content here\n` +
` </template>\n` +
` <preview name="main" width="600" height="400">\n` +
` <${componentId} />\n` +
` </preview>\n` +
`</component>\n\n`;
const filePath = path.join(getModuleSourceDirectory(state), componentId + "." + PAPERCLIP_FILE_EXTENSION);
if (fs.existsSync(filePath)) {
res.statusCode = 500;
return res.send({
message: "Component exists"
});
}
fs.writeFileSync(
filePath,
content
);
const publicPath = getPublicSrcPath(filePath, state);
yield put(moduleCreated(filePath, publicPath, content));
res.send({ componentId: componentId });
// TODO - create global style if it doesn"t already exist
// check if component name is already taken (must be unique)
// create style based on component name
// create component based on WPC spec (or something like that), basically this:
/*
<template name="test">
<style scoped>
.container {
}
</style>
<div className="container">
</div>
</template>
<preview>
<test />
</preview>
*/
}
示例5: fixturePath
function fixturePath(name: string) {
return path.join(
__dirname,
"__tests__/fixtures/serializedState/v1/",
`${kebabCase(name)}.json`
);
}
示例6: codeFrameError
attributes: attributes.reduce((obj, attr) => {
if (t.isJSXSpreadAttribute(attr)) {
throw codeFrameError(attr.loc, 'JSX 参数暂不支持 ...spread 表达式')
}
const name = attr.name.name === 'className' ? 'class' : attr.name.name
let value: string | boolean = true
let attrValue = attr.value
if (typeof name === 'string') {
if (t.isStringLiteral(attrValue)) {
value = attrValue.value
} else if (t.isJSXExpressionContainer(attrValue)) {
const isBindEvent =
name.startsWith('bind') || name.startsWith('catch')
let { code } = generate(attrValue.expression)
code = code
.replace(/(this\.props\.)|(this\.state\.)/, '')
.replace(/this\./, '')
value = isBindEvent ? code : `{{${code}}}`
if (t.isStringLiteral(attrValue.expression)) {
value = attrValue.expression.value
}
}
if (
componentSpecialProps &&
componentSpecialProps.has(name)
) {
obj[name] = value
} else {
obj[isDefaultComponent && !name.includes('-') && !name.includes(':') ? kebabCase(name) : name] = value
}
}
return obj
}, {}),
示例7: moduleArchive
export function moduleArchive(
moduleCode: ModuleCode,
year: string,
moduleTitle: ModuleTitle = '',
): string {
return `/archive/${moduleCode}/${year.replace('/', '-')}/${kebabCase(moduleTitle)}`;
}
示例8: getInjectableName
export function queryByDirective<T extends Function>( host: ng.IAugmentedJQuery, Type: T ) {
const ctrlName = getInjectableName( Type );
const selector = kebabCase( ctrlName );
const debugElement = host.find( selector );
const componentInstance = debugElement.controller( ctrlName ) as T;
return { debugElement, componentInstance };
}
示例9:
return this.servicesCategoryDao.getNewInstance().then(function(category: ServicesCategory) {
category._isNew = false;
category.id = _.kebabCase(name);
category.name = name;
category.services = services;
category.types = _.map(selectedIds, x => 'service-' + x);
return category;
});
示例10: findInFileAndReplace
export function findInFileAndReplace(filePath: string, patternReplacePair: any) {
if (existsSync(filePath)) {
return Log.error(`File not found: ${filePath}`);
}
let code = readFileSync(filePath, "utf8");
for (let patterns = Object.keys(patternReplacePair), i = patterns.length; i--;) {
const pattern = patterns[i];
const replace = patternReplacePair[pattern];
const allPatterns = [pattern, pascalCase(pattern), kebabCase(pattern), camelCase(pattern)];
const allReplaces = [replace, pascalCase(replace), kebabCase(replace), camelCase(replace)];
for (let j = 0, jl = allPatterns.length; j < jl; ++j) {
const regex = new RegExp(allPatterns[j], "g");
code = code.replace(regex, allReplaces[j]);
}
}
writeFileSync(filePath, code);
}