emilsoftware-utilities 1.3.13 → 1.3.15

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.
@@ -1,19 +1,5 @@
1
- export declare class Autobind {
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<T extends {
2
+ new (...args: any[]): {};
3
+ }>(constructor: T): {
4
+ new (...args: any[]): {};
5
+ } & T;
package/dist/Autobind.js CHANGED
@@ -1,85 +1,45 @@
1
1
  "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
2
17
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Autobind = void 0;
4
- var Autobind = /** @class */ (function () {
5
- function Autobind() {
6
- }
7
- /**
8
- * Binds a method to the instance, ensuring `this` references are preserved.
9
- */
10
- Autobind.boundMethod = function (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));
14
- }
15
- var definingProperty = false;
16
- return {
17
- configurable: true,
18
- get: function () {
19
- if (definingProperty ||
20
- this === target.prototype ||
21
- Object.prototype.hasOwnProperty.call(this, key) ||
22
- typeof fn !== 'function') {
23
- return fn;
18
+ exports.autobind = autobind;
19
+ function autobind(constructor) {
20
+ return /** @class */ (function (_super) {
21
+ __extends(class_1, _super);
22
+ function class_1() {
23
+ var args = [];
24
+ for (var _i = 0; _i < arguments.length; _i++) {
25
+ args[_i] = arguments[_i];
26
+ }
27
+ var _this = _super.apply(this, args) || this;
28
+ var prototype = Object.getPrototypeOf(_this);
29
+ var propertyNames = Object.getOwnPropertyNames(prototype);
30
+ for (var _a = 0, propertyNames_1 = propertyNames; _a < propertyNames_1.length; _a++) {
31
+ var key = propertyNames_1[_a];
32
+ var descriptor = Object.getOwnPropertyDescriptor(prototype, key);
33
+ if (descriptor && typeof descriptor.value === 'function' && key !== 'constructor') {
34
+ Object.defineProperty(_this, key, {
35
+ value: descriptor.value.bind(_this),
36
+ configurable: true,
37
+ writable: true,
38
+ });
24
39
  }
25
- var boundFn = fn.bind(this);
26
- definingProperty = true;
27
- Object.defineProperty(this, key, {
28
- configurable: true,
29
- get: function () {
30
- return boundFn;
31
- },
32
- set: function (value) {
33
- fn = value;
34
- delete this[key];
35
- },
36
- });
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
40
  }
57
- });
58
- return target;
59
- };
60
- /**
61
- * Retrieves all property keys (including symbols) from the prototype.
62
- */
63
- Autobind.getPrototypeKeys = function (proto) {
64
- if (typeof Reflect !== 'undefined' && typeof Reflect.ownKeys === 'function') {
65
- return Reflect.ownKeys(proto);
41
+ return _this;
66
42
  }
67
- var keys = Object.getOwnPropertyNames(proto);
68
- if (typeof Object.getOwnPropertySymbols === 'function') {
69
- return keys.concat(Object.getOwnPropertySymbols(proto));
70
- }
71
- return keys;
72
- };
73
- Autobind.apply = function () {
74
- var args = [];
75
- for (var _i = 0; _i < arguments.length; _i++) {
76
- args[_i] = arguments[_i];
77
- }
78
- if (args.length === 1) {
79
- return Autobind.boundClass(args[0]);
80
- }
81
- return Autobind.boundMethod(args[0], args[1], args[2]);
82
- };
83
- return Autobind;
84
- }());
85
- exports.Autobind = Autobind;
43
+ return class_1;
44
+ }(constructor));
45
+ }
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 _a;
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 { Autobind } from "./Autobind";
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 { Autobind, ExecutionTimeLogger, Logger, LogLevels, Orm, DateUtilities, RestUtilities, DatabaseUtilities, DatabaseUpdater, StatusCode };
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.Autobind = void 0;
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, "Autobind", { enumerable: true, get: function () { return Autobind_1.Autobind; } });
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");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "emilsoftware-utilities",
3
- "version": "1.3.13",
3
+ "version": "1.3.15",
4
4
  "description": "Utilities for EmilSoftware",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",