Socket
Socket
Sign inDemoInstall

sdk-base

Package Overview
Dependencies
8
Maintainers
4
Versions
19
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.5.1 to 3.6.0

6

History.md
3.6.0 / 2019-04-24
==================
**features**
* [[`39c0f1d`](http://github.com/node-modules/sdk-base/commit/39c0f1d946bd7da1e393d42cca2f5e1bc22eb785)] - feat: implement close function (#17) (killa <<killa123@126.com>>)
3.5.1 / 2018-09-27

@@ -3,0 +9,0 @@ ==================

@@ -10,2 +10,3 @@ 'use strict';

const EventEmitter = require('events').EventEmitter;
const CLOSE_PROMISE = Symbol('base#closePromise');

@@ -34,2 +35,3 @@ class Base extends EventEmitter {

this._readyCallbacks = [];
this._closed = false;

@@ -172,2 +174,29 @@ // support `yield this.await('event')`

}
close() {
if (this._closed) {
return Promise.resolve();
}
if (this[CLOSE_PROMISE]) {
return this[CLOSE_PROMISE];
}
if (!this._close) {
this._closed = true;
return Promise.resolve();
}
let closeFunc = this._close;
if (is.generatorFunction(closeFunc)) {
closeFunc = co.wrap(closeFunc);
}
this[CLOSE_PROMISE] = closeFunc.apply(this);
assert(is.promise(this[CLOSE_PROMISE]), '[sdk-base] this._close should return either a promise or a generator');
return this[CLOSE_PROMISE]
.then(() => {
this._closed = true;
})
.catch(err => {
this._closed = true;
this.emit('error', err);
});
}
}

@@ -174,0 +203,0 @@

18

package.json
{
"name": "sdk-base",
"version": "3.5.1",
"version": "3.6.0",
"description": "a base class for sdk with default error handler",

@@ -37,14 +37,14 @@ "main": "index.js",

"co": "^4.6.0",
"is-type-of": "^1.2.0"
"is-type-of": "^1.2.1"
},
"devDependencies": {
"@types/node": "^10.5.3",
"autod": "^3.0.1",
"egg-bin": "^4.3.5",
"egg-ci": "^1.8.0",
"eslint": "^4.11.0",
"eslint-config-egg": "^5.1.1",
"autod": "^3.1.0",
"egg-bin": "^4.12.3",
"egg-ci": "^1.11.0",
"eslint": "^5.16.0",
"eslint-config-egg": "^7.3.1",
"pedding": "^1.1.0",
"runscript": "^1.3.0",
"typescript": "^2.9.2"
"typescript": "^3.4.3"
},

@@ -55,4 +55,4 @@ "engine": {

"ci": {
"version": "6, 8, 9"
"version": "6, 8, 10, 11"
}
}

@@ -148,5 +148,9 @@ sdk-base

```
- `._close()`: The `_close()` method is called by `close`, It can be overridden by child class, but should not be called directly. It must return promise or generator.
- `.close()`: The `close()` method is used to close the instance.
### License
[MIT](LICENSE)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc