diff --git a/.gitignore b/.gitignore index 6554d78..91c0db0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,22 @@ -node_modules/ -docs/ +.nogit/ + +# artifacts coverage/ -public/ \ No newline at end of file +public/ +pages/ + +# installs +node_modules/ + +# caches +.yarn/ +.cache/ +.rpt2_cache + +# builds +dist/ +dist_web/ +dist_serve/ +dist_ts_web/ + +# custom \ No newline at end of file diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8b576a0..b14b4ac 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,16 +1,16 @@ -# gitzone standard -image: hosttoday/ht-docker-node:npmci +# gitzone ci_default +image: registry.gitlab.com/hosttoday/ht-docker-node:npmci cache: paths: - - .npmci_cache/ - key: "$CI_BUILD_STAGE" + - .npmci_cache/ + key: '$CI_BUILD_STAGE' stages: -- security -- test -- release -- metadata + - security + - test + - release + - metadata # ==================== # security stage @@ -18,108 +18,103 @@ stages: mirror: stage: security script: - - npmci git mirror + - npmci git mirror tags: - - docker - - notpriv + - lossless + - docker + - notpriv snyk: stage: security script: + - npmci npm prepare - npmci command npm install -g snyk - npmci command npm install --ignore-scripts - npmci command snyk test tags: - - docker - - notpriv + - lossless + - docker + - notpriv # ==================== # 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 + - npmci npm prepare + - npmci node install stable + - npmci npm install + - npmci npm test coverage: /\d+.?\d+?\%\s*coverage/ tags: - - docker - - notpriv - -testSTABLE: + - lossless + - docker + - priv + +testBuild: stage: test script: - - npmci node install stable - - npmci npm install - - npmci npm test + - npmci npm prepare + - npmci node install stable + - npmci npm install + - npmci command npm run build coverage: /\d+.?\d+?\%\s*coverage/ tags: - - docker - - notpriv + - lossless + - docker + - notpriv release: stage: release script: - - npmci node install stable - - npmci npm publish + - npmci node install stable + - npmci npm publish only: - - tags + - tags tags: - - docker - - notpriv + - lossless + - docker + - notpriv # ==================== # metadata stage # ==================== codequality: stage: metadata - image: docker:stable allow_failure: true - services: - - docker:stable-dind script: - - export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/') - - docker run - --env SOURCE_CODE="$PWD" - --volume "$PWD":/code - --volume /var/run/docker.sock:/var/run/docker.sock - "registry.gitlab.com/gitlab-org/security-products/codequality:$SP_VERSION" /code - artifacts: - paths: [codeclimate.json] + - npmci command npm install -g tslint typescript + - npmci npm prepare + - npmci npm install + - npmci command "tslint -c tslint.json ./ts/**/*.ts" tags: - - docker - - priv + - lossless + - docker + - priv trigger: stage: metadata script: - - npmci trigger + - npmci trigger only: - - tags + - tags tags: - - docker - - notpriv + - lossless + - docker + - notpriv pages: - image: hosttoday/ht-docker-node:npmci stage: metadata script: - - npmci command npm install -g npmpage - - npmci command npmpage + - npmci node install lts + - npmci command npm install -g @gitzone/tsdoc + - npmci npm prepare + - npmci npm install + - npmci command tsdoc tags: + - lossless - docker - notpriv only: @@ -127,15 +122,5 @@ pages: artifacts: expire_in: 1 week paths: - - public - 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 + - public allow_failure: true diff --git a/README.md b/README.md index 5e9da35..22bd180 100644 --- a/README.md +++ b/README.md @@ -1,25 +1,20 @@ # @pushrocks/smartdelay +timeouts for the async/await era, written in TypeScript -timeouts for the async/await era, written in TypeScript - -## Availabililty - -[![npm](https://push.rocks/assets/repo-button-npm.svg)](https://www.npmjs.com/package/smartdelay) -[![git](https://push.rocks/assets/repo-button-git.svg)](https://GitLab.com/pushrocks/smartdelay) -[![git](https://push.rocks/assets/repo-button-mirror.svg)](https://github.com/pushrocks/smartdelay) -[![docs](https://push.rocks/assets/repo-button-docs.svg)](https://pushrocks.gitlab.io/smartdelay/) +## Availabililty and Links +* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartdelay) +* [gitlab.com (source)](https://gitlab.com/pushrocks/smartdelay) +* [github.com (source mirror)](https://github.com/pushrocks/smartdelay) +* [docs (typedoc)](https://pushrocks.gitlab.io/smartdelay/) ## Status for master - -[![build status](https://GitLab.com/pushrocks/smartdelay/badges/master/build.svg)](https://GitLab.com/pushrocks/smartdelay/commits/master) -[![coverage report](https://GitLab.com/pushrocks/smartdelay/badges/master/coverage.svg)](https://GitLab.com/pushrocks/smartdelay/commits/master) -[![npm downloads per month](https://img.shields.io/npm/dm/smartdelay.svg)](https://www.npmjs.com/package/smartdelay) -[![Dependency Status](https://david-dm.org/pushrocks/smartdelay.svg)](https://david-dm.org/pushrocks/smartdelay) -[![bitHound Dependencies](https://www.bithound.io/github/pushrocks/smartdelay/badges/dependencies.svg)](https://www.bithound.io/github/pushrocks/smartdelay/master/dependencies/npm) -[![bitHound Code](https://www.bithound.io/github/pushrocks/smartdelay/badges/code.svg)](https://www.bithound.io/github/pushrocks/smartdelay) -[![TypeScript](https://img.shields.io/badge/TypeScript-2.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/) -[![node](https://img.shields.io/badge/node->=%206.x.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/) -[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/) +[![build status](https://gitlab.com/pushrocks/smartdelay/badges/master/build.svg)](https://gitlab.com/pushrocks/smartdelay/commits/master) +[![coverage report](https://gitlab.com/pushrocks/smartdelay/badges/master/coverage.svg)](https://gitlab.com/pushrocks/smartdelay/commits/master) +[![npm downloads per month](https://img.shields.io/npm/dm/@pushrocks/smartdelay.svg)](https://www.npmjs.com/package/@pushrocks/smartdelay) +[![Known Vulnerabilities](https://snyk.io/test/npm/@pushrocks/smartdelay/badge.svg)](https://snyk.io/test/npm/@pushrocks/smartdelay) +[![TypeScript](https://img.shields.io/badge/TypeScript->=%203.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/) +[![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/) +[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-prettier-ff69b4.svg)](https://prettier.io/) ## Usage @@ -29,9 +24,22 @@ Use TypeScript for best in class instellisense. 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(); + await smartdelay.delayFor(3000); // excution will halt here 3 seconds for this function scope BUT NOT BLOCK anything else + console.log('hi there'); + + // You can also go random + await smartdelay.delayForRandom(2000, 6000); // this will delay exection somewhere between 2 and 6 seconds. + console.log('Yay. You did not see me coming at this exact time'); })(); ``` -[![npm](https://push.rocks/assets/repo-header.svg)](https://push.rocks) +## Contribution + +We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: [Contribute monthly :)](https://lossless.link/contribute) + +For further information read the linked docs at the top of this readme. + +> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh) +| 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) diff --git a/npmextra.json b/npmextra.json index 095e3c9..7e647d0 100644 --- a/npmextra.json +++ b/npmextra.json @@ -2,5 +2,15 @@ "npmci": { "npmGlobalTools": [], "npmAccessLevel": "public" + }, + "gitzone": { + "module": { + "githost": "gitlab.com", + "gitscope": "pushrocks", + "gitrepo": "smartdelay", + "shortDescription": "timeouts for the async/await era, written in TypeScript", + "npmPackagename": "@pushrocks/smartdelay", + "license": "MIT" + } } } \ No newline at end of file diff --git a/package.json b/package.json index 1205e6d..a6a6f6f 100644 --- a/package.json +++ b/package.json @@ -28,5 +28,16 @@ "@gitzone/tstest": "^1.0.28", "@pushrocks/tapbundle": "^3.0.13", "@types/node": "^12.12.5" - } -} + }, + "files": [ + "ts/**/*", + "ts_web/**/*", + "dist/**/*", + "dist_web/**/*", + "dist_ts_web/**/*", + "assets/**/*", + "cli.js", + "npmextra.json", + "readme.md" + ] +} \ No newline at end of file diff --git a/test/test.ts b/test/test.ts index 071d4b7..b191077 100644 --- a/test/test.ts +++ b/test/test.ts @@ -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 => { - tools.timeout(5000); - let timePassed = false; +tap.test('.delayForRandom should delay async for a random time period', async tools => { + let timePassedBefore = false; + let timePassedAfter = false; setTimeout(() => { - timePassed = true; + timePassedBefore = true; }, 3000); - await smartdelay.delayForRandom(3000, 4900).then(async () => { - // tslint:disable-next-line:no-unused-expression - expect(timePassed).to.be.true; - }); + setTimeout(() => { + timePassedAfter = 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 => { diff --git a/tslint.json b/tslint.json index 45052ad..d4ea2e9 100644 --- a/tslint.json +++ b/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" }