本文整理汇总了TypeScript中decamelize.default方法的典型用法代码示例。如果您正苦于以下问题:TypeScript decamelize.default方法的具体用法?TypeScript decamelize.default怎么用?TypeScript decamelize.default使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类decamelize
的用法示例。
在下文中一共展示了decamelize.default方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: constructor
constructor(db: string | Db | Promise<Db>, info:MongoResourceDefinition, routes:Routes = MongoResource.defaultRoutes()) {
if (typeof info.id !== 'string') {
info.id = '_id';
}
if (typeof info.idIsObjectId !== 'boolean') {
info.idIsObjectId = (info.id === '_id');
}
super(info, routes);
if (!this.collection) {
this.collection = decamelize('' + this.namePlural, '_');
}
if (typeof db === 'string') {
this[__db] = MongoClient.connect(db as string);
} else {
this[__db] = Promise.resolve(db as Db | Promise<Db>);
}
this[__indexesChecked] = false;
}
示例2: log
public log(name: string, commands: string[]) {
const operation = capitalizeFirstLetter(decamelize(name, ' '))
console.log(chalk.yellow('⤠'), chalk.bold(chalk.yellow(`${operation}:`)))
commands.forEach(command => {
console.log(' ', chalk.yellow(command))
})
console.log('')
}
示例3: fixAttributeName
function fixAttributeName(attributeName) {
attributeName = decamelize(attributeName, '-');
const splitFrom = twoPartProperties.find(p => attributeName.indexOf(p) === 0);
if (splitFrom) {
return `${splitFrom}.${attributeName.substring(splitFrom.length + 1)}`;
}
else {
return attributeName;
}
}
示例4: processElement
export function processElement(element) {
if (!element) { return element; }
if (typeof(element) === 'string') {
return element;
}
else if (typeof(element) === 'number') {
return element.toString();
}
else if (Array.isArray(element)) {
return element.map(processElement);
}
else {
if (element.$$typeof !== XSLFOElementType) {
throw Error(`Not an XSLFOElement, instead of ${typeof(element)}, ${element.$$typeof}`);
}
if (typeof(element.type) === 'string') {
const { children, ...attributes } = element.props;
const processedChildren = processElement(children);
return {
tag: decamelize(element.type, '-'),
attributes,
children: processedChildren
};
}
else {
let childTree;
if (typeof(element.type === 'function')) {
const type = new element.type(element.props);
if (type.render) {
childTree = type.render();
}
else {
childTree = type;
}
}
else {
throw new Error("I don't know what this is...");
}
return processElement(childTree);
}
}
}
示例5: bootstrap
export function bootstrap(ngModule, target, parentState?: any) {
const annotations = target.__annotations__;
const component = annotations.component;
const name = camelcase(component.selector || target.name);
const styleElements: any[] = [];
const headEl = angular.element(document).find('head');
if (map[target.name]) {
return name;
}
map[target.name] = decamelize(component.selector || target.name, '-');
// Bootstrap providers, directives and pipes
(component.providers || []).forEach(provider => utils.bootstrapHelper(ngModule, provider));
(component.directives || []).forEach(directive => utils.bootstrapHelper(ngModule, directive));
(component.pipes || []).forEach(pipe => utils.bootstrapHelper(ngModule, pipe));
// Define the style elements
(component.styles || []).forEach(style => {
styleElements.push(angular.element('<style type="text/css">@charset "UTF-8";' + style + '</style>'));
});
(component.styleUrls || []).forEach(url => {
styleElements.push(angular.element('<link rel="stylesheet" href="' + url + '">'));
});
// Inject the services
utils.inject(target);
const hostBindings = utils.parseHosts(component.host || {});
ngModule
.controller(target.name, target)
.directive(name, ['$compile', ($compile) => {
const directive: any = {
restrict: 'E',
scope: {},
bindToController: {},
controller: target.name,
controllerAs: component.exportAs || '$ctrl',
transclude: true,
compile: () => {
// Prepend all the style elements to the `head` dom element
styleElements.forEach(el => headEl.prepend(el));
return {
pre: (scope, el) => {
// Bind the hosts
utils.bindHostBindings(scope, el, hostBindings, component.exportAs || name);
if (target.prototype.ngOnInit) {
// Call the `ngOnInit` lifecycle hook
const init = $compile(`<div ng-init="${directive.controllerAs}.ngOnInit();"></div>`)(scope);
el.append(init);
}
scope.$on('$destroy', () => {
// Remove all the style elements when destroying the directive
styleElements.forEach(el => el.remove());
if (target.prototype.ngOnDestroy) {
// Call the `ngOnDestroy` lifecycle hook
scope[directive.controllerAs].ngOnDestroy();
}
});
}
}
}
};
// Bind inputs and outputs
utils.bindInput(target, directive);
utils.bindOutput(target, directive);
// Set the template
if (component.template) {
directive.template = component.template;
} else {
directive.templateUrl = component.templateUrl;
}
return directive;
}]);
if (annotations.routes) {
var cmpStates = [];
annotations.routes.forEach(route => {
const name = route.name || route.as;
const routerAnnotations = route.component.__annotations__ && route.component.__annotations__.router;
const state: any = {
name,
url: route.path,
isDefault: route.useAsDefault === true
}
// Bootstrap the route component if it's not the same as the target component
if (route.component.name !== component.name) {
bootstrap(ngModule, route.component, state);
//.........这里部分代码省略.........
示例6: basePath
get basePath(): string {
return '/' + (this.path ? this.path : decamelize('' + this.namePlural, '-'));
}