Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
@dxos/async
Advanced tools
$ npm install @dxos/async
import async from '@dxos/async';
const test = async () => {
const [getValue, setValue] = trigger();
setTimeout(() => {
setValue(100);
}, 1000);
const value = await getValue();
expect(value).toBe(100);
};
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>;
PRs accepted.
GPL-3.0 © DxOS
FAQs
Async utilities.
We found that @dxos/async demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.