fix(core): update
This commit is contained in:
parent
9f6d88e162
commit
c761cc4460
17568
package-lock.json
generated
17568
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -19,12 +19,11 @@
|
|||||||
"url": "https://gitlab.com/pushrocks/smartq/issues"
|
"url": "https://gitlab.com/pushrocks/smartq/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://gitlab.com/pushrocks/smartq#README",
|
"homepage": "https://gitlab.com/pushrocks/smartq#README",
|
||||||
"dependencies": {},
|
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.25",
|
"@gitzone/tsbuild": "^2.1.25",
|
||||||
"@gitzone/tstest": "^1.0.52",
|
"@gitzone/tstest": "^1.0.54",
|
||||||
"@pushrocks/tapbundle": "^3.2.9",
|
"@pushrocks/tapbundle": "^3.2.14",
|
||||||
"@types/node": "^14.11.8",
|
"@types/node": "^15.6.1",
|
||||||
"tslint": "^6.1.3",
|
"tslint": "^6.1.3",
|
||||||
"tslint-config-prettier": "^1.18.0"
|
"tslint-config-prettier": "^1.18.0"
|
||||||
},
|
},
|
||||||
|
@ -86,7 +86,6 @@ myPromisedFunction('helloThere', 2).then((x) => {
|
|||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## Contribution
|
## 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: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
|
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: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
|
||||||
|
54
test/test.readme.node.ts
Normal file
54
test/test.readme.node.ts
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
import * as smartpromise from '../ts';
|
||||||
|
|
||||||
|
// using Deferreds
|
||||||
|
// simple deferred;
|
||||||
|
const done = smartpromise.defer();
|
||||||
|
done.promise.then((stringArg) => {
|
||||||
|
console.log(stringArg);
|
||||||
|
});
|
||||||
|
done.resolve('hello') // whenever you are ready
|
||||||
|
|
||||||
|
|
||||||
|
// using deferreds in async functions to cater callback style apis
|
||||||
|
const myAsyncFunction = async (): Promise<string> => {
|
||||||
|
const done = smartpromise.defer<string>(); // returns your typical Deferred object
|
||||||
|
setTimeout(() => {
|
||||||
|
done.resolve('hi'); // will throw type error for other types than string as argument ;)
|
||||||
|
}, 6000);
|
||||||
|
|
||||||
|
console.log(done.status); // logs "pending";
|
||||||
|
await done.promise;
|
||||||
|
console.log(done.status); // logs "fullfilled"
|
||||||
|
console.log(done.duration); // outputs the duration in millisenconds
|
||||||
|
|
||||||
|
return done.promise;
|
||||||
|
};
|
||||||
|
|
||||||
|
let myAsyncFunction2 = async () => {
|
||||||
|
let aString = await myAsyncFunction();
|
||||||
|
console.log(aString); // will log 'hi' to console
|
||||||
|
};
|
||||||
|
|
||||||
|
myAsyncFunction2();
|
||||||
|
|
||||||
|
// Resolved and Rejected promises
|
||||||
|
// ------------------------------------------------
|
||||||
|
smartpromise.resolvedPromise(`I'll get logged to console soon`).then((x) => {
|
||||||
|
console.log(x);
|
||||||
|
});
|
||||||
|
|
||||||
|
smartpromise
|
||||||
|
.rejectedPromise(`what a lovely error message`)
|
||||||
|
.then(
|
||||||
|
() => {
|
||||||
|
console.log('This never makes it to console');
|
||||||
|
} /*, alternatively put a reject function here */
|
||||||
|
)
|
||||||
|
.catch((err) => {
|
||||||
|
console.log(err);
|
||||||
|
});
|
||||||
|
|
||||||
|
import {tap, expect } from '@pushrocks/tapbundle';
|
||||||
|
|
||||||
|
tap.test('runs through', async () => {})
|
||||||
|
tap.start();
|
Loading…
x
Reference in New Issue
Block a user