Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7daefcac11 | |||
| 912bdc61fb | |||
| 4b5581a6f1 | |||
| 4aa3d18219 | |||
| 21f3a1dc59 | |||
| 69d9881215 | |||
| f218d24c97 | |||
| 29983e44fa | |||
| a99767986d | |||
| 647a9ab4cb | |||
| ffb4d1c29e | |||
| f4480aa289 |
20
.gitignore
vendored
20
.gitignore
vendored
@@ -1,4 +1,20 @@
|
|||||||
node_modules/
|
.nogit/
|
||||||
docs/
|
|
||||||
|
# artifacts
|
||||||
coverage/
|
coverage/
|
||||||
public/
|
public/
|
||||||
|
pages/
|
||||||
|
|
||||||
|
# installs
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# caches
|
||||||
|
.yarn/
|
||||||
|
.cache/
|
||||||
|
.rpt2_cache
|
||||||
|
|
||||||
|
# builds
|
||||||
|
dist/
|
||||||
|
dist_*/
|
||||||
|
|
||||||
|
# custom
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
# gitzone standard
|
# gitzone ci_default
|
||||||
image: hosttoday/ht-docker-node:npmci
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
|
||||||
cache:
|
cache:
|
||||||
paths:
|
paths:
|
||||||
- .npmci_cache/
|
- .npmci_cache/
|
||||||
key: "$CI_BUILD_STAGE"
|
key: '$CI_BUILD_STAGE'
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- security
|
- security
|
||||||
@@ -20,53 +20,50 @@ mirror:
|
|||||||
script:
|
script:
|
||||||
- npmci git mirror
|
- npmci git mirror
|
||||||
tags:
|
tags:
|
||||||
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
- notpriv
|
||||||
|
|
||||||
snyk:
|
audit:
|
||||||
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
stage: security
|
stage: security
|
||||||
script:
|
script:
|
||||||
- npmci command npm install -g snyk
|
- npmci npm prepare
|
||||||
- npmci command npm install --ignore-scripts
|
- npmci command npm install --ignore-scripts
|
||||||
- npmci command snyk test
|
- npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
- npmci command npm audit --audit-level=high
|
||||||
tags:
|
tags:
|
||||||
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
- notpriv
|
||||||
|
|
||||||
# ====================
|
# ====================
|
||||||
# test stage
|
# test stage
|
||||||
# ====================
|
# ====================
|
||||||
testLEGACY:
|
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- npmci node install legacy
|
|
||||||
- npmci npm install
|
|
||||||
- npmci npm test
|
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
allow_failure: true
|
|
||||||
|
|
||||||
testLTS:
|
testStable:
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- npmci node install lts
|
|
||||||
- npmci npm install
|
|
||||||
- npmci npm test
|
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
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
|
||||||
|
- priv
|
||||||
|
|
||||||
|
testBuild:
|
||||||
|
stage: test
|
||||||
|
script:
|
||||||
|
- npmci npm prepare
|
||||||
|
- npmci node install stable
|
||||||
|
- npmci npm install
|
||||||
|
- npmci command npm run build
|
||||||
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
|
tags:
|
||||||
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
- notpriv
|
||||||
|
|
||||||
@@ -78,6 +75,7 @@ release:
|
|||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
tags:
|
tags:
|
||||||
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
- notpriv
|
||||||
|
|
||||||
@@ -86,20 +84,14 @@ release:
|
|||||||
# ====================
|
# ====================
|
||||||
codequality:
|
codequality:
|
||||||
stage: metadata
|
stage: metadata
|
||||||
image: docker:stable
|
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
services:
|
|
||||||
- docker:stable-dind
|
|
||||||
script:
|
script:
|
||||||
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
|
- npmci command npm install -g tslint typescript
|
||||||
- docker run
|
- npmci npm prepare
|
||||||
--env SOURCE_CODE="$PWD"
|
- npmci npm install
|
||||||
--volume "$PWD":/code
|
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
|
||||||
--volume /var/run/docker.sock:/var/run/docker.sock
|
|
||||||
"registry.gitlab.com/gitlab-org/security-products/codequality:$SP_VERSION" /code
|
|
||||||
artifacts:
|
|
||||||
paths: [codeclimate.json]
|
|
||||||
tags:
|
tags:
|
||||||
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
- priv
|
- priv
|
||||||
|
|
||||||
@@ -110,16 +102,20 @@ trigger:
|
|||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
tags:
|
tags:
|
||||||
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
- notpriv
|
||||||
|
|
||||||
pages:
|
pages:
|
||||||
image: hosttoday/ht-docker-node:npmci
|
|
||||||
stage: metadata
|
stage: metadata
|
||||||
script:
|
script:
|
||||||
- npmci command npm install -g npmpage
|
- npmci node install lts
|
||||||
- npmci command npmpage
|
- npmci command npm install -g @gitzone/tsdoc
|
||||||
|
- npmci npm prepare
|
||||||
|
- npmci npm install
|
||||||
|
- npmci command tsdoc
|
||||||
tags:
|
tags:
|
||||||
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
- notpriv
|
||||||
only:
|
only:
|
||||||
@@ -129,13 +125,3 @@ pages:
|
|||||||
paths:
|
paths:
|
||||||
- public
|
- public
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
|
|
||||||
windowsCompatibility:
|
|
||||||
image: stefanscherer/node-windows:10-build-tools
|
|
||||||
stage: metadata
|
|
||||||
script:
|
|
||||||
- npm install & npm test
|
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
|
||||||
tags:
|
|
||||||
- windows
|
|
||||||
allow_failure: true
|
|
||||||
|
|||||||
29
.vscode/launch.json
vendored
Normal file
29
.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "current file",
|
||||||
|
"type": "node",
|
||||||
|
"request": "launch",
|
||||||
|
"args": [
|
||||||
|
"${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"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
26
.vscode/settings.json
vendored
Normal file
26
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"json.schemas": [
|
||||||
|
{
|
||||||
|
"fileMatch": ["/npmextra.json"],
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"npmci": {
|
||||||
|
"type": "object",
|
||||||
|
"description": "settings for npmci"
|
||||||
|
},
|
||||||
|
"gitzone": {
|
||||||
|
"type": "object",
|
||||||
|
"description": "settings for gitzone",
|
||||||
|
"properties": {
|
||||||
|
"projectType": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": ["website", "element", "service", "npm"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
37
README.md
37
README.md
@@ -1,37 +0,0 @@
|
|||||||
# @pushrocks/smartdelay
|
|
||||||
|
|
||||||
timeouts for the async/await era, written in TypeScript
|
|
||||||
|
|
||||||
## Availabililty
|
|
||||||
|
|
||||||
[](https://www.npmjs.com/package/smartdelay)
|
|
||||||
[](https://GitLab.com/pushrocks/smartdelay)
|
|
||||||
[](https://github.com/pushrocks/smartdelay)
|
|
||||||
[](https://pushrocks.gitlab.io/smartdelay/)
|
|
||||||
|
|
||||||
## Status for master
|
|
||||||
|
|
||||||
[](https://GitLab.com/pushrocks/smartdelay/commits/master)
|
|
||||||
[](https://GitLab.com/pushrocks/smartdelay/commits/master)
|
|
||||||
[](https://www.npmjs.com/package/smartdelay)
|
|
||||||
[](https://david-dm.org/pushrocks/smartdelay)
|
|
||||||
[](https://www.bithound.io/github/pushrocks/smartdelay/master/dependencies/npm)
|
|
||||||
[](https://www.bithound.io/github/pushrocks/smartdelay)
|
|
||||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
|
||||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
|
||||||
[](http://standardjs.com/)
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
Use TypeScript for best in class instellisense.
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
import * as smartdelay from 'smartdelay';
|
|
||||||
|
|
||||||
(async () => {
|
|
||||||
await smartdelay.delayFor('3000'); // excution will halt here 3 seconds for this function scope BUT NOT BLOCK anything else
|
|
||||||
console.log();
|
|
||||||
})();
|
|
||||||
```
|
|
||||||
|
|
||||||
[](https://push.rocks)
|
|
||||||
@@ -1,8 +1,17 @@
|
|||||||
{
|
{
|
||||||
"npmci": {
|
"npmci": {
|
||||||
"npmGlobalTools": [
|
"npmGlobalTools": [],
|
||||||
"npmts"
|
|
||||||
],
|
|
||||||
"npmAccessLevel": "public"
|
"npmAccessLevel": "public"
|
||||||
|
},
|
||||||
|
"gitzone": {
|
||||||
|
"projectType": "npm",
|
||||||
|
"module": {
|
||||||
|
"githost": "gitlab.com",
|
||||||
|
"gitscope": "pushrocks",
|
||||||
|
"gitrepo": "smartdelay",
|
||||||
|
"shortDescription": "timeouts for the async/await era, written in TypeScript",
|
||||||
|
"npmPackagename": "@pushrocks/smartdelay",
|
||||||
|
"license": "MIT"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
3486
package-lock.json
generated
3486
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
37
package.json
37
package.json
@@ -1,13 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartdelay",
|
"name": "@pushrocks/smartdelay",
|
||||||
"private": false,
|
"private": false,
|
||||||
"version": "2.0.1",
|
"version": "2.0.7",
|
||||||
"description": "timeouts for the async/await era, written in TypeScript",
|
"description": "timeouts for the async/await era, written in TypeScript",
|
||||||
"main": "dist/index.js",
|
"main": "dist_ts/index.js",
|
||||||
"typings": "dist/index.d.ts",
|
"typings": "dist_ts/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "tsrun test/test.ts",
|
"test": "(tstest test/)",
|
||||||
"build": "(npmts)"
|
"build": "(tsbuild && tsbundle npm)"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@@ -20,11 +20,28 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://gitlab.com/pushrocks/smartdelay#README",
|
"homepage": "https://gitlab.com/pushrocks/smartdelay#README",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/smartpromise": "^2.0.5"
|
"@pushrocks/smartpromise": "^3.0.6"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsrun": "^1.1.1",
|
"@gitzone/tsbuild": "^2.1.24",
|
||||||
"@types/node": "^10.5.2",
|
"@gitzone/tsbundle": "^1.0.69",
|
||||||
"tapbundle": "^2.0.2"
|
"@gitzone/tsrun": "^1.2.8",
|
||||||
}
|
"@gitzone/tstest": "^1.0.28",
|
||||||
|
"@pushrocks/tapbundle": "^3.2.1",
|
||||||
|
"@types/node": "^14.0.5",
|
||||||
|
"tslint": "^6.1.2",
|
||||||
|
"tslint-config-prettier": "^1.18.0"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"ts/**/*",
|
||||||
|
"ts_web/**/*",
|
||||||
|
"dist/**/*",
|
||||||
|
"dist_*/**/*",
|
||||||
|
"dist_ts/**/*",
|
||||||
|
"dist_ts_web/**/*",
|
||||||
|
"assets/**/*",
|
||||||
|
"cli.js",
|
||||||
|
"npmextra.json",
|
||||||
|
"readme.md"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
20
test/test.ts
20
test/test.ts
@@ -1,4 +1,4 @@
|
|||||||
import { expect, tap } from 'tapbundle';
|
import { expect, tap } from '@pushrocks/tapbundle';
|
||||||
|
|
||||||
import * as smartdelay from '../ts/index';
|
import * as smartdelay from '../ts/index';
|
||||||
|
|
||||||
@@ -14,16 +14,18 @@ tap.test('.delayFor should delay async', async tools => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('.delayForRandpm should delay async for a random time period', async tools => {
|
tap.test('.delayForRandom should delay async for a random time period', async tools => {
|
||||||
tools.timeout(5000);
|
let timePassedBefore = false;
|
||||||
let timePassed = false;
|
let timePassedAfter = false;
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
timePassed = true;
|
timePassedBefore = true;
|
||||||
}, 3000);
|
}, 3000);
|
||||||
await smartdelay.delayForRandom(3000, 4900).then(async () => {
|
setTimeout(() => {
|
||||||
// tslint:disable-next-line:no-unused-expression
|
timePassedAfter = true;
|
||||||
expect(timePassed).to.be.true;
|
}, 5000);
|
||||||
});
|
await smartdelay.delayForRandom(3000, 4900);
|
||||||
|
expect(timePassedBefore).to.be.true;
|
||||||
|
expect(timePassedAfter).to.be.false;
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('.delayFor should pass on a type', async tools => {
|
tap.test('.delayFor should pass on a type', async tools => {
|
||||||
|
|||||||
12
ts/index.ts
12
ts/index.ts
@@ -1,4 +1,3 @@
|
|||||||
import 'typings-global';
|
|
||||||
import * as smartpromise from '@pushrocks/smartpromise';
|
import * as smartpromise from '@pushrocks/smartpromise';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -36,6 +35,7 @@ export class Timeout<T> {
|
|||||||
private _deferred: smartpromise.Deferred<T>;
|
private _deferred: smartpromise.Deferred<T>;
|
||||||
private _timeout: any;
|
private _timeout: any;
|
||||||
private _cancelled: boolean = false;
|
private _cancelled: boolean = false;
|
||||||
|
|
||||||
constructor(timeInMillisecondArg, passOn?: T) {
|
constructor(timeInMillisecondArg, passOn?: T) {
|
||||||
this._deferred = smartpromise.defer<T>();
|
this._deferred = smartpromise.defer<T>();
|
||||||
this.promise = this._deferred.promise;
|
this.promise = this._deferred.promise;
|
||||||
@@ -46,11 +46,17 @@ export class Timeout<T> {
|
|||||||
}, timeInMillisecondArg);
|
}, timeInMillisecondArg);
|
||||||
}
|
}
|
||||||
|
|
||||||
makeUnrefed() {
|
/**
|
||||||
|
* unreffing a timeout causes the node process to not wait for completion before exit
|
||||||
|
*/
|
||||||
|
public makeUnrefed() {
|
||||||
this._timeout.unref();
|
this._timeout.unref();
|
||||||
}
|
}
|
||||||
|
|
||||||
cancel() {
|
/**
|
||||||
|
* cancels the timer
|
||||||
|
*/
|
||||||
|
public cancel() {
|
||||||
this._cancelled = true;
|
this._cancelled = true;
|
||||||
this.makeUnrefed();
|
this.makeUnrefed();
|
||||||
}
|
}
|
||||||
|
|||||||
16
tslint.json
16
tslint.json
@@ -1,3 +1,17 @@
|
|||||||
{
|
{
|
||||||
"extends": "tslint-config-standard"
|
"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