emilsoftware-utilities 1.3.13 → 1.3.14
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/dist/Autobind.d.ts +1 -19
- package/dist/Autobind.js +74 -67
- package/dist/Orm.js +1 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/dist/Autobind.d.ts
CHANGED
|
@@ -1,19 +1 @@
|
|
|
1
|
-
export declare
|
|
2
|
-
/**
|
|
3
|
-
* Binds a method to the instance, ensuring `this` references are preserved.
|
|
4
|
-
*/
|
|
5
|
-
static boundMethod(target: any, key: any, descriptor: any): {
|
|
6
|
-
configurable: boolean;
|
|
7
|
-
get(): any;
|
|
8
|
-
set(value: any): void;
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* Applies `boundMethod` to all methods in the class prototype.
|
|
12
|
-
*/
|
|
13
|
-
static boundClass(target: any): any;
|
|
14
|
-
/**
|
|
15
|
-
* Retrieves all property keys (including symbols) from the prototype.
|
|
16
|
-
*/
|
|
17
|
-
private static getPrototypeKeys;
|
|
18
|
-
static apply(...args: any[]): any;
|
|
19
|
-
}
|
|
1
|
+
export declare function autobind(...args: any[]): any;
|
package/dist/Autobind.js
CHANGED
|
@@ -1,29 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
exports.autobind = autobind;
|
|
4
|
+
// DECORATOR
|
|
5
|
+
/**
|
|
6
|
+
* Return a descriptor removing the value and returning a getter
|
|
7
|
+
* The getter will return a .bind version of the function
|
|
8
|
+
* and memoize the result against a symbol on the instance
|
|
9
|
+
*/
|
|
10
|
+
function boundMethod(target, key, descriptor) {
|
|
11
|
+
var fn = descriptor === null || descriptor === void 0 ? void 0 : descriptor.value;
|
|
12
|
+
if (typeof fn !== 'function') {
|
|
13
|
+
throw new TypeError("@boundMethod decorator can only be applied to methods not: ".concat(typeof fn));
|
|
6
14
|
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
typeof fn !== 'function') {
|
|
23
|
-
return fn;
|
|
24
|
-
}
|
|
25
|
-
var boundFn = fn.bind(this);
|
|
26
|
-
definingProperty = true;
|
|
15
|
+
// In IE11 calling Object.defineProperty has a side effect of evaluating the
|
|
16
|
+
// getter for the property which is being replaced. This causes infinite
|
|
17
|
+
// recursion and an "Out of stack space" error.
|
|
18
|
+
var definingProperty = false;
|
|
19
|
+
return {
|
|
20
|
+
configurable: true,
|
|
21
|
+
get: function () {
|
|
22
|
+
// eslint-disable-next-line no-prototype-builtins
|
|
23
|
+
if (definingProperty || this === target.prototype || this.hasOwnProperty(key) ||
|
|
24
|
+
typeof fn !== 'function') {
|
|
25
|
+
return fn;
|
|
26
|
+
}
|
|
27
|
+
var boundFn = fn.bind(this);
|
|
28
|
+
definingProperty = true;
|
|
29
|
+
if (key) {
|
|
27
30
|
Object.defineProperty(this, key, {
|
|
28
31
|
configurable: true,
|
|
29
32
|
get: function () {
|
|
@@ -31,55 +34,59 @@ var Autobind = /** @class */ (function () {
|
|
|
31
34
|
},
|
|
32
35
|
set: function (value) {
|
|
33
36
|
fn = value;
|
|
37
|
+
// @ts-ignore
|
|
34
38
|
delete this[key];
|
|
35
|
-
}
|
|
39
|
+
}
|
|
36
40
|
});
|
|
37
|
-
definingProperty = false;
|
|
38
|
-
return boundFn;
|
|
39
|
-
},
|
|
40
|
-
set: function (value) {
|
|
41
|
-
fn = value;
|
|
42
|
-
},
|
|
43
|
-
};
|
|
44
|
-
};
|
|
45
|
-
/**
|
|
46
|
-
* Applies `boundMethod` to all methods in the class prototype.
|
|
47
|
-
*/
|
|
48
|
-
Autobind.boundClass = function (target) {
|
|
49
|
-
var keys = Autobind.getPrototypeKeys(target.prototype);
|
|
50
|
-
keys.forEach(function (key) {
|
|
51
|
-
if (key === 'constructor')
|
|
52
|
-
return;
|
|
53
|
-
var descriptor = Object.getOwnPropertyDescriptor(target.prototype, key);
|
|
54
|
-
if (descriptor && typeof descriptor.value === 'function') {
|
|
55
|
-
Object.defineProperty(target.prototype, key, Autobind.boundMethod(target, key, descriptor));
|
|
56
41
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
*/
|
|
63
|
-
Autobind.getPrototypeKeys = function (proto) {
|
|
64
|
-
if (typeof Reflect !== 'undefined' && typeof Reflect.ownKeys === 'function') {
|
|
65
|
-
return Reflect.ownKeys(proto);
|
|
42
|
+
definingProperty = false;
|
|
43
|
+
return boundFn;
|
|
44
|
+
},
|
|
45
|
+
set: function (value) {
|
|
46
|
+
fn = value;
|
|
66
47
|
}
|
|
67
|
-
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Use boundMethod to bind all methods on the target.prototype
|
|
52
|
+
*/
|
|
53
|
+
function boundClass(target) {
|
|
54
|
+
// (Using reflect to get all keys including symbols)
|
|
55
|
+
var keys;
|
|
56
|
+
// Use Reflect if exists
|
|
57
|
+
if (typeof Reflect !== 'undefined' && typeof Reflect.ownKeys === 'function') {
|
|
58
|
+
keys = Reflect.ownKeys(target.prototype);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
keys = Object.getOwnPropertyNames(target.prototype);
|
|
62
|
+
// Use symbols if support is provided
|
|
68
63
|
if (typeof Object.getOwnPropertySymbols === 'function') {
|
|
69
|
-
|
|
64
|
+
// @ts-ignore
|
|
65
|
+
keys = keys.concat(Object.getOwnPropertySymbols(target.prototype));
|
|
70
66
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
args[_i] = arguments[_i];
|
|
67
|
+
}
|
|
68
|
+
keys.forEach(function (key) {
|
|
69
|
+
// Ignore special case target method
|
|
70
|
+
if (key === 'constructor') {
|
|
71
|
+
return;
|
|
77
72
|
}
|
|
78
|
-
|
|
79
|
-
|
|
73
|
+
var descriptor = Object.getOwnPropertyDescriptor(target.prototype, key);
|
|
74
|
+
// Only methods need binding
|
|
75
|
+
if (typeof (descriptor === null || descriptor === void 0 ? void 0 : descriptor.value) === 'function') {
|
|
76
|
+
Object.defineProperty(target.prototype, key, boundMethod(target, key, descriptor));
|
|
80
77
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
78
|
+
});
|
|
79
|
+
return target;
|
|
80
|
+
}
|
|
81
|
+
function autobind() {
|
|
82
|
+
var args = [];
|
|
83
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
84
|
+
args[_i] = arguments[_i];
|
|
85
|
+
}
|
|
86
|
+
if (args.length === 1) {
|
|
87
|
+
// @ts-ignore
|
|
88
|
+
return boundClass.apply(void 0, args);
|
|
89
|
+
}
|
|
90
|
+
// @ts-ignore
|
|
91
|
+
return boundMethod.apply(void 0, args);
|
|
92
|
+
}
|
package/dist/Orm.js
CHANGED
|
@@ -103,8 +103,7 @@ var Logger_1 = require("./Logger");
|
|
|
103
103
|
var Utilities_1 = require("./Utilities");
|
|
104
104
|
var Autobind_1 = require("./Autobind");
|
|
105
105
|
var Orm = function () {
|
|
106
|
-
var
|
|
107
|
-
var _classDecorators = [(_a = Autobind_1.Autobind).apply.bind(_a)];
|
|
106
|
+
var _classDecorators = [Autobind_1.autobind];
|
|
108
107
|
var _classDescriptor;
|
|
109
108
|
var _classExtraInitializers = [];
|
|
110
109
|
var _classThis;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { autobind } from "./Autobind";
|
|
2
2
|
import { DatabaseUpdater } from "./DatabaseUpdater";
|
|
3
3
|
import { ExecutionTimeLogger } from "./ExecutionTimeLogger";
|
|
4
4
|
import { LogLevels, Logger } from "./Logger";
|
|
5
5
|
import { Orm } from "./Orm";
|
|
6
6
|
import { DateUtilities, RestUtilities, DatabaseUtilities, StatusCode } from "./Utilities";
|
|
7
7
|
export * from "es-node-firebird";
|
|
8
|
-
export {
|
|
8
|
+
export { autobind, ExecutionTimeLogger, Logger, LogLevels, Orm, DateUtilities, RestUtilities, DatabaseUtilities, DatabaseUpdater, StatusCode };
|
package/dist/index.js
CHANGED
|
@@ -14,9 +14,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.StatusCode = exports.DatabaseUpdater = exports.DatabaseUtilities = exports.RestUtilities = exports.DateUtilities = exports.Orm = exports.LogLevels = exports.Logger = exports.ExecutionTimeLogger = exports.
|
|
17
|
+
exports.StatusCode = exports.DatabaseUpdater = exports.DatabaseUtilities = exports.RestUtilities = exports.DateUtilities = exports.Orm = exports.LogLevels = exports.Logger = exports.ExecutionTimeLogger = exports.autobind = void 0;
|
|
18
18
|
var Autobind_1 = require("./Autobind");
|
|
19
|
-
Object.defineProperty(exports, "
|
|
19
|
+
Object.defineProperty(exports, "autobind", { enumerable: true, get: function () { return Autobind_1.autobind; } });
|
|
20
20
|
var DatabaseUpdater_1 = require("./DatabaseUpdater");
|
|
21
21
|
Object.defineProperty(exports, "DatabaseUpdater", { enumerable: true, get: function () { return DatabaseUpdater_1.DatabaseUpdater; } });
|
|
22
22
|
var ExecutionTimeLogger_1 = require("./ExecutionTimeLogger");
|