• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript decamelize类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中decamelize的典型用法代码示例。如果您正苦于以下问题:TypeScript decamelize类的具体用法?TypeScript decamelize怎么用?TypeScript decamelize使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了decamelize类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: 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('')
 }
开发者ID:mirego,项目名称:accent-cli,代码行数:8,代码来源:hook-runner.ts


示例2: 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;
    }
}
开发者ID:luggage66,项目名称:jsx-xsl-fo,代码行数:12,代码来源:implementation.ts


示例3: 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);
        }
    }
}
开发者ID:luggage66,项目名称:jsx-xsl-fo,代码行数:49,代码来源:implementation.ts


示例4: 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;
 }
开发者ID:vivocha,项目名称:arrest,代码行数:18,代码来源:resource.ts


示例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);
//.........这里部分代码省略.........
开发者ID:Ledragon,项目名称:angular2-polyfill,代码行数:101,代码来源:component.ts


示例6: basePath

 get basePath(): string {
   return '/' + (this.path ? this.path : decamelize('' + this.namePlural, '-'));
 }
开发者ID:vivocha,项目名称:arrest,代码行数:3,代码来源:resource.ts



注:本文中的decamelize类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript deep-equal类代码示例发布时间:2022-05-28
下一篇:
TypeScript debug类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap