本文整理汇总了TypeScript中@ember/-internals/utils.getName函数的典型用法代码示例。如果您正苦于以下问题:TypeScript getName函数的具体用法?TypeScript getName怎么用?TypeScript getName使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getName函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: calculateToString
function calculateToString(target: object): string {
let str;
if (!searchDisabled) {
processAllNamespaces();
str = getName(target);
if (str !== void 0) {
return str;
}
let superclass = target;
do {
superclass = Object.getPrototypeOf(superclass);
if (superclass === Function.prototype || superclass === Object.prototype) {
break;
}
str = getName(target);
if (str !== void 0) {
str = `(subclass of ${str})`;
break;
}
} while (str === void 0);
}
return str || '(unknown)';
}
示例2: removeNamespace
export function removeNamespace(namespace: Namespace): void {
let name = getName(namespace) as string;
delete NAMESPACES_BY_ID[name];
NAMESPACES.splice(NAMESPACES.indexOf(namespace), 1);
if (name in context.lookup && namespace === context.lookup[name]) {
context.lookup[name] = undefined;
}
}
示例3: classToString
export function classToString(this: object): string {
let name = getName(this);
if (name !== void 0) {
return name;
}
name = calculateToString(this);
setName(this, name);
return name;
}
示例4: _processNamespace
function _processNamespace(paths: string[], root: Namespace, seen: Set<Namespace>): void {
let idx = paths.length;
let id = paths.join('.');
NAMESPACES_BY_ID[id] = root;
setName(root, id);
// Loop over all of the keys in the namespace, looking for classes
for (let key in root) {
if (!hasOwnProperty.call(root, key)) {
continue;
}
let obj = root[key];
// If we are processing the `Ember` namespace, for example, the
// `paths` will start with `["Ember"]`. Every iteration through
// the loop will update the **second** element of this list with
// the key, so processing `Ember.View` will make the Array
// `['Ember', 'View']`.
paths[idx] = key;
// If we have found an unprocessed class
if (obj && obj.toString === classToString && getName(obj) === void 0) {
// Replace the class' `toString` with the dot-separated path
setName(obj, paths.join('.'));
// Support nested namespaces
} else if (obj && obj.isNamespace) {
// Skip aliased namespaces
if (seen.has(obj)) {
continue;
}
seen.add(obj);
// Process the child namespace
_processNamespace(paths, obj, seen);
}
}
paths.length = idx; // cut out last item
}