@google-cloud/promisify 1.0.4 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +38 -0
- package/README.md +30 -0
- package/build/src/index.js +16 -27
- package/package.json +21 -17
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,44 @@
|
|
|
4
4
|
|
|
5
5
|
[1]: https://www.npmjs.com/package/nodejs-promisify?activeTab=versions
|
|
6
6
|
|
|
7
|
+
### [2.0.3](https://www.github.com/googleapis/nodejs-promisify/compare/v2.0.2...v2.0.3) (2020-09-04)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
* allow excluding accessor methods ([#228](https://www.github.com/googleapis/nodejs-promisify/issues/228)) ([114d8bc](https://www.github.com/googleapis/nodejs-promisify/commit/114d8bcef7093bdfda195a15e0c2f376195fd3fc))
|
|
13
|
+
|
|
14
|
+
### [2.0.2](https://www.github.com/googleapis/nodejs-promisify/compare/v2.0.1...v2.0.2) (2020-07-06)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* update node issue template ([#204](https://www.github.com/googleapis/nodejs-promisify/issues/204)) ([a2ba8d8](https://www.github.com/googleapis/nodejs-promisify/commit/a2ba8d8e45ef03d093d987292a467696745fc9fd))
|
|
20
|
+
|
|
21
|
+
### [2.0.1](https://www.github.com/googleapis/nodejs-promisify/compare/v2.0.0...v2.0.1) (2020-05-08)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### Bug Fixes
|
|
25
|
+
|
|
26
|
+
* apache license URL ([#468](https://www.github.com/googleapis/nodejs-promisify/issues/468)) ([#191](https://www.github.com/googleapis/nodejs-promisify/issues/191)) ([0edc724](https://www.github.com/googleapis/nodejs-promisify/commit/0edc7246c53d25d9dd220b813561bcee97250783))
|
|
27
|
+
|
|
28
|
+
## [2.0.0](https://www.github.com/googleapis/nodejs-promisify/compare/v1.0.4...v2.0.0) (2020-03-23)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### ⚠ BREAKING CHANGES
|
|
32
|
+
|
|
33
|
+
* update to latest version of gts/typescript (#183)
|
|
34
|
+
* drop Node 8 from engines field (#184)
|
|
35
|
+
|
|
36
|
+
### Features
|
|
37
|
+
|
|
38
|
+
* drop Node 8 from engines field ([#184](https://www.github.com/googleapis/nodejs-promisify/issues/184)) ([7e6d3c5](https://www.github.com/googleapis/nodejs-promisify/commit/7e6d3c54066d89530ed25c7f9722efd252f43fb8))
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
### Build System
|
|
42
|
+
|
|
43
|
+
* update to latest version of gts/typescript ([#183](https://www.github.com/googleapis/nodejs-promisify/issues/183)) ([9c3ed12](https://www.github.com/googleapis/nodejs-promisify/commit/9c3ed12c12f4bb1e17af7440c6371c4cefddcd59))
|
|
44
|
+
|
|
7
45
|
### [1.0.4](https://www.github.com/googleapis/nodejs-promisify/compare/v1.0.3...v1.0.4) (2019-12-05)
|
|
8
46
|
|
|
9
47
|
|
package/README.md
CHANGED
|
@@ -14,6 +14,9 @@
|
|
|
14
14
|
A simple utility for promisifying functions and classes.
|
|
15
15
|
|
|
16
16
|
|
|
17
|
+
A comprehensive list of changes in each version may be found in
|
|
18
|
+
[the CHANGELOG](https://github.com/googleapis/nodejs-promisify/blob/master/CHANGELOG.md).
|
|
19
|
+
|
|
17
20
|
* [Google Cloud Common Promisify Node.js Client API Reference][client-docs]
|
|
18
21
|
|
|
19
22
|
* [github.com/googleapis/nodejs-promisify](https://github.com/googleapis/nodejs-promisify)
|
|
@@ -89,6 +92,27 @@ has instructions for running the samples.
|
|
|
89
92
|
The [Google Cloud Common Promisify Node.js Client API Reference][client-docs] documentation
|
|
90
93
|
also contains samples.
|
|
91
94
|
|
|
95
|
+
## Supported Node.js Versions
|
|
96
|
+
|
|
97
|
+
Our client libraries follow the [Node.js release schedule](https://nodejs.org/en/about/releases/).
|
|
98
|
+
Libraries are compatible with all current _active_ and _maintenance_ versions of
|
|
99
|
+
Node.js.
|
|
100
|
+
|
|
101
|
+
Client libraries targetting some end-of-life versions of Node.js are available, and
|
|
102
|
+
can be installed via npm [dist-tags](https://docs.npmjs.com/cli/dist-tag).
|
|
103
|
+
The dist-tags follow the naming convention `legacy-(version)`.
|
|
104
|
+
|
|
105
|
+
_Legacy Node.js versions are supported as a best effort:_
|
|
106
|
+
|
|
107
|
+
* Legacy versions will not be tested in continuous integration.
|
|
108
|
+
* Some security patches may not be able to be backported.
|
|
109
|
+
* Dependencies will not be kept up-to-date, and features will not be backported.
|
|
110
|
+
|
|
111
|
+
#### Legacy tags available
|
|
112
|
+
|
|
113
|
+
* `legacy-8`: install client libraries from this dist-tag for versions
|
|
114
|
+
compatible with Node.js 8.
|
|
115
|
+
|
|
92
116
|
## Versioning
|
|
93
117
|
|
|
94
118
|
This library follows [Semantic Versioning](http://semver.org/).
|
|
@@ -112,6 +136,12 @@ More Information: [Google Cloud Platform Launch Stages][launch_stages]
|
|
|
112
136
|
|
|
113
137
|
Contributions welcome! See the [Contributing Guide](https://github.com/googleapis/nodejs-promisify/blob/master/CONTRIBUTING.md).
|
|
114
138
|
|
|
139
|
+
Please note that this `README.md`, the `samples/README.md`,
|
|
140
|
+
and a variety of configuration files in this repository (including `.nycrc` and `tsconfig.json`)
|
|
141
|
+
are generated from a central template. To edit one of these files, make an edit
|
|
142
|
+
to its template in this
|
|
143
|
+
[directory](https://github.com/googleapis/synthtool/tree/master/synthtool/gcp/templates/node_library).
|
|
144
|
+
|
|
115
145
|
## License
|
|
116
146
|
|
|
117
147
|
Apache Version 2.0
|
package/build/src/index.js
CHANGED
|
@@ -1,18 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
//
|
|
4
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
// you may not use this file except in compliance with the License.
|
|
6
|
-
// You may obtain a copy of the License at
|
|
7
|
-
//
|
|
8
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
//
|
|
10
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
// See the License for the specific language governing permissions and
|
|
14
|
-
// limitations under the License.
|
|
2
|
+
/* eslint-disable prefer-rest-params */
|
|
15
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.callbackifyAll = exports.callbackify = exports.promisifyAll = exports.promisify = void 0;
|
|
16
5
|
/**
|
|
17
6
|
* Wraps a callback style function to conditionally return a promise.
|
|
18
7
|
*
|
|
@@ -29,7 +18,6 @@ function promisify(originalMethod, options) {
|
|
|
29
18
|
const slice = Array.prototype.slice;
|
|
30
19
|
// tslint:disable-next-line:no-any
|
|
31
20
|
const wrapper = function () {
|
|
32
|
-
const context = this;
|
|
33
21
|
let last;
|
|
34
22
|
for (last = arguments.length - 1; last >= 0; last--) {
|
|
35
23
|
const arg = arguments[last];
|
|
@@ -39,7 +27,7 @@ function promisify(originalMethod, options) {
|
|
|
39
27
|
if (typeof arg !== 'function') {
|
|
40
28
|
break; // non-callback last argument found.
|
|
41
29
|
}
|
|
42
|
-
return originalMethod.apply(
|
|
30
|
+
return originalMethod.apply(this, arguments);
|
|
43
31
|
}
|
|
44
32
|
// peel trailing undefined.
|
|
45
33
|
const args = slice.call(arguments, 0, last + 1);
|
|
@@ -48,8 +36,8 @@ function promisify(originalMethod, options) {
|
|
|
48
36
|
// Because dedupe will likely create a single install of
|
|
49
37
|
// @google-cloud/common to be shared amongst all modules, we need to
|
|
50
38
|
// localize it at the Service level.
|
|
51
|
-
if (
|
|
52
|
-
PromiseCtor =
|
|
39
|
+
if (this && this.Promise) {
|
|
40
|
+
PromiseCtor = this.Promise;
|
|
53
41
|
}
|
|
54
42
|
return new PromiseCtor((resolve, reject) => {
|
|
55
43
|
// tslint:disable-next-line:no-any
|
|
@@ -66,7 +54,7 @@ function promisify(originalMethod, options) {
|
|
|
66
54
|
resolve(callbackArgs);
|
|
67
55
|
}
|
|
68
56
|
});
|
|
69
|
-
originalMethod.apply(
|
|
57
|
+
originalMethod.apply(this, args);
|
|
70
58
|
});
|
|
71
59
|
};
|
|
72
60
|
wrapper.promisified_ = true;
|
|
@@ -86,9 +74,10 @@ function promisifyAll(Class, options) {
|
|
|
86
74
|
const ownPropertyNames = Object.getOwnPropertyNames(Class.prototype);
|
|
87
75
|
const methods = ownPropertyNames.filter(methodName => {
|
|
88
76
|
// clang-format off
|
|
89
|
-
return (
|
|
90
|
-
|
|
91
|
-
|
|
77
|
+
return (!exclude.includes(methodName) &&
|
|
78
|
+
typeof Class.prototype[methodName] === 'function' && // is it a function?
|
|
79
|
+
!/(^_|(Stream|_)|promise$)|^constructor$/.test(methodName) // is it promisable?
|
|
80
|
+
);
|
|
92
81
|
// clang-format on
|
|
93
82
|
});
|
|
94
83
|
methods.forEach(methodName => {
|
|
@@ -113,12 +102,11 @@ function callbackify(originalMethod) {
|
|
|
113
102
|
}
|
|
114
103
|
// tslint:disable-next-line:no-any
|
|
115
104
|
const wrapper = function () {
|
|
116
|
-
const context = this;
|
|
117
105
|
if (typeof arguments[arguments.length - 1] !== 'function') {
|
|
118
|
-
return originalMethod.apply(
|
|
106
|
+
return originalMethod.apply(this, arguments);
|
|
119
107
|
}
|
|
120
108
|
const cb = Array.prototype.pop.call(arguments);
|
|
121
|
-
originalMethod.apply(
|
|
109
|
+
originalMethod.apply(this, arguments).then(
|
|
122
110
|
// tslint:disable-next-line:no-any
|
|
123
111
|
(res) => {
|
|
124
112
|
res = Array.isArray(res) ? res : [res];
|
|
@@ -143,9 +131,10 @@ Class, options) {
|
|
|
143
131
|
const ownPropertyNames = Object.getOwnPropertyNames(Class.prototype);
|
|
144
132
|
const methods = ownPropertyNames.filter(methodName => {
|
|
145
133
|
// clang-format off
|
|
146
|
-
return (
|
|
147
|
-
|
|
148
|
-
|
|
134
|
+
return (!exclude.includes(methodName) &&
|
|
135
|
+
typeof Class.prototype[methodName] === 'function' && // is it a function?
|
|
136
|
+
!/^_|(Stream|_)|^constructor$/.test(methodName) // is it callbackifyable?
|
|
137
|
+
);
|
|
149
138
|
// clang-format on
|
|
150
139
|
});
|
|
151
140
|
methods.forEach(methodName => {
|
package/package.json
CHANGED
|
@@ -1,25 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@google-cloud/promisify",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.3",
|
|
4
4
|
"description": "A simple utility for promisifying functions and classes.",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"types": "build/src/index.d.ts",
|
|
7
7
|
"repository": "googleapis/nodejs-promisify",
|
|
8
8
|
"scripts": {
|
|
9
|
-
"test": "
|
|
9
|
+
"test": "c8 mocha build/test",
|
|
10
10
|
"lint": "gts check",
|
|
11
|
-
"clean": "gts clean",
|
|
12
11
|
"compile": "tsc -p .",
|
|
13
12
|
"fix": "gts fix",
|
|
14
13
|
"prepare": "npm run compile",
|
|
15
14
|
"pretest": "npm run compile",
|
|
16
|
-
"posttest": "npm run lint",
|
|
17
15
|
"docs": "compodoc src/",
|
|
18
16
|
"presystem-test": "npm run compile",
|
|
19
17
|
"samples-test": "cd samples/ && npm link ../ && npm test && cd ../",
|
|
20
18
|
"system-test": "mocha build/system-test",
|
|
21
19
|
"docs-test": "linkinator docs",
|
|
22
|
-
"predocs-test": "npm run docs"
|
|
20
|
+
"predocs-test": "npm run docs",
|
|
21
|
+
"prelint": "cd samples; npm link ../; npm install",
|
|
22
|
+
"clean": "gts clean",
|
|
23
|
+
"precompile": "gts clean",
|
|
24
|
+
"api-extractor": "api-extractor run --local",
|
|
25
|
+
"api-documenter": "api-documenter yaml --input-folder=temp"
|
|
23
26
|
},
|
|
24
27
|
"keywords": [],
|
|
25
28
|
"files": [
|
|
@@ -30,21 +33,22 @@
|
|
|
30
33
|
"license": "Apache-2.0",
|
|
31
34
|
"devDependencies": {
|
|
32
35
|
"@compodoc/compodoc": "^1.1.9",
|
|
33
|
-
"@types/mocha": "^
|
|
36
|
+
"@types/mocha": "^8.0.0",
|
|
34
37
|
"@types/node": "^10.5.2",
|
|
35
|
-
"@types/sinon": "^
|
|
38
|
+
"@types/sinon": "^9.0.0",
|
|
39
|
+
"c8": "^7.0.0",
|
|
40
|
+
"chai": "^4.2.0",
|
|
36
41
|
"codecov": "^3.0.4",
|
|
37
|
-
"gts": "^
|
|
38
|
-
"hard-rejection": "^2.
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"typescript": "3.6.4"
|
|
42
|
+
"gts": "^2.0.0",
|
|
43
|
+
"hard-rejection": "^2.1.0",
|
|
44
|
+
"linkinator": "^2.0.0",
|
|
45
|
+
"mocha": "^8.0.0",
|
|
46
|
+
"sinon": "^9.0.0",
|
|
47
|
+
"typescript": "^3.8.3",
|
|
48
|
+
"@microsoft/api-documenter": "^7.8.10",
|
|
49
|
+
"@microsoft/api-extractor": "^7.8.10"
|
|
46
50
|
},
|
|
47
51
|
"engines": {
|
|
48
|
-
"node": ">=
|
|
52
|
+
"node": ">=10"
|
|
49
53
|
}
|
|
50
54
|
}
|