Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7c561b2a25 | |||
| de4342aa18 | |||
| eeb05aa987 | |||
| 1cc575d2c8 | |||
| 3bcddff4ab | |||
| b7da538595 | |||
| aee7e17035 | |||
| ddd6e45662 | |||
| 3a9a8686a1 | |||
| 499ae24297 | |||
| 820c6ccb74 | |||
| 9b8198d592 | |||
| 1f0e574854 | |||
| 9f305070eb | |||
| 062f99990b | |||
| d3201b0d35 | |||
| 5df94778dd |
@@ -12,30 +12,38 @@ stages:
|
|||||||
- release
|
- release
|
||||||
- metadata
|
- metadata
|
||||||
|
|
||||||
|
before_script:
|
||||||
|
- pnpm install -g pnpm
|
||||||
|
- pnpm install -g @shipzone/npmci
|
||||||
|
- npmci npm prepare
|
||||||
|
|
||||||
# ====================
|
# ====================
|
||||||
# security stage
|
# security stage
|
||||||
# ====================
|
# ====================
|
||||||
mirror:
|
# ====================
|
||||||
stage: security
|
# security stage
|
||||||
script:
|
# ====================
|
||||||
- npmci git mirror
|
auditProductionDependencies:
|
||||||
tags:
|
|
||||||
- lossless
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
audit:
|
|
||||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
stage: security
|
stage: security
|
||||||
script:
|
script:
|
||||||
- npmci npm prepare
|
|
||||||
- npmci command npm install --ignore-scripts
|
|
||||||
- npmci command npm config set registry https://registry.npmjs.org
|
- npmci command npm config set registry https://registry.npmjs.org
|
||||||
- npmci command npm audit --audit-level=high
|
- npmci command pnpm audit --audit-level=high --prod
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
allow_failure: true
|
||||||
|
|
||||||
|
auditDevDependencies:
|
||||||
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
stage: security
|
||||||
|
script:
|
||||||
|
- npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
- npmci command pnpm audit --audit-level=high --dev
|
||||||
|
tags:
|
||||||
|
- lossless
|
||||||
|
- docker
|
||||||
|
allow_failure: true
|
||||||
|
|
||||||
# ====================
|
# ====================
|
||||||
# test stage
|
# test stage
|
||||||
@@ -44,28 +52,22 @@ audit:
|
|||||||
testStable:
|
testStable:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci npm prepare
|
|
||||||
- npmci node install stable
|
- npmci node install stable
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci npm test
|
- npmci npm test
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
|
||||||
- docker
|
- docker
|
||||||
- priv
|
|
||||||
|
|
||||||
testBuild:
|
testBuild:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci npm prepare
|
|
||||||
- npmci node install stable
|
- npmci node install stable
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci command npm run build
|
- npmci npm build
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
|
||||||
|
|
||||||
release:
|
release:
|
||||||
stage: release
|
stage: release
|
||||||
@@ -85,11 +87,12 @@ release:
|
|||||||
codequality:
|
codequality:
|
||||||
stage: metadata
|
stage: metadata
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
script:
|
script:
|
||||||
- npmci command npm install -g tslint typescript
|
- npmci command npm install -g typescript
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
|
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
@@ -109,11 +112,9 @@ trigger:
|
|||||||
pages:
|
pages:
|
||||||
stage: metadata
|
stage: metadata
|
||||||
script:
|
script:
|
||||||
- npmci node install lts
|
- npmci node install stable
|
||||||
- npmci command npm install -g @gitzone/tsdoc
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci command tsdoc
|
- npmci command npm run buildDocs
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
|
|||||||
24
.vscode/launch.json
vendored
24
.vscode/launch.json
vendored
@@ -2,28 +2,10 @@
|
|||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"configurations": [
|
"configurations": [
|
||||||
{
|
{
|
||||||
"name": "current file",
|
"command": "npm test",
|
||||||
"type": "node",
|
"name": "Run npm test",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"args": [
|
"type": "node-terminal"
|
||||||
"${relativeFile}"
|
|
||||||
],
|
|
||||||
"runtimeArgs": ["-r", "@gitzone/tsrun"],
|
|
||||||
"cwd": "${workspaceRoot}",
|
|
||||||
"protocol": "inspector",
|
|
||||||
"internalConsoleOptions": "openOnSessionStart"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "test.ts",
|
|
||||||
"type": "node",
|
|
||||||
"request": "launch",
|
|
||||||
"args": [
|
|
||||||
"test/test.ts"
|
|
||||||
],
|
|
||||||
"runtimeArgs": ["-r", "@gitzone/tsrun"],
|
|
||||||
"cwd": "${workspaceRoot}",
|
|
||||||
"protocol": "inspector",
|
|
||||||
"internalConsoleOptions": "openOnSessionStart"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@@ -15,7 +15,7 @@
|
|||||||
"properties": {
|
"properties": {
|
||||||
"projectType": {
|
"projectType": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": ["website", "element", "service", "npm"]
|
"enum": ["website", "element", "service", "npm", "wcc"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,10 +7,10 @@
|
|||||||
"projectType": "npm",
|
"projectType": "npm",
|
||||||
"module": {
|
"module": {
|
||||||
"githost": "gitlab.com",
|
"githost": "gitlab.com",
|
||||||
"gitscope": "pushrocks",
|
"gitscope": "push.rocks",
|
||||||
"gitrepo": "smartdelay",
|
"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",
|
"npmPackagename": "@push.rocks/smartdelay",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
25394
package-lock.json
generated
25394
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
29
package.json
29
package.json
@@ -1,13 +1,14 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartdelay",
|
"name": "@push.rocks/smartdelay",
|
||||||
"private": false,
|
"private": false,
|
||||||
"version": "2.0.11",
|
"version": "3.0.5",
|
||||||
"description": "timeouts for the async/await era, written in TypeScript",
|
"description": "timeouts for the async/await era, written in TypeScript",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
"typings": "dist_ts/index.d.ts",
|
"typings": "dist_ts/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(tstest test/)",
|
"test": "(tstest test/)",
|
||||||
"build": "(tsbuild && tsbundle npm)"
|
"build": "(tsbuild --web --allowimplicitany && tsbundle npm)",
|
||||||
|
"buildDocs": "tsdoc"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@@ -20,17 +21,15 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://gitlab.com/pushrocks/smartdelay#README",
|
"homepage": "https://gitlab.com/pushrocks/smartdelay#README",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/smartpromise": "^3.0.6"
|
"@push.rocks/smartpromise": "^4.0.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.24",
|
"@gitzone/tsbuild": "^2.1.66",
|
||||||
"@gitzone/tsbundle": "^1.0.69",
|
"@gitzone/tsbundle": "^2.0.8",
|
||||||
"@gitzone/tsrun": "^1.2.8",
|
"@gitzone/tsrun": "^1.2.42",
|
||||||
"@gitzone/tstest": "^1.0.28",
|
"@gitzone/tstest": "^1.0.74",
|
||||||
"@pushrocks/tapbundle": "^3.2.1",
|
"@push.rocks/tapbundle": "^5.0.8",
|
||||||
"@types/node": "^15.12.0",
|
"@types/node": "^20.4.1"
|
||||||
"tslint": "^6.1.2",
|
|
||||||
"tslint-config-prettier": "^1.18.0"
|
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"ts/**/*",
|
"ts/**/*",
|
||||||
@@ -43,5 +42,9 @@
|
|||||||
"cli.js",
|
"cli.js",
|
||||||
"npmextra.json",
|
"npmextra.json",
|
||||||
"readme.md"
|
"readme.md"
|
||||||
]
|
],
|
||||||
|
"browserslist": [
|
||||||
|
"last 1 chrome versions"
|
||||||
|
],
|
||||||
|
"type": "module"
|
||||||
}
|
}
|
||||||
|
|||||||
4711
pnpm-lock.yaml
generated
Normal file
4711
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
29
readme.md
29
readme.md
@@ -1,20 +1,26 @@
|
|||||||
# @pushrocks/smartdelay
|
# @push.rocks/smartdelay
|
||||||
timeouts for the async/await era, written in TypeScript
|
timeouts for the async/await era, written in TypeScript
|
||||||
|
|
||||||
## Availabililty and Links
|
## Availabililty and Links
|
||||||
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartdelay)
|
* [npmjs.org (npm package)](https://www.npmjs.com/package/@push.rocks/smartdelay)
|
||||||
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartdelay)
|
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartdelay)
|
||||||
* [github.com (source mirror)](https://github.com/pushrocks/smartdelay)
|
* [github.com (source mirror)](https://github.com/pushrocks/smartdelay)
|
||||||
* [docs (typedoc)](https://pushrocks.gitlab.io/smartdelay/)
|
* [docs (typedoc)](https://pushrocks.gitlab.io/smartdelay/)
|
||||||
|
|
||||||
## Status for master
|
## Status for master
|
||||||
[](https://gitlab.com/pushrocks/smartdelay/commits/master)
|
|
||||||
[](https://gitlab.com/pushrocks/smartdelay/commits/master)
|
Status Category | Status Badge
|
||||||
[](https://www.npmjs.com/package/@pushrocks/smartdelay)
|
-- | --
|
||||||
[](https://snyk.io/test/npm/@pushrocks/smartdelay)
|
GitLab Pipelines | [](https://lossless.cloud)
|
||||||
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
||||||
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
npm | [](https://lossless.cloud)
|
||||||
[](https://prettier.io/)
|
Snyk | [](https://lossless.cloud)
|
||||||
|
TypeScript Support | [](https://lossless.cloud)
|
||||||
|
node Support | [](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
|
Code Style | [](https://lossless.cloud)
|
||||||
|
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
||||||
|
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
||||||
|
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
@@ -39,7 +45,6 @@ We are always happy for code contributions. If you are not the code contributing
|
|||||||
|
|
||||||
For further information read the linked docs at the top of this readme.
|
For further information read the linked docs at the top of this readme.
|
||||||
|
|
||||||
> 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)
|
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
||||||
|
|
||||||
[](https://maintainedby.lossless.com)
|
|
||||||
|
|||||||
22
test/test.ts
22
test/test.ts
@@ -1,8 +1,8 @@
|
|||||||
import { expect, tap } from '@pushrocks/tapbundle';
|
import { expect, tap } from '@push.rocks/tapbundle';
|
||||||
|
|
||||||
import * as smartdelay from '../ts/index';
|
import * as smartdelay from '../ts/index.js';
|
||||||
|
|
||||||
tap.test('.delayFor should delay async', async tools => {
|
tap.test('.delayFor should delay async', async (tools) => {
|
||||||
tools.timeout(5000);
|
tools.timeout(5000);
|
||||||
let timePassed = false;
|
let timePassed = false;
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@@ -10,11 +10,11 @@ tap.test('.delayFor should delay async', async tools => {
|
|||||||
}, 2000);
|
}, 2000);
|
||||||
await smartdelay.delayFor(3000).then(async () => {
|
await smartdelay.delayFor(3000).then(async () => {
|
||||||
// tslint:disable-next-line:no-unused-expression
|
// tslint:disable-next-line:no-unused-expression
|
||||||
expect(timePassed).to.be.true;
|
expect(timePassed).toBeTrue();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('.delayForRandom should delay async for a random time period', async tools => {
|
tap.test('.delayForRandom should delay async for a random time period', async (tools) => {
|
||||||
let timePassedBefore = false;
|
let timePassedBefore = false;
|
||||||
let timePassedAfter = false;
|
let timePassedAfter = false;
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@@ -24,19 +24,19 @@ tap.test('.delayForRandom should delay async for a random time period', async to
|
|||||||
timePassedAfter = true;
|
timePassedAfter = true;
|
||||||
}, 5000);
|
}, 5000);
|
||||||
await smartdelay.delayForRandom(3000, 4900);
|
await smartdelay.delayForRandom(3000, 4900);
|
||||||
expect(timePassedBefore).to.be.true;
|
expect(timePassedBefore).toBeTrue();
|
||||||
expect(timePassedAfter).to.be.false;
|
expect(timePassedAfter).toBeFalse();
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('.delayFor should pass on a type', async tools => {
|
tap.test('.delayFor should pass on a type', async (tools) => {
|
||||||
tools.timeout(5000);
|
tools.timeout(5000);
|
||||||
let timePassed = false;
|
let timePassed = false;
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
timePassed = true;
|
timePassed = true;
|
||||||
}, 2000);
|
}, 2000);
|
||||||
let hey = 'heyThere';
|
let hey = 'heyThere';
|
||||||
await smartdelay.delayFor<string>(3000, hey).then(async stringArg => {
|
await smartdelay.delayFor<string>(3000, hey).then(async (stringArg) => {
|
||||||
expect(stringArg).equal('heyThere');
|
expect(stringArg).toEqual('heyThere');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@ tap.test('smartdelay.Timeout', async () => {
|
|||||||
await timeout.promise;
|
await timeout.promise;
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('smartdelay.Timeout should cancel', async tools => {
|
tap.test('smartdelay.Timeout should cancel', async (tools) => {
|
||||||
let timeout = new smartdelay.Timeout(60000);
|
let timeout = new smartdelay.Timeout(60000);
|
||||||
timeout.cancel();
|
timeout.cancel();
|
||||||
});
|
});
|
||||||
|
|||||||
8
ts/00_commitinfo_data.ts
Normal file
8
ts/00_commitinfo_data.ts
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
/**
|
||||||
|
* autocreated commitinfo by @pushrocks/commitinfo
|
||||||
|
*/
|
||||||
|
export const commitinfo = {
|
||||||
|
name: '@push.rocks/smartdelay',
|
||||||
|
version: '3.0.5',
|
||||||
|
description: 'timeouts for the async/await era, written in TypeScript'
|
||||||
|
}
|
||||||
14
ts/index.ts
14
ts/index.ts
@@ -1,11 +1,15 @@
|
|||||||
import * as smartpromise from '@pushrocks/smartpromise';
|
import * as smartpromise from '@push.rocks/smartpromise';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* delay something, works like setTimeout
|
* delay something, works like setTimeout
|
||||||
* @param timeInMillisecondArg
|
* @param timeInMillisecondArg
|
||||||
* @param passOnArg
|
* @param passOnArg
|
||||||
*/
|
*/
|
||||||
export let delayFor = async <T>(timeInMillisecondArg: number, passOnArg?: T, unrefedArg = false) => {
|
export let delayFor = async <T>(
|
||||||
|
timeInMillisecondArg: number,
|
||||||
|
passOnArg?: T,
|
||||||
|
unrefedArg = false
|
||||||
|
) => {
|
||||||
const timeout = new Timeout(timeInMillisecondArg, null, unrefedArg);
|
const timeout = new Timeout(timeInMillisecondArg, null, unrefedArg);
|
||||||
await timeout.promise;
|
await timeout.promise;
|
||||||
return passOnArg;
|
return passOnArg;
|
||||||
@@ -20,7 +24,11 @@ export let delayForRandom = async <T>(
|
|||||||
passOnArg?: T,
|
passOnArg?: T,
|
||||||
unrefedArg = false
|
unrefedArg = false
|
||||||
) => {
|
) => {
|
||||||
await delayFor(Math.random() * (timeMaxInMillisecondArg - timeMinInMillisecondArg) + timeMinInMillisecondArg, null, unrefedArg)
|
await delayFor(
|
||||||
|
Math.random() * (timeMaxInMillisecondArg - timeMinInMillisecondArg) + timeMinInMillisecondArg,
|
||||||
|
null,
|
||||||
|
unrefedArg
|
||||||
|
);
|
||||||
return passOnArg;
|
return passOnArg;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
10
tsconfig.json
Normal file
10
tsconfig.json
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"useDefineForClassFields": false,
|
||||||
|
"target": "ES2022",
|
||||||
|
"module": "ES2022",
|
||||||
|
"moduleResolution": "nodenext",
|
||||||
|
"esModuleInterop": true
|
||||||
|
}
|
||||||
|
}
|
||||||
17
tslint.json
17
tslint.json
@@ -1,17 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": ["tslint:latest", "tslint-config-prettier"],
|
|
||||||
"rules": {
|
|
||||||
"semicolon": [true, "always"],
|
|
||||||
"no-console": false,
|
|
||||||
"ordered-imports": false,
|
|
||||||
"object-literal-sort-keys": false,
|
|
||||||
"member-ordering": {
|
|
||||||
"options":{
|
|
||||||
"order": [
|
|
||||||
"static-method"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"defaultSeverity": "warning"
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user