@creditkarma/async-scope
Advanced tools
Comparing version 0.0.10 to 0.0.11
@@ -1,2 +0,2 @@ | ||
import { IAsyncOptions, IAsyncScope } from './types'; | ||
import { IAsyncOptions, IAsyncScope, ISizeProfile } from './types'; | ||
export declare class AsyncScope implements IAsyncScope { | ||
@@ -16,2 +16,3 @@ static debug(msg: string, ...args: Array<any>): void; | ||
lineage(): Array<number>; | ||
size(): ISizeProfile; | ||
private removeOldest(); | ||
@@ -18,0 +19,0 @@ private addNode(asyncId, parentId); |
@@ -73,2 +73,8 @@ "use strict"; | ||
} | ||
size() { | ||
return { | ||
size: this.asyncMap.size, | ||
maxSize: this.maxSize, | ||
}; | ||
} | ||
removeOldest() { | ||
@@ -75,0 +81,0 @@ const oldestId = this.asyncMap.oldestId; |
@@ -30,1 +30,5 @@ import { IAsyncHooks } from '@creditkarma/async-hooks'; | ||
} | ||
export interface ISizeProfile { | ||
size: number; | ||
maxSize: number; | ||
} |
{ | ||
"name": "@creditkarma/async-scope", | ||
"version": "0.0.10", | ||
"version": "0.0.11", | ||
"description": "A thread local approximation built on async hooks, written in TypeScript", | ||
@@ -5,0 +5,0 @@ "main": "dist/main/index.js", |
@@ -106,2 +106,22 @@ # Async Scope | ||
#### `size` | ||
Returns an object describing the size of the current store. | ||
```typescript | ||
interface ISizeProfile { | ||
size: number | ||
maxSize: number | ||
} | ||
``` | ||
The object contains two properties. First `size` is the current number of scopes being tracked by the store. Second `maxSize` is the maximum number the store will hold before it starts ejecting old scopes. | ||
```typescript | ||
import { AsyncScope } from '@creditkarma/async-scope' | ||
const asyncScope: AsyncScope = new AsyncScope() | ||
console.log(asyncScope.size()) | ||
``` | ||
## Contributing | ||
@@ -108,0 +128,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
36329
308
134