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

@pushrocks/smartdelay

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pushrocks/smartdelay - npm Package Compare versions

Comparing version 2.0.13 to 3.0.1

dist_ts/00_commitinfo_data.d.ts

242

dist_bundle/bundle.js

@@ -1,168 +0,78 @@

var tsbundle = (function (exports) {
'use strict';
// node_modules/.pnpm/@pushrocks+smartpromise@4.0.0/node_modules/@pushrocks/smartpromise/dist_ts/smartpromise.classes.deferred.js
var Deferred = class {
get duration() {
if (this.stoppedAt) {
return this.stoppedAt - this.startedAt;
} else {
return Date.now() - this.startedAt;
}
}
constructor() {
this.promise = new Promise((resolve, reject) => {
this.resolve = (valueArg) => {
this.status = "fulfilled";
this.stoppedAt = Date.now();
resolve(valueArg);
};
this.reject = (reason) => {
this.status = "rejected";
this.stoppedAt = Date.now();
reject(reason);
};
this.startedAt = Date.now();
this.status = "pending";
});
}
};
var defer = () => {
return new Deferred();
};
function createCommonjsModule(fn, basedir, module) {
return module = {
path: basedir,
exports: {},
require: function (path, base) {
return commonjsRequire(path, (base === undefined || base === null) ? module.path : base);
}
}, fn(module, module.exports), module.exports;
}
function commonjsRequire () {
throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
}
var dist_ts = createCommonjsModule(function (module, exports) {
Object.defineProperty(exports, "__esModule", { value: true });
exports.getFirstTrueOrFalse = exports.timeoutWrap = exports.map = exports.rejectedPromise = exports.resolvedPromise = exports.defer = exports.Deferred = void 0;
class Deferred {
constructor() {
this.promise = new Promise((resolve, reject) => {
this.resolve = (valueArg) => {
this.status = 'fulfilled';
this.stoppedAt = Date.now();
resolve(valueArg);
};
this.reject = (reason) => {
this.status = 'rejected';
this.stoppedAt = Date.now();
reject(reason);
};
this.startedAt = Date.now();
this.status = 'pending';
});
}
get duration() {
if (this.stoppedAt) {
return this.stoppedAt - this.startedAt;
}
else {
return Date.now() - this.startedAt;
}
}
}
exports.Deferred = Deferred;
exports.defer = () => {
return new Deferred();
};
/**
* Creates a new resolved promise for the provided value.
*/
exports.resolvedPromise = (value) => {
return Promise.resolve(value);
};
/**
* Creates a new rejected promise for the provided reason.
*/
exports.rejectedPromise = (err) => {
return Promise.reject(err);
};
/**
* accepts an array of inputs and a function that accepts the input.
* runs all items with the function and returns the result array when all items have run
* @param inputArg
* @param functionArg
*/
exports.map = async (inputArg, functionArg) => {
const promiseArray = [];
const resultArray = [];
for (const item of inputArg) {
const promise = functionArg(item);
promiseArray.push(promise);
promise.then((x) => {
resultArray.push(x);
});
}
await Promise.all(promiseArray);
return resultArray;
};
exports.timeoutWrap = (promiseArg, timeoutInMs) => {
return new Promise((resolve, reject) => {
setTimeout(() => {
reject(new Error('timeout'));
}, timeoutInMs);
promiseArg.then(resolve, reject);
});
};
exports.getFirstTrueOrFalse = async (promisesArg) => {
const done = exports.defer();
for (const promiseArg of promisesArg) {
promiseArg.then((resultArg) => {
if (resultArg === true) {
done.resolve(true);
}
});
}
Promise.all(promisesArg).then(() => {
done.resolve(false);
});
return done.promise;
};
});
/**
* delay something, works like setTimeout
* @param timeInMillisecondArg
* @param passOnArg
*/
let delayFor = async (timeInMillisecondArg, passOnArg, unrefedArg = false) => {
const timeout = new Timeout(timeInMillisecondArg, null, unrefedArg);
await timeout.promise;
return passOnArg;
};
/**
* delay for a random time
*/
let delayForRandom = async (timeMinInMillisecondArg, timeMaxInMillisecondArg, passOnArg, unrefedArg = false) => {
await delayFor(Math.random() * (timeMaxInMillisecondArg - timeMinInMillisecondArg) + timeMinInMillisecondArg, null, unrefedArg);
return passOnArg;
};
class Timeout {
constructor(timeInMillisecondArg, passOn, unrefedArg = false) {
this._cancelled = false;
this.timeoutInMillis = timeInMillisecondArg;
this._deferred = dist_ts.defer();
this.promise = this._deferred.promise;
this._timeout = setTimeout(() => {
if (!this._cancelled) {
this._deferred.resolve(passOn);
}
}, timeInMillisecondArg);
this.started = Date.now();
if (unrefedArg) {
this.makeUnrefed();
}
}
/**
* unreffing a timeout causes the node process to not wait for completion before exit
*/
makeUnrefed() {
this._timeout.unref();
}
/**
* cancels the timer
*/
cancel() {
this._cancelled = true;
clearTimeout(this._timeout);
}
getTimeLeft() {
const result = this.started + this.timeoutInMillis - Date.now();
return result > 0 ? result : 0;
}
}
exports.Timeout = Timeout;
exports.delayFor = delayFor;
exports.delayForRandom = delayForRandom;
Object.defineProperty(exports, '__esModule', { value: true });
return exports;
}({}));
// ts/index.ts
var delayFor = async (timeInMillisecondArg, passOnArg, unrefedArg = false) => {
const timeout = new Timeout(timeInMillisecondArg, null, unrefedArg);
await timeout.promise;
return passOnArg;
};
var delayForRandom = async (timeMinInMillisecondArg, timeMaxInMillisecondArg, passOnArg, unrefedArg = false) => {
await delayFor(
Math.random() * (timeMaxInMillisecondArg - timeMinInMillisecondArg) + timeMinInMillisecondArg,
null,
unrefedArg
);
return passOnArg;
};
var Timeout = class {
constructor(timeInMillisecondArg, passOn, unrefedArg = false) {
this._cancelled = false;
this.timeoutInMillis = timeInMillisecondArg;
this._deferred = defer();
this.promise = this._deferred.promise;
this._timeout = setTimeout(() => {
if (!this._cancelled) {
this._deferred.resolve(passOn);
}
}, timeInMillisecondArg);
this.started = Date.now();
if (unrefedArg) {
this.makeUnrefed();
}
}
makeUnrefed() {
this._timeout.unref();
}
cancel() {
this._cancelled = true;
clearTimeout(this._timeout);
}
getTimeLeft() {
const result = this.started + this.timeoutInMillis - Date.now();
return result > 0 ? result : 0;
}
};
export {
Timeout,
delayFor,
delayForRandom
};
//# sourceMappingURL=bundle.js.map

@@ -1,24 +0,2 @@

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Timeout = exports.delayForRandom = exports.delayFor = void 0;
const smartpromise = __importStar(require("@pushrocks/smartpromise"));
import * as smartpromise from '@pushrocks/smartpromise';
/**

@@ -29,3 +7,3 @@ * delay something, works like setTimeout

*/
exports.delayFor = async (timeInMillisecondArg, passOnArg, unrefedArg = false) => {
export let delayFor = async (timeInMillisecondArg, passOnArg, unrefedArg = false) => {
const timeout = new Timeout(timeInMillisecondArg, null, unrefedArg);

@@ -38,7 +16,7 @@ await timeout.promise;

*/
exports.delayForRandom = async (timeMinInMillisecondArg, timeMaxInMillisecondArg, passOnArg, unrefedArg = false) => {
await exports.delayFor(Math.random() * (timeMaxInMillisecondArg - timeMinInMillisecondArg) + timeMinInMillisecondArg, null, unrefedArg);
export let delayForRandom = async (timeMinInMillisecondArg, timeMaxInMillisecondArg, passOnArg, unrefedArg = false) => {
await delayFor(Math.random() * (timeMaxInMillisecondArg - timeMinInMillisecondArg) + timeMinInMillisecondArg, null, unrefedArg);
return passOnArg;
};
class Timeout {
export class Timeout {
constructor(timeInMillisecondArg, passOn, unrefedArg = false) {

@@ -77,3 +55,2 @@ this._cancelled = false;

}
exports.Timeout = Timeout;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0FBQUEsc0VBQXdEO0F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UFDLFVBQVUsRUFBRTtnQkFDcEIsSUFBSSxDQUFDLFNBQVMsQ0FBQyxPQUFPLENBQUMsTUFBTSxDQUFDLENBQUM7YUFDaEM7UUFDSCxDQUFDLEVBQUUsb0JBQW9CLENBQUMsQ0FBQztRQUN6QixJQUFJLENBQUMsT0FBTyxHQUFHLElBQUksQ0FBQyxHQUFHLEVBQUUsQ0FBQztRQUMxQixJQUFJLFVBQVUsRUFBRTtZQUNkLElBQUksQ0FBQyxXQUFXLEVBQUUsQ0FBQztTQUNwQjtJQUNILENBQUM7SUFFRDs7T0FFRztJQUNJLFdBQVc7UUFDaEIsSUFBSSxDQUFDLFFBQVEsQ0FBQyxLQUFLLEVBQUUsQ0FBQztJQUN4QixDQUFDO0lBRUQ7O09BRUc7SUFDSSxNQUFNO1FBQ1gsSUFBSSxDQUFDLFVBQVUsR0FBRyxJQUFJLENBQUM7UUFDdkIsWUFBWSxDQUFDLElBQUksQ0FBQyxRQUFRLENBQUMsQ0FBQztJQUM5QixDQUFDO0lBRU0sV0FBVztRQUNoQixNQUFNLE1BQU0sR0FBRyxJQUFJLENBQUMsT0FBTyxHQUFHLElBQUksQ0FBQyxlQUFlLEdBQUcsSUFBSSxDQUFDLEdBQUcsRUFBRSxDQUFDO1FBQ2hFLE9BQU8sTUFBTSxHQUFHLENBQUMsQ0FBQyxDQUFDLENBQUMsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUM7SUFDakMsQ0FBQztDQUNGIn0=

@@ -12,3 +12,3 @@ {

"gitrepo": "smartdelay",
"shortDescription": "timeouts for the async/await era, written in TypeScript",
"description": "timeouts for the async/await era, written in TypeScript",
"npmPackagename": "@pushrocks/smartdelay",

@@ -15,0 +15,0 @@ "license": "MIT"

{
"name": "@pushrocks/smartdelay",
"private": false,
"version": "2.0.13",
"version": "3.0.1",
"description": "timeouts for the async/await era, written in TypeScript",

@@ -10,3 +10,4 @@ "main": "dist_ts/index.js",

"test": "(tstest test/)",
"build": "(tsbuild --web && tsbundle npm)"
"build": "(tsbuild --web --allowimplicitany && tsbundle npm)",
"buildDocs": "tsdoc"
},

@@ -24,13 +25,11 @@ "repository": {

"dependencies": {
"@pushrocks/smartpromise": "^3.0.6"
"@pushrocks/smartpromise": "^4.0.0"
},
"devDependencies": {
"@gitzone/tsbuild": "^2.1.24",
"@gitzone/tsbundle": "^1.0.69",
"@gitzone/tsrun": "^1.2.8",
"@gitzone/tstest": "^1.0.28",
"@pushrocks/tapbundle": "^3.2.1",
"@types/node": "^15.12.0",
"tslint": "^6.1.2",
"tslint-config-prettier": "^1.18.0"
"@gitzone/tsbuild": "^2.1.65",
"@gitzone/tsbundle": "^2.0.7",
"@gitzone/tsrun": "^1.2.39",
"@gitzone/tstest": "^1.0.74",
"@pushrocks/tapbundle": "^5.0.4",
"@types/node": "^18.15.11"
},

@@ -51,3 +50,4 @@ "files": [

"last 1 chrome versions"
]
],
"type": "module"
}

@@ -24,3 +24,2 @@ # @pushrocks/smartdelay

BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@pushrocks/smartdelay)](https://lossless.cloud)
Platform support | [![Supports Windows 10](https://badgen.net/badge/supports%20Windows%2010/yes/green?icon=windows)](https://lossless.cloud) [![Supports Mac OS X](https://badgen.net/badge/supports%20Mac%20OS%20X/yes/green?icon=apple)](https://lossless.cloud)

@@ -50,5 +49,4 @@ ## Usage

> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
## Legal
> MIT licensed | **©** [Task Venture Capital GmbH](https://task.vc)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
[![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com)

Sorry, the diff of this file is not supported yet

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