Compare commits

...

8 Commits

Author SHA1 Message Date
0526c45ea1 3.0.2 2019-03-26 12:11:25 +01:00
9933d72784 fix(core): update 2019-03-26 12:11:24 +01:00
d1bc689b35 3.0.1 2019-03-26 12:07:13 +01:00
25c0deb3f3 fix(core): update 2019-03-26 12:07:12 +01:00
5138219563 3.0.0 2019-03-26 12:02:02 +01:00
93f426cce0 BREAKING CHANGE(remove util dependency and promisify functionality): update 2019-03-26 12:02:01 +01:00
e42061047a 2.0.5 2018-07-03 08:41:43 +02:00
3b07f99488 fix(README): fix import statement 2018-07-03 08:41:42 +02:00
8 changed files with 63 additions and 66 deletions

View File

@ -26,6 +26,7 @@ mirror:
snyk:
stage: security
script:
- npmci npm prepare
- npmci command npm install -g snyk
- npmci command npm install --ignore-scripts
- npmci command snyk test
@ -36,21 +37,11 @@ snyk:
# ====================
# 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:
stage: test
script:
- npmci npm prepare
- npmci node install lts
- npmci npm install
- npmci npm test
@ -62,6 +53,7 @@ testLTS:
testSTABLE:
stage: test
script:
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci npm test
@ -117,8 +109,10 @@ pages:
image: hosttoday/ht-docker-node:npmci
stage: metadata
script:
- npmci command npm install -g npmpage
- npmci command npmpage
- npmci command npm install -g typedoc typescript
- npmci npm prepare
- npmci npm install
- npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/
tags:
- docker
- notpriv
@ -129,13 +123,3 @@ pages:
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
allow_failure: true

View File

@ -1,25 +1,20 @@
# @pushrocks/smartpromise
simple promises and Deferred constructs
smart helpers that work with promises
## Availabililty
[![npm](https://pushrocks.gitlab.io/assets/repo-button-npm.svg)](https://www.npmjs.com/package/smartq)
[![git](https://pushrocks.gitlab.io/assets/repo-button-git.svg)](https://GitLab.com/pushrocks/smartq)
[![git](https://pushrocks.gitlab.io/assets/repo-button-mirror.svg)](https://github.com/pushrocks/smartq)
[![docs](https://pushrocks.gitlab.io/assets/repo-button-docs.svg)](https://pushrocks.gitlab.io/smartq/)
## Availabililty and Links
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartpromise)
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartpromise)
* [github.com (source mirror)](https://github.com/pushrocks/smartpromise)
* [docs (typedoc)](https://pushrocks.gitlab.io/smartpromise/)
## Status for master
[![build status](https://GitLab.com/pushrocks/smartq/badges/master/build.svg)](https://GitLab.com/pushrocks/smartq/commits/master)
[![coverage report](https://GitLab.com/pushrocks/smartq/badges/master/coverage.svg)](https://GitLab.com/pushrocks/smartq/commits/master)
[![npm downloads per month](https://img.shields.io/npm/dm/smartq.svg)](https://www.npmjs.com/package/smartq)
[![Dependency Status](https://david-dm.org/pushrocks/smartq.svg)](https://david-dm.org/pushrocks/smartq)
[![bitHound Dependencies](https://www.bithound.io/github/pushrocks/smartq/badges/dependencies.svg)](https://www.bithound.io/github/pushrocks/smartq/master/dependencies/npm)
[![bitHound Code](https://www.bithound.io/github/pushrocks/smartq/badges/code.svg)](https://www.bithound.io/github/pushrocks/smartq)
[![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->=%208.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/smartpromise/badges/master/build.svg)](https://gitlab.com/pushrocks/smartpromise/commits/master)
[![coverage report](https://gitlab.com/pushrocks/smartpromise/badges/master/coverage.svg)](https://gitlab.com/pushrocks/smartpromise/commits/master)
[![npm downloads per month](https://img.shields.io/npm/dm/@pushrocks/smartpromise.svg)](https://www.npmjs.com/package/@pushrocks/smartpromise)
[![Known Vulnerabilities](https://snyk.io/test/npm/@pushrocks/smartpromise/badge.svg)](https://snyk.io/test/npm/@pushrocks/smartpromise)
[![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,7 +24,7 @@ Use TypeScript for best in class instellisense.
> smartq does not repeat any native functions, so for things like .all() simply use Promise.all()
```javascript
import * as q from 'smartq'
import * as q from '@pushrocks/smartpromise'
// Deferred
// -----------------------------------------------
@ -77,8 +72,9 @@ myPromisedFunction('helloThere', 2).then(x => {
})
```
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)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
[![repo-footer](https://pushrocks.gitlab.io/assets/repo-footer.svg)](https://push.rocks)
[![repo-footer](https://pushrocks.gitlab.io/assets/repo-footer.svg)](https://maintainedby.lossless.com)

View File

@ -4,5 +4,15 @@
"npmts"
],
"npmAccessLevel": "public"
},
"gitzone": {
"module": {
"githost": "gitlab.com",
"gitscope": "pushrocks",
"gitrepo": "smartpromise",
"shortDescription": "simple promises and Deferred constructs",
"npmPackagename": "@pushrocks/smartpromise",
"license": "MIT"
}
}
}

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "@pushrocks/smartpromise",
"version": "2.0.4",
"version": "3.0.2",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@ -1,8 +1,8 @@
{
"name": "@pushrocks/smartpromise",
"private": false,
"version": "2.0.4",
"description": "dropin replacement for q",
"version": "3.0.2",
"description": "simple promises and Deferred constructs",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"scripts": {

View File

@ -1,10 +1,6 @@
import { expect, tap } from 'tapbundle';
import * as q from '../ts/index';
let myCallback = (someValue1: string, cb?) => {
cb(null, someValue1);
};
tap.test('should return a Deferred for .defer()', async () => {
let myDeferred = q.defer();
let expectPromise = expect(myDeferred.promise).to.eventually.be.fulfilled;
@ -20,16 +16,14 @@ tap.test('should let types flow through the Promise', async () => {
return expectPromise;
});
tap.test('should promisify a callback', async () => {
let myPromisified = q.promisify(myCallback);
let expectPromise = expect(myPromisified('hi')).to.eventually.equal('hi');
return await expectPromise;
});
tap.test('should map callbacks', async () => {
let inputArray = ['hi', 'awesome'];
let myPromisified = q.promisify(myCallback);
let expectPromise = expect(q.map(inputArray, myPromisified)).to.eventually.deep.equal(inputArray);
const myPromisified = async myInput => {
return myInput;
};
const expectPromise = expect(q.map(inputArray, myPromisified)).to.eventually.deep.equal(
inputArray
);
return expectPromise;
});

View File

@ -1,5 +1,3 @@
import * as util from 'util';
export interface IResolve<T> {
(value?: T | Promise<T>): void;
}
@ -42,14 +40,15 @@ export let rejectedPromise = err => {
return Promise.reject(err);
};
export let promisify = util.promisify;
interface IAsyncFunction<T> {
(someArg: T): Promise<T>;
}
export let map = async <T>(inputArg: T[], functionArg) => {
let promisifedFunction = promisify(functionArg);
export let map = async <T>(inputArg: T[], functionArg: IAsyncFunction<T>) => {
let promiseArray: Promise<any>[] = [];
let resultArray = [];
for (let item of inputArg) {
let promise: Promise<any> = promisifedFunction(item);
let promise: Promise<any> = functionArg(item);
promiseArray.push(promise);
promise.then(x => {
resultArray.push(x);

View File

@ -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"
}