本文整理汇总了TypeScript中@ember/polyfills._WeakSet类的典型用法代码示例。如果您正苦于以下问题:TypeScript _WeakSet类的具体用法?TypeScript _WeakSet怎么用?TypeScript _WeakSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了_WeakSet类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: wrap
export function wrap(func: Function, superFunc: Function) {
if (!hasSuper(func)) {
return func;
}
// ensure an unwrapped super that calls _super is wrapped with a terminal _super
if (!IS_WRAPPED_FUNCTION_SET.has(superFunc) && hasSuper(superFunc)) {
return _wrap(func, _wrap(superFunc, ROOT));
}
return _wrap(func, superFunc);
}
示例2: inspectValue
function inspectValue(value: any | null | undefined, depth: number, seen?: WeakSet<object>) {
let valueIsArray = false;
switch (typeof value) {
case 'undefined':
return 'undefined';
case 'object':
if (value === null) return 'null';
if (isArray(value)) {
valueIsArray = true;
break;
}
// is toString Object.prototype.toString or undefined then traverse
if (value.toString === objectToString || value.toString === undefined) {
break;
}
// custom toString
return value.toString();
case 'function':
return value.toString === functionToString
? value.name
? `[Function:${value.name}]`
: `[Function]`
: value.toString();
case 'string':
return stringify(value);
case 'symbol':
case 'boolean':
case 'number':
default:
return value.toString();
}
if (seen === undefined) {
seen = new WeakSet();
} else {
if (seen.has(value)) return `[Circular]`;
}
seen.add(value);
return valueIsArray
? inspectArray(value, depth + 1, seen)
: inspectObject(value, depth + 1, seen);
}
示例3: _wrap
function _wrap(func: Function, superFunc: Function): Function {
function superWrapper(this: { _super?: Function }) {
let orig = this._super;
this._super = superFunc;
let ret = func.apply(this, arguments);
this._super = orig;
return ret;
}
IS_WRAPPED_FUNCTION_SET.add(superWrapper);
setObservers(superWrapper, getObservers(func));
setListeners(superWrapper, getListeners(func));
return superWrapper;
}
示例4: isProxy
export function isProxy(value: any | undefined | null): value is object {
if (isObject(value)) {
return PROXIES.has(value);
}
return false;
}
示例5: setProxy
export function setProxy(object: object): void {
if (isObject(object)) {
PROXIES.add(object);
}
}
示例6: isProxy
export function isProxy(object: any | undefined | null) {
if (isObject(object)) {
return PROXIES.has(object);
}
return false;
}