Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@dxos/async

Package Overview
Dependencies
Maintainers
10
Versions
3003
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dxos/async - npm Package Compare versions

Comparing version 1.0.2-alpha.0 to 2.10.2

dist/src/async.d.ts

97

package.json
{
"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.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc