@dxos/async
Advanced tools
Comparing version 1.0.2-alpha.0 to 2.10.2
{ | ||
"name": "@dxos/async", | ||
"version": "1.0.2-alpha.0", | ||
"description": "Basic async utils", | ||
"files": [ | ||
"dist" | ||
], | ||
"main": "dist/es/index.js", | ||
"types": "dist/es/index.d.ts", | ||
"scripts": { | ||
"build": "tsc", | ||
"build:watch": "yarn run build --watch", | ||
"clean": "rm -rf dist", | ||
"coverage": "npm test -- --coverage", | ||
"coveralls": "npm run coverage && cat ./coverage/lcov.info | coveralls", | ||
"lint": "eslint 'src/**/*.{js,ts}'", | ||
"lint:lockfile": "lockfile-lint --path yarn.lock --allowed-hosts yarn npm codeload.github.com --validate-https", | ||
"prepublishOnly": "npm run test && npm run build", | ||
"test": "jest --verbose --passWithNoTests", | ||
"posttest": "npm run lint" | ||
}, | ||
"license": "AGPL-3.0", | ||
"jest": { | ||
"preset": "ts-jest/presets/js-with-ts", | ||
"testEnvironment": "node", | ||
"modulePathIgnorePatterns": [ | ||
"dist" | ||
] | ||
}, | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"@types/jest": "^26.0.10", | ||
"@typescript-eslint/eslint-plugin": "^3.9.0", | ||
"@typescript-eslint/parser": "^3.9.0", | ||
"coveralls": "^3.0.7", | ||
"jest": "^26.4.2", | ||
"lockfile-lint": "^4.3.7", | ||
"semistandard": "^14.2.0", | ||
"ts-jest": "^26.2.0", | ||
"typescript": "^3.9.7" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"eslintConfig": { | ||
"parser": "@typescript-eslint/parser", | ||
"extends": [ | ||
"eslint-config-semistandard", | ||
"plugin:@typescript-eslint/recommended" | ||
], | ||
"rules": { | ||
"no-unused-vars": "off", | ||
"no-useless-constructor": "off", | ||
"no-undef": "off", | ||
"@typescript-eslint/explicit-module-boundary-types": "off", | ||
"@typescript-eslint/no-explicit-any": "off" | ||
} | ||
} | ||
"name": "@dxos/async", | ||
"version": "2.10.2", | ||
"description": "Async utils.", | ||
"bugs": { | ||
"url": "'https://github.com/dxos/protocols/issues" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/dxos/protocols.git" | ||
}, | ||
"license": "AGPL-3.0", | ||
"main": "dist/src/index.js", | ||
"types": "dist/src/index.d.ts", | ||
"files": [ | ||
"dist", | ||
"src" | ||
], | ||
"scripts": { | ||
"build": "toolchain build", | ||
"lint": "toolchain lint", | ||
"test": "toolchain test" | ||
}, | ||
"dependencies": { | ||
"@dxos/debug": "2.10.2", | ||
"@types/debug": "^4.1.1", | ||
"@types/end-of-stream": "^1.4.0", | ||
"@types/lodash": "^4.14.159", | ||
"@types/node": "^14.0.9", | ||
"@types/stream-buffers": "^3.0.2", | ||
"@types/through2": "^2.0.36", | ||
"lodash.merge": "^4.6.2" | ||
}, | ||
"devDependencies": { | ||
"@dxos/toolchain-node-library": "2.10.1-beta", | ||
"@types/jest": "^26.0.7", | ||
"stream-buffers": "^3.0.2" | ||
}, | ||
"publishConfig": { | ||
"access": "restricted" | ||
} | ||
} |
# Async | ||
[![Build Status](https://travis-ci.com/dxos/async.svg?branch=master)](https://travis-ci.com/dxos/async) | ||
[![Coverage Status](https://coveralls.io/repos/github/dxos/async/badge.svg?branch=master)](https://coveralls.io/github/dxos/async?branch=master) | ||
[![Greenkeeper badge](https://badges.greenkeeper.io/dxos/async.svg)](https://greenkeeper.io/) | ||
[![js-semistandard-style](https://img.shields.io/badge/code%20style-semistandard-brightgreen.svg?style=flat-square)](https://github.com/standard/semistandard) | ||
[![standard-readme compliant](https://img.shields.io/badge/readme%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme) | ||
## Install | ||
``` | ||
$ npm install @dxos/async | ||
``` | ||
## Usage | ||
```javascript | ||
import async from '@dxos/async'; | ||
const test = async () => { | ||
const [getValue, setValue] = trigger(); | ||
setTimeout(() => { | ||
setValue(100); | ||
}, 1000); | ||
const value = await getValue(); | ||
expect(value).toBe(100); | ||
}; | ||
``` | ||
## API | ||
```typescript | ||
export function noop(...args: any[]): any[]; | ||
export function sleep(timeout: any): Promise<unknown>; | ||
export function timeout(f: any, timeout?: number | undefined): Promise<unknown>; | ||
export function promiseTimeout(promise: Promise<any>, timeout: number): Promise<unknown>; | ||
export function waitForCondition(condFn: Function, timeout?: number | undefined, interval?: number | undefined): any; | ||
export function onEvent(eventEmitter: any, eventName: string, callback: Function): () => any; | ||
export function addListener(eventEmitter: any, eventName: any, callback: any): { | ||
remove: () => any; | ||
}; | ||
export function waitForEvent(eventEmitter: any, eventName: string, test?: Function | undefined, timeout?: number | undefined): Promise<unknown>; | ||
export function expectToThrow(test: Function, errType?: ErrorConstructor): Promise<void>; | ||
export class Event<T> {} | ||
/** | ||
* Returns a tuple containing a Promise that will be resolved when the resolver function is called. | ||
*/ | ||
export function trigger(timeout?: number): [() => Promise<void>, () => void]; | ||
export function trigger<T>(timeout?: number): [() => Promise<T>, (arg: T) => void]; | ||
/** | ||
* Use `trigger` instead. | ||
* @deprecated | ||
*/ | ||
export const useValue: typeof trigger; | ||
/** | ||
* Multiple-use version of `trigger`. | ||
* | ||
* Has two states: | ||
* - WAITING: promise is in pending state and will be resolved once `wake()` is called. | ||
* - READY: promise is already resolved, and all calls to `wait()` resolve immedeately. | ||
* | ||
* Trigger starts in WAITING state initially. | ||
* Use `reset()` to swith resolved trigger back to WAITING state. | ||
*/ | ||
export declare class Trigger {} | ||
/** | ||
* Returns a callback and a promise that's resolved when the callback is called n times. | ||
* @param n The number of times the callback is required to be called to resolve the promise. | ||
*/ | ||
export declare const latch: (n?: number) => readonly [Promise<number>, () => void]; | ||
/** | ||
* Waits for the specified number of events from the given emitter. | ||
*/ | ||
export declare const sink: (emitter: EventEmitter, event: string, count?: number) => Promise<void>; | ||
``` | ||
## Contributing | ||
PRs accepted. | ||
## License | ||
GPL-3.0 © DxOS | ||
Asynchronous utilities. |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
230727
3
2057
1
1
0
8
63
4
1
+ Added@dxos/debug@2.10.2
+ Added@types/debug@^4.1.1
+ Added@types/end-of-stream@^1.4.0
+ Added@types/lodash@^4.14.159
+ Added@types/node@^14.0.9
+ Added@types/stream-buffers@^3.0.2
+ Added@types/through2@^2.0.36
+ Addedlodash.merge@^4.6.2
+ Added@dxos/debug@2.10.2(transitive)
+ Added@types/debug@4.1.12(transitive)
+ Added@types/end-of-stream@1.4.4(transitive)
+ Added@types/lodash@4.17.13(transitive)
+ Added@types/ms@0.7.34(transitive)
+ Added@types/node@14.18.63(transitive)
+ Added@types/stream-buffers@3.0.7(transitive)
+ Added@types/through2@2.0.41(transitive)
+ Addeddebug@4.3.7(transitive)
+ Addedlodash.merge@4.6.2(transitive)
+ Addedms@2.1.3(transitive)