Socket
Socket
Sign inDemoInstall

@bunt/async

Package Overview
Dependencies
3
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.29.15 to 0.29.16

10

dist/esm/AsyncCallback.js

@@ -1,6 +0,3 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AsyncCallback = void 0;
const is_1 = require("@bunt/is");
class AsyncCallback {
import { isUndefined } from "@bunt/is";
export class AsyncCallback {
#disposables = [];

@@ -56,3 +53,3 @@ #pipeline = [];

asResult = (value) => {
return (0, is_1.isUndefined)(value) ? { value, done: true } : { value, done: false };
return isUndefined(value) ? { value, done: true } : { value, done: false };
};

@@ -71,3 +68,2 @@ pipe = (value) => {

}
exports.AsyncCallback = AsyncCallback;
//# sourceMappingURL=AsyncCallback.js.map

@@ -1,8 +0,5 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AsyncIteratorFactory = void 0;
const is_1 = require("@bunt/is");
const AsyncPool_js_1 = require("./AsyncPool.js");
class AsyncIteratorFactory {
#pool = new AsyncPool_js_1.AsyncPool();
import { isUndefined } from "@bunt/is";
import { AsyncPool } from "./AsyncPool.js";
export class AsyncIteratorFactory {
#pool = new AsyncPool();
#factory;

@@ -36,6 +33,5 @@ constructor(factory) {

#format(value) {
return (0, is_1.isUndefined)(value) ? { value, done: true } : { value, done: false };
return isUndefined(value) ? { value, done: true } : { value, done: false };
}
}
exports.AsyncIteratorFactory = AsyncIteratorFactory;
//# sourceMappingURL=AsyncIteratorFactory.js.map

@@ -1,5 +0,2 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AsyncLoader = void 0;
class AsyncLoader {
export class AsyncLoader {
static factory(fn) {

@@ -13,3 +10,2 @@ return () => this.require(fn);

}
exports.AsyncLoader = AsyncLoader;
//# sourceMappingURL=AsyncLoader.js.map

@@ -1,7 +0,4 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AsyncPool = void 0;
const assert_1 = require("@bunt/assert");
const Defer_js_1 = require("./Defer.js");
class AsyncPool {
import { assert } from "@bunt/assert";
import { Defer } from "./Defer.js";
export class AsyncPool {
#buffer = [];

@@ -14,8 +11,8 @@ #maxBufferSize;

reject(reason) {
(0, assert_1.assert)(!this.#pending?.settled, `Failed to call reject in ${this.#pending?.state} state`);
this.#pending = this.#pending || new Defer_js_1.Defer();
assert(!this.#pending?.settled, `Failed to call reject in ${this.#pending?.state} state`);
this.#pending = this.#pending || new Defer();
this.#pending.reject(reason);
}
push(value) {
(0, assert_1.assert)(!this.#pending?.settled, `Failed to call push in ${this.#pending?.state} state`);
assert(!this.#pending?.settled, `Failed to call push in ${this.#pending?.state} state`);
if (this.#pending) {

@@ -26,3 +23,3 @@ this.#pending.resolve(value);

}
(0, assert_1.assert)(this.#buffer.length < this.#maxBufferSize, "Buffer reached size limit");
assert(this.#buffer.length < this.#maxBufferSize, "Buffer reached size limit");
this.#buffer.push(value);

@@ -37,6 +34,5 @@ }

}
return this.#pending = this.#pending || new Defer_js_1.Defer();
return this.#pending = this.#pending || new Defer();
}
}
exports.AsyncPool = AsyncPool;
//# sourceMappingURL=AsyncPool.js.map

@@ -1,6 +0,3 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AsyncSingleCall = void 0;
const Defer_js_1 = require("./Defer.js");
class AsyncSingleCall {
import { Defer } from "./Defer.js";
export class AsyncSingleCall {
#fn;

@@ -13,3 +10,3 @@ #defer = null;

if (!this.#defer) {
this.#defer = new Defer_js_1.Defer();
this.#defer = new Defer();
const { resolve, reject } = this.#defer;

@@ -27,3 +24,2 @@ Promise.resolve(this.#fn())

}
exports.AsyncSingleCall = AsyncSingleCall;
//# sourceMappingURL=AsyncSingleCall.js.map

@@ -1,7 +0,4 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AsyncState = void 0;
const is_1 = require("@bunt/is");
import { isDefined } from "@bunt/is";
const registry = new WeakMap();
class AsyncState {
export class AsyncState {
static acquire(listener) {

@@ -36,9 +33,8 @@ const state = {};

static isReleased(pending) {
return (0, is_1.isDefined)(pending) && (registry.get(pending)?.done ?? true);
return isDefined(pending) && (registry.get(pending)?.done ?? true);
}
static has(pending) {
return (0, is_1.isDefined)(pending) && registry.has(pending);
return isDefined(pending) && registry.has(pending);
}
}
exports.AsyncState = AsyncState;
//# sourceMappingURL=AsyncState.js.map

@@ -1,7 +0,4 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Defer = void 0;
const events_1 = require("events");
class Defer {
#event = new events_1.EventEmitter();
import { EventEmitter } from "events";
export class Defer {
#event = new EventEmitter();
#pending;

@@ -39,3 +36,2 @@ #state = "pending";

}
exports.Defer = Defer;
//# sourceMappingURL=Defer.js.map

@@ -1,7 +0,4 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.asyncCall = exports.toAsync = exports.allSettled = exports.all = exports.throttle = exports.watch = exports.wait = exports.timeout = void 0;
const Defer_js_1 = require("./Defer.js");
function timeout(timeout) {
const defer = new Defer_js_1.Defer();
import { Defer } from "./Defer.js";
export function timeout(timeout) {
const defer = new Defer();
const timer = setTimeout(defer.resolve, timeout);

@@ -11,4 +8,3 @@ defer.then(() => clearTimeout(timer));

}
exports.timeout = timeout;
function wait(fn) {
export function wait(fn) {
return new Promise((resolve) => {

@@ -18,4 +14,3 @@ fn(resolve);

}
exports.wait = wait;
async function watch(expected, fn, tries = Infinity) {
export async function watch(expected, fn, tries = Infinity) {
while (tries-- > 0 && expected !== await fn()) {

@@ -25,4 +20,3 @@ // nothing

}
exports.watch = watch;
function throttle(fn, t = 100) {
export function throttle(fn, t = 100) {
return async (...args) => {

@@ -33,12 +27,9 @@ await timeout(t);

}
exports.throttle = throttle;
async function all(pending) {
export async function all(pending) {
return Promise.all(pending);
}
exports.all = all;
function allSettled(pending) {
export function allSettled(pending) {
return Promise.allSettled(pending);
}
exports.allSettled = allSettled;
function toAsync(fn) {
export function toAsync(fn) {
return async (...args) => {

@@ -48,7 +39,5 @@ return fn(...args);

}
exports.toAsync = toAsync;
async function asyncCall(fn, ...args) {
export async function asyncCall(fn, ...args) {
return fn(...args);
}
exports.asyncCall = asyncCall;
//# sourceMappingURL=fn.js.map

@@ -1,25 +0,9 @@

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./fn.js"), exports);
__exportStar(require("./AsyncPool.js"), exports);
__exportStar(require("./AsyncState.js"), exports);
__exportStar(require("./Defer.js"), exports);
__exportStar(require("./AsyncIteratorFactory.js"), exports);
__exportStar(require("./AsyncLoader.js"), exports);
__exportStar(require("./AsyncSingleCall.js"), exports);
__exportStar(require("./AsyncCallback.js"), exports);
export * from "./fn.js";
export * from "./AsyncPool.js";
export * from "./AsyncState.js";
export * from "./Defer.js";
export * from "./AsyncIteratorFactory.js";
export * from "./AsyncLoader.js";
export * from "./AsyncSingleCall.js";
export * from "./AsyncCallback.js";
//# sourceMappingURL=index.js.map
{
"name": "@bunt/async",
"version": "0.29.15",
"version": "0.29.16",
"keywords": [

@@ -34,5 +34,5 @@ "typescript",

"dependencies": {
"@bunt/assert": "^0.29.15",
"@bunt/is": "^0.29.14",
"@bunt/type": "^0.29.14"
"@bunt/assert": "^0.29.16",
"@bunt/is": "^0.29.16",
"@bunt/type": "^0.29.16"
},

@@ -43,3 +43,3 @@ "publishConfig": {

"license": "MIT",
"gitHead": "c51511e885a99ea220708c6329ffa4ac4550e14e"
"gitHead": "6d4993cad2d32f4c402b89685fc92f2db8df2cf6"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc