本文整理匯總了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('')
}
示例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;
}
}
示例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);
}
}
}
示例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;
}
示例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, '-'));
}