From 66aab11faef6ca9825227276eec71c12ccb112ab Mon Sep 17 00:00:00 2001 From: wentout Date: Sun, 1 Sep 2024 19:59:16 +0300 Subject: [PATCH] new.target for function based constructors --- .eslintrc.js | 11 +- build/api/types/InstanceCreator.js | 6 +- build/api/types/InstanceCreator.js.map | 2 +- build/api/types/TypeProxy.js | 7 + build/api/types/TypeProxy.js.map | 2 +- .../compileNewModificatorFunctionBody.js | 12 +- .../compileNewModificatorFunctionBody.js.map | 2 +- package-lock.json | 534 ++++--- package.json | 9 +- src/api/types/InstanceCreator.ts | 32 +- src/api/types/TypeProxy.ts | 137 +- .../compileNewModificatorFunctionBody.ts | 26 +- test/AsyncNewTest.js | 12 + test/environment.js | 1323 +++++++++-------- test/hookSamples.js | 2 + test/hooks.js | 102 +- test/index.js | 30 +- test/v8bug.js | 64 + 18 files changed, 1281 insertions(+), 1032 deletions(-) create mode 100644 test/AsyncNewTest.js create mode 100644 test/v8bug.js diff --git a/.eslintrc.js b/.eslintrc.js index 3d1ab9d..7852502 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -20,7 +20,7 @@ module.exports = { '@typescript-eslint' ], rules: { - indent: ['error', 'tab'], + 'indent': ['error', 'tab'], 'key-spacing': [ 'warn', { @@ -30,8 +30,8 @@ module.exports = { }, ], 'linebreak-style': ['error', 'unix'], - quotes: ['error', 'single'], - semi: ['error', 'always'], + 'quotes': ['error', 'single'], + 'semi': ['error', 'always'], 'no-unused-vars': 'off', '@typescript-eslint/no-unused-vars': 'error', 'no-shadow': [ @@ -42,11 +42,11 @@ module.exports = { allow: [], }, ], - 'array-bracket-spacing': ['warn', 'always'], + 'array-bracket-spacing': ['error', 'always'], 'computed-property-spacing': ['error', 'always'], 'object-curly-spacing': ['error', 'always'], 'space-before-function-paren': [ - 'warn', { + 'error', { 'anonymous': 'always', 'named': 'always', 'asyncArrow': 'always' @@ -84,6 +84,7 @@ module.exports = { ], '@typescript-eslint/no-var-requires': 'off', '@typescript-eslint/no-empty-function': 'off', + '@typescript-eslint/no-explicit-any': 'off', yoda: 'warn', }, overrides: [{ diff --git a/build/api/types/InstanceCreator.js b/build/api/types/InstanceCreator.js index 6e68b86..21350f7 100644 --- a/build/api/types/InstanceCreator.js +++ b/build/api/types/InstanceCreator.js @@ -238,14 +238,16 @@ exports.InstanceCreator = function (type, existentInstance, args, chained) { self.InstanceModificator = (0, InstanceModificator_1.makeInstanceModificator)(self); if (blockErrors) { try { - self.inheritedInstance = new self.InstanceModificator(...args); + const answer = new self.InstanceModificator(...args); + self.inheritedInstance = answer; } catch (error) { self.throwModificationError(error); } } else { - self.inheritedInstance = new self.InstanceModificator(...args); + const answer = new self.InstanceModificator(...args); + self.inheritedInstance = answer; } if (self.inheritedInstance instanceof Promise) { const waiter = self.makeWaiter(type); diff --git a/build/api/types/InstanceCreator.js.map b/build/api/types/InstanceCreator.js.map index 01f51d1..af653d7 100644 --- a/build/api/types/InstanceCreator.js.map +++ b/build/api/types/InstanceCreator.js.map @@ -1 +1 @@ -{"version":3,"file":"InstanceCreator.js","sourceRoot":"","sources":["../../../src/api/types/InstanceCreator.ts"],"names":[],"mappings":"AACA,YAAY,CAAC;;;AAIb,+CAA4C;AAE5C,MAAM,EACL,GAAG,EACH,qBAAqB,GACrB,GAAG,qBAAS,CAAC;AAEd,qDAAuD;AACvD,MAAM,EACL,0BAA0B,GAC1B,GAAG,oBAAW,CAAC;AAEhB,oCAAkC;AAClC,MAAM,EACL,0BAA0B,EAC1B,qBAAqB,EACrB,uBAAuB,GACvB,GAAG,eAAU,CAAC;AAEf,sCAAqC;AACrC,6EAA0E;AAC1E,iFAA8E;AAE9E,yCAAsC;AAEtC,+DAAgE;AAEhE,MAAM,cAAc,GAAG;IAEtB,MAAM,EACL,IAAI,EACJ,gBAAgB,EAChB,IAAI,EACJ,mBAAmB,EACnB,GAAG,IAAI,CAAC;IAET,MAAM,EACL,SAAS,EACT,UAAU,GACV,GAAG,IAAI,CAAC;IAET,MAAM,QAAQ,GAAG;QAChB,IA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;IAED,IAAI,CAAC,cAAc,CAAE,IAAI,CAAE,CAAC;IAE5B,OAAO,IAAI,CAAC,iBAAiB,CAAC;AAE/B,CAAyD,CAAC;AAE1D,MAAM,CAAC,MAAM,CAAE,uBAAe,CAAC,SAAS,EAAE,wBAAwB,CAAE,CAAC"} \ No newline at end of file +{"version":3,"file":"InstanceCreator.js","sourceRoot":"","sources":["../../../src/api/types/InstanceCreator.ts"],"names":[],"mappings":"AACA,YAAY,CAAC;;;AAIb,+CAA4C;AAE5C,MAAM,EACL,GAAG,EACH,qBAAqB,GACrB,GAAG,qBAAS,CAAC;AAEd,qDAAuD;AACvD,MAAM,EACL,0BAA0B,GAC1B,GAAG,oBAAW,CAAC;AAEhB,oCAAkC;AAClC,MAAM,EACL,0BAA0B,EAC1B,qBAAqB,EACrB,uBAAuB,GACvB,GAAG,eAAU,CAAC;AAEf,sCAAqC;AACrC,6EAA0E;AAC1E,iFAA8E;AAE9E,yCAAsC;AAEtC,+DAAgE;AAEhE,MAAM,cAAc,GAAG;IAEtB,MAAM,EACL,IAAI,EACJ,gBAAgB,EAChB,IAAI,EACJ,mBAAmB,EACnB,GAAG,IAAI,CAAC;IAET,MAAM,EACL,SAAS,EACT,UAAU,GACV,GAAG,IAAI,CAAC;IAET,MAAM,QAAQ,GAAG;QAChB,IAAI;QACJ,gBAAgB;QAChB,IAAI;QACJ,mBAAmB;KACnB,CAAC;IAEF,SAAS,CAAC,UAAU,CAAE,aAAa,EAAE,QAAQ,CAAE,CAAC;IAEhD,UAAU,CAAC,UAAU,CAAE,aAAa,EAAE,QAAQ,CAAE,CAAC;IAEjD,IAAI,CAAC,UAAU,CAAE,aAAa,EAAE,QAAQ,CAAE,CAAC;AAE5C,CAAC,CAAC;AAGF,MAAM,eAAe,GAAG;IAGvB,MAAM,OAAO,GAAG,IAAI,CAAC;IACrB,MAAM,EACL,iBAAiB,GACjB,GAAG,OAAO,CAAC;IAEZ,MAAM,EACL,QAAQ,EAAE,IAAI,EACd,UAAU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,CAAC,mBAAmB,CAAE,GAAG,IAAI,CAAE,CAAC;IAE/C,CAAC;IAED,IAAI,CAAC,cAAc,EAAE,CAAC;IAEtB,IAAI,CAAC,mBAAmB,GAAG,IAAA,6CAAuB,EAAE,IAAI,CAAE,CAAC;IAE3D,IAAK,WAAW,EAAG,CAAC;QAEnB,IAAI,CAAC;YAEJ,MAAM,MAAM,GAAG,IAAI,IAAI,CAAC,mBAAmB,CAAE,GAAG,IAAI,CAAE,CAAC;YAEvD,IAAI,CAAC,iBAAiB,GAAG,MAAM,CAAC;QAEjC,CAAC;QAAC,OAAQ,KAAK,EAAG,CAAC;YAElB,IAAI,CAAC,sBAAsB,CAAE,KAAK,CAAE,CAAC;QAEtC,CAAC;IAEF,CAAC;SAAM,CAAC;QAEP,MAAM,MAAM,GAAG,IAAI,IAAI,CAAC,mBAAmB,CAAE,GAAG,IAAI,CAAE,CAAC;QAEvD,IAAI,CAAC,iBAAiB,GAAG,MAAM,CAAC;IAEjC,CAAC;IAGD,IAAK,IAAI,CAAC,iBAAiB,YAAY,OAAO,EAAG,CAAC;QAEjD,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,CAAE,IAAI,CAAE,CAAC;QAEvC,GAAG,CAAE,MAAM,EAAE,qBAAqB,EAAE;YACnC,GAAG;gBACF,OAAO,QAAQ,CAAC;YACjB,CAAC;SACD,CAAE,CAAC;QAEJ,OAAO,MAAM,CAAC;IAEf,CAAC;IAED,IAAI,CAAC,cAAc,CAAE,IAAI,CAAE,CAAC;IAE5B,OAAO,IAAI,CAAC,iBAAiB,CAAC;AAE/B,CAAyD,CAAC;AAE1D,MAAM,CAAC,MAAM,CAAE,uBAAe,CAAC,SAAS,EAAE,wBAAwB,CAAE,CAAC"} \ No newline at end of file diff --git a/build/api/types/TypeProxy.js b/build/api/types/TypeProxy.js index 8c8c944..b7d4b82 100644 --- a/build/api/types/TypeProxy.js +++ b/build/api/types/TypeProxy.js @@ -151,7 +151,14 @@ exports.TypeProxy.prototype.construct = function (__, args) { const gaiaProxy = new Proxy(gaia, { get: gaiaProxyHandlerGet }); + if (args[0] === 'NullishReturn') { + debugger; + } const instance = new InstanceCreator_1.InstanceCreator(type, gaiaProxy, args); + if (args[0] === 'NullishReturn') { + instance; + debugger; + } return instance; }; //# sourceMappingURL=TypeProxy.js.map \ No newline at end of file diff --git a/build/api/types/TypeProxy.js.map b/build/api/types/TypeProxy.js.map index 0cd880a..6344ffc 100644 --- a/build/api/types/TypeProxy.js.map +++ b/build/api/types/TypeProxy.js.map @@ -1 +1 @@ -{"version":3,"file":"TypeProxy.js","sourceRoot":"","sources":["../../../src/api/types/TypeProxy.ts"],"names":[],"mappings":"AACA,YAAY,CAAC;;;AAIb,+CAA4C;AAC5C,MAAM,EACL,UAAU,GACV,GAAG,qBAAS,CAAC;AAEd,yCAAsC;AAEtC,qDAAuD;AACvD,MAAM,EACL,qBAAqB,GACrB,GAAG,oBAAW,CAAC;AAEhB,oCAAkC;AAClC,MAAM,EACL,UAAU,EACV,cAAc,EACd,iBAAiB,EACjB,wBAAwB,GACxB,GAAG,eAAU,CAAC;AAEf,2CAAqC;AACrC,MAAM,EACL,IAAI,EACJ,SAAS,EACT,sBAAsB,EACtB,GAAG,mBAAU,CAAC;AAEf,uDAAoD;AAEvC,QAAA,SAAS,GAAG,UAAU,QAAa,EAAE,MAAW;IAC5D,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE;QACnB,QAAQ;QACR,MAAM;KACN,CAAC,CAAC;IACH,MAAM,SAAS,GAAG,IAAI,KAAK,CAAC,iCAAe,EAAE,IAAI,CAAC,CAAC;IACnD,OAAO,SAAS,CAAC;AAClB,CAA6B,CAAC;AAE9B,iBAAS,CAAC,SAAS,CAAC,GAAG,GAAG,UAAU,MAAW,EAAE,IAAY;IAE5D,MAAM,EACL,QAAQ,EAAE,IAAI,EACd,GAAG,IAAI,CAAC;IAKT,IAAI,IAAI,KAAK,WAAW,EAAE,CAAC;QAC1B,OAAO,IAAI,CAAC,KAAK,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5D,OAAO,QAAQ,CAAC;AAEjB,CAAC,CAAC"} \ No newline at end of file +{"version":3,"file":"TypeProxy.js","sourceRoot":"","sources":["../../../src/api/types/TypeProxy.ts"],"names":[],"mappings":"AACA,YAAY,CAAC;;;AAIb,+CAA4C;AAC5C,MAAM,EACL,UAAU,GACV,GAAG,qBAAS,CAAC;AAEd,yCAAsC;AAEtC,qDAAuD;AACvD,MAAM,EACL,qBAAqB,GACrB,GAAG,oBAAW,CAAC;AAEhB,oCAAkC;AAClC,MAAM,EACL,UAAU,EACV,cAAc,EACd,iBAAiB,EACjB,wBAAwB,GACxB,GAAG,eAAU,CAAC;AAEf,2CAAqC;AACrC,MAAM,EACL,IAAI,EACJ,SAAS,EACT,sBAAsB,EACtB,GAAG,mBAAU,CAAC;AAEf,uDAAoD;AAEvC,QAAA,SAAS,GAAG,UAAW,QAAa,EAAE,MAAW;IAC7D,MAAM,CAAC,MAAM,CAAE,IAAI,EAAE;QACpB,QAAQ;QACR,MAAM;KACN,CAAE,CAAC;IACJ,MAAM,SAAS,GAAG,IAAI,KAAK,CAAE,iCAAe,EAAE,IAAI,CAAE,CAAC;IACrD,OAAO,SAAS,CAAC;AAClB,CAA6B,CAAC;AAE9B,iBAAS,CAAC,SAAS,CAAC,GAAG,GAAG,UAAW,MAAW,EAAE,IAAY;IAE7D,MAAM,EACL,QAAQ,EAAE,IAAI,EACd,GAAG,IAAI,CAAC;IAKT,IAAK,IAAI,KAAK,WAAW,EAAG,CAAC;QAC5B,OAAO,IAAI,CAAC,KAAK,CAAC;IACnB,CAAC;IAED,MAAM,eAAe,GAAG,IAAI,CAAE,IAAI,CAAE,CAAC;IACrC,IAAK,eAAe,EAAG,CAAC;QACvB,OAAO,eAAe,CAAC;IACxB,CAAC;IAID,IAAK,IAAA,SAAG,EAAE,IAAI,EAAE,IAAI,CAAE,EAAG,CAAC;QACzB,OAAO,eAAe,CAAC;IACxB,CAAC;IAGD,IAAK,IAAI,CAAC,QAAQ,CAAC,GAAG,C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/types/compileNewModificatorFunctionBody.js index 9978fe6..685664b 100644 --- a/build/api/types/compileNewModificatorFunctionBody.js +++ b/build/api/types/compileNewModificatorFunctionBody.js @@ -9,8 +9,18 @@ const getClassConstructor = (ConstructHandler, CreationHandler) => { }; }; const getFunctionConstructor = (ConstructHandler, CreationHandler) => { + const newable = Object.hasOwnProperty.call(ConstructHandler, 'prototype'); return function (...args) { - const answer = ConstructHandler.call(this, ...args); + let answer; + if (!newable) { + answer = ConstructHandler.call(this, ...args); + } + else { + const _proto = ConstructHandler.prototype; + ConstructHandler.prototype = this.constructor.prototype; + answer = new ConstructHandler(...args); + ConstructHandler.prototype = _proto; + } return CreationHandler.call(this, answer); }; }; diff --git a/build/api/types/compileNewModificatorFunctionBody.js.map b/build/api/types/compileNewModificatorFunctionBody.js.map index a9aecfb..bc13f16 100644 --- a/build/api/types/compileNewModificatorFunctionBody.js.map +++ b/build/api/types/compileNewModificatorFunctionBody.js.map @@ -1 +1 @@ -{"version":3,"file":"compileNewModificatorFunctionBody.js","sourceRoot":"","sources":["../../../src/api/types/compileNewModificatorFunctionBody.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAkCb,MAAM,mBAAmB,GAAG,CAAE,gBAAqB,EAAE,eAAoB,EAAI,EAAE;IAC9E,OAAO,KAAM,SAAQ,gBAAgB;QACpC,YAAc,GAAG,IAAW;YAC3B,MAAM,MAAM,GAAG,KAAK,CAAE,GAAG,IAAI,CAAE,CAAC;YAEhC,OAAO,eAAe,CAAC,IAAI,CAAE,IAAI,EAAE,MAAM,CAAE,CAAC;QAC7C,CAAC;KACD,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,sBAAsB,GAAG,CAAE,gBAAqB,EAAE,eAAoB,EAAI,EAAE;IACjF,OAAO,UAAsB,GAAG,IAAW;QAC1C,MAAM,MAAM,GAAG,gBAAgB,CAAC,IAAI,CAAE,IAAI,EAAE,GAAG,IAAI,CAAE,CAAC;QAEtD,OAAO,eAAe,CAAC,IAAI,CAAE,IAAI,EAAE,MAAM,CAAE,CAAC;IAC7C,CAAC,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,iCAAiC,GAAG,UAAW,YAAoB,EAAE,OAAO,GAAG,KAAK;IACzF,OAAO,UAAW,gBAAqB,EAAE,eAAoB,EAAE,qBAA6B;QAC3F,OAAO;YACN,IAAI,gBAAqB,CAAC;YAC1B,IAAK,OAAO,EAAG,CAAC;gBACf,gBAAgB,GAAG,mBAAmB,CAAE,gBAAgB,EAAE,eAAe,CAAE,CAAC;YAC7E,CAAC;iBAAM,CAAC;gBACP,gBAAgB,GAAG,sBAAsB,CAAE,gBAAgB,EAAE,eAAe,CAAE,CAAC;YAChF,CAAC;YACD,gBAAgB,CAAC,SAAS,CAAC,WAAW,GAAG,gBAAgB,CAAC;YAC1D,MAAM,CAAC,cAAc,CAAE,gBAAgB,CAAC,SAAS,CAAC,WAAW,EAAE,MAAM,EAAE;gBACtE,KAAK,EAAM,YAAY;gBACvB,QAAQ,EAAG,KAAK;aAChB,CAAE,CAAC;YACJ,MAAM,CAAC,cAAc,CAAE,gBAAgB,EAAE,qBAAqB,EAAE;gBAC/D,GAAG;oBACF,OAAO,YAAY,CAAC;gBACrB,CAAC;aACD,CAAE,CAAC;YACJ,OAAO,gBAAgB,CAAC;QACzB,CAAC,CAAC;IACH,CAAC,CAAC;AACH,CAAC,CAAC;AAEF,kBAAe,iCAAiC,CAAC"} \ No newline at end of file +{"version":3,"file":"compileNewModificatorFunctionBody.js","sourceRoot":"","sources":["../../../src/api/types/compileNewModificatorFunctionBody.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAkCb,MAAM,mBAAmB,GAAG,CAAE,gBAAqB,EAAE,eAAoB,EAAI,EAAE;IAC9E,OAAO,KAAM,SAAQ,gBAAgB;QACpC,YAAa,GAAG,IAAW;YAC1B,MAAM,MAAM,GAAG,KAAK,CAAE,GAAG,IAAI,CAAE,CAAC;YAEhC,OAAO,eAAe,CAAC,IAAI,CAAE,IAAI,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,CAAC,WAAW,EAAE,MAAM,EAAE;gBACtE,KAAK,EAAE,YAAY;gBACnB,QAAQ,EAAE,KAAK;aACf,CAAE,CAAC;YACJ,MAAM,CAAC,cAAc,CAAE,gBAAgB,EAAE,qBAAqB,EAAE;gBAC/D,GAAG;oBACF,OAAO,YAAY,CAAC;gBACrB,CAAC;aACD,CAAE,CAAC;YACJ,OAAO,gBAAgB,CAAC;QACzB,CAAC,CAAC;IACH,CAAC,CAAC;AACH,CAAC,CAAC;AAEF,kBAAe,iCAAiC,CAAC"} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 333d655..aebbe69 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,16 +1,16 @@ { "name": "mnemonica", - "version": "0.9.984", + "version": "0.9.985", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "mnemonica", - "version": "0.9.984", + "version": "0.9.985", "license": "MIT", "devDependencies": { "@types/jest": "^29.5.12", - "@types/node": "^18.19.44", + "@types/node": "^18.19.48", "@typescript-eslint/eslint-plugin": "^5.62.0", "@typescript-eslint/parser": "^5.62.0", "chai": "^4.5.0", @@ -21,11 +21,11 @@ "husky": "^8.0.3", "jest": "^29.7.0", "json5": "^2.2.3", - "lint-staged": "^13.3.0", + "lint-staged": "^15.2.10", "mocha": "^10.7.3", "mocha-lcov-reporter": "^1.3.0", "nyc": "^15.1.0", - "ts-jest": "^29.2.4", + "ts-jest": "^29.2.5", "typescript": "^5.5.4" }, "engines": { @@ -61,9 +61,9 @@ } }, "node_modules/@babel/compat-data": { - "version": "7.25.2", - "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.25.2.tgz", - "integrity": "sha512-bYcppcpKBvX4znYaPEeFau03bp89ShqNMLs+rmdptMw+heSZh9+z84d2YG+K7cYLbWwzdjtDoW/uqZmPjulClQ==", + "version": "7.25.4", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.25.4.tgz", + "integrity": "sha512-+LGRog6RAsCJrrrg/IO6LGmpphNe5DiK30dGjCoxxeGv49B10/3XYGxPsAwrDlMFcFEvdAUavDT8r9k/hSyQqQ==", "dev": true, "license": "MIT", "engines": { @@ -112,13 +112,13 @@ } }, "node_modules/@babel/generator": { - "version": "7.25.0", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.25.0.tgz", - "integrity": "sha512-3LEEcj3PVW8pW2R1SR1M89g/qrYk/m/mB/tLqn7dn4sbBUQyTqnlod+II2U4dqiGtUmkcnAmkMDralTFZttRiw==", + "version": "7.25.6", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.25.6.tgz", + "integrity": "sha512-VPC82gr1seXOpkjAAKoLhP50vx4vGNlF4msF64dSFq1P8RfB+QAuJWGHPXXPc8QyfVWwwB/TNNU4+ayZmHNbZw==", "dev": true, "license": "MIT", "dependencies": { - "@babel/types": "^7.25.0", + "@babel/types": "^7.25.6", "@jridgewell/gen-mapping": "^0.3.5", "@jridgewell/trace-mapping": "^0.3.25", "jsesc": "^2.5.1" @@ -242,14 +242,14 @@ } }, "node_modules/@babel/helpers": { - "version": "7.25.0", - "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.25.0.tgz", - "integrity": "sha512-MjgLZ42aCm0oGjJj8CtSM3DB8NOOf8h2l7DCTePJs29u+v7yO/RBX9nShlKMgFnRks/Q4tBAe7Hxnov9VkGwLw==", + "version": "7.25.6", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.25.6.tgz", + "integrity": "sha512-Xg0tn4HcfTijTwfDwYlvVCl43V6h4KyVVX2aEm4qdO/PC6L2YvzLHFdmxhoeSA3eslcE6+ZVXHgWwopXYLNq4Q==", "dev": true, "license": "MIT", "dependencies": { "@babel/template": "^7.25.0", - "@babel/types": "^7.25.0" + "@babel/types": "^7.25.6" }, "engines": { "node": ">=6.9.0" @@ -350,13 +350,13 @@ } }, "node_modules/@babel/parser": { - "version": "7.25.3", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.25.3.tgz", - "integrity": "sha512-iLTJKDbJ4hMvFPgQwwsVoxtHyWpKKPBrxkANrSYewDPaPpT5py5yeVkgPIJ7XYXhndxJpaA3PyALSXQ7u8e/Dw==", + "version": "7.25.6", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.25.6.tgz", + "integrity": "sha512-trGdfBdbD0l1ZPmcJ83eNxB9rbEax4ALFTF7fN386TMYbeCQbyme5cOEXQhbGXKebwGaB/J52w1mrklMcbgy6Q==", "dev": true, "license": "MIT", "dependencies": { - "@babel/types": "^7.25.2" + "@babel/types": "^7.25.6" }, "bin": { "parser": "bin/babel-parser.js" @@ -421,13 +421,13 @@ } }, "node_modules/@babel/plugin-syntax-import-attributes": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-import-attributes/-/plugin-syntax-import-attributes-7.24.7.tgz", - "integrity": "sha512-hbX+lKKeUMGihnK8nvKqmXBInriT3GVjzXKFriV3YC6APGxMbP8RZNFwy91+hocLXq90Mta+HshoB31802bb8A==", + "version": "7.25.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-import-attributes/-/plugin-syntax-import-attributes-7.25.6.tgz", + "integrity": "sha512-sXaDXaJN9SNLymBdlWFA+bjzBhFD617ZaFiY13dGt7TVslVvVgA6fkZOP7Ki3IGElC45lwHdOTrCtKZGVAWeLQ==", "dev": true, "license": "MIT", "dependencies": { - "@babel/helper-plugin-utils": "^7.24.7" + "@babel/helper-plugin-utils": "^7.24.8" }, "engines": { "node": ">=6.9.0" @@ -589,13 +589,13 @@ } }, "node_modules/@babel/plugin-syntax-typescript": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.24.7.tgz", - "integrity": "sha512-c/+fVeJBB0FeKsFvwytYiUD+LBvhHjGSI0g446PRGdSVGZLRNArBUno2PETbAly3tpiNAQR5XaZ+JslxkotsbA==", + "version": "7.25.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.25.4.tgz", + "integrity": "sha512-uMOCoHVU52BsSWxPOMVv5qKRdeSlPuImUCB2dlPuBSU+W2/ROE7/Zg8F2Kepbk+8yBa68LlRKxO+xgEVWorsDg==", "dev": true, "license": "MIT", "dependencies": { - "@babel/helper-plugin-utils": "^7.24.7" + "@babel/helper-plugin-utils": "^7.24.8" }, "engines": { "node": ">=6.9.0" @@ -620,17 +620,17 @@ } }, "node_modules/@babel/traverse": { - "version": "7.25.3", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.25.3.tgz", - "integrity": "sha512-HefgyP1x754oGCsKmV5reSmtV7IXj/kpaE1XYY+D9G5PvKKoFfSbiS4M77MdjuwlZKDIKFCffq9rPU+H/s3ZdQ==", + "version": "7.25.6", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.25.6.tgz", + "integrity": "sha512-9Vrcx5ZW6UwK5tvqsj0nGpp/XzqthkT0dqIc9g1AdtygFToNtTF67XzYS//dm+SAK9cp3B9R4ZO/46p63SCjlQ==", "dev": true, "license": "MIT", "dependencies": { "@babel/code-frame": "^7.24.7", - "@babel/generator": "^7.25.0", - "@babel/parser": "^7.25.3", + "@babel/generator": "^7.25.6", + "@babel/parser": "^7.25.6", "@babel/template": "^7.25.0", - "@babel/types": "^7.25.2", + "@babel/types": "^7.25.6", "debug": "^4.3.1", "globals": "^11.1.0" }, @@ -649,9 +649,9 @@ } }, "node_modules/@babel/types": { - "version": "7.25.2", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.25.2.tgz", - "integrity": "sha512-YTnYtra7W9e6/oAZEHj0bJehPRUlLH9/fbpT5LfB0NhQXyALCRkRs3zH9v07IYhkgpqX6Z78FnuccZr/l4Fs4Q==", + "version": "7.25.6", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.25.6.tgz", + "integrity": "sha512-/l42B1qxpG6RdfYf343Uw1vmDjeNhneUXtzhojE7pDgfpEypmRhI6j1kr17XCVv4Cgl9HdAiQY2x0GwKm7rWCw==", "dev": true, "license": "MIT", "dependencies": { @@ -1413,9 +1413,9 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "18.19.44", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.44.tgz", - "integrity": "sha512-ZsbGerYg72WMXUIE9fYxtvfzLEuq6q8mKERdWFnqTmOvudMxnz+CBNRoOwJ2kNpFOncrKjT1hZwxjlFgQ9qvQA==", + "version": "18.19.48", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.48.tgz", + "integrity": "sha512-7WevbG4ekUcRQSZzOwxWgi5dZmTak7FaxXDoW7xVxPBmKx1rTzfmRLkeCgJzcbBnOV2dkhAPc8cCeT6agocpjg==", "dev": true, "license": "MIT", "dependencies": { @@ -1957,9 +1957,9 @@ } }, "node_modules/async": { - "version": "3.2.5", - "resolved": "https://registry.npmjs.org/async/-/async-3.2.5.tgz", - "integrity": "sha512-baNZyqaaLhyLVKm/DlvdW051MSgO6b8eVfIezl9E5PqWxFgzLm/wQntEW4zOytVburDEr0JlALEpdOFwvErLsg==", + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/async/-/async-3.2.6.tgz", + "integrity": "sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA==", "dev": true, "license": "MIT" }, @@ -2315,9 +2315,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001651", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001651.tgz", - "integrity": "sha512-9Cf+Xv1jJNe1xPZLGuUXLNkE1BoDkqRqYyFJ9TDYSqhduqA4hu4oR9HluGoWYQC/aj8WHjsGVV+bwkh0+tegRg==", + "version": "1.0.30001655", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001655.tgz", + "integrity": "sha512-jRGVy3iSGO5Uutn2owlb5gR6qsGngTw9ZTb4ali9f3glshcNmJ2noam4Mo9zia5P9Dk3jNNydy7vQjuE5dQmfg==", "dev": true, "funding": [ { @@ -2449,9 +2449,9 @@ } }, "node_modules/cjs-module-lexer": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/cjs-module-lexer/-/cjs-module-lexer-1.3.1.tgz", - "integrity": "sha512-a3KdPAANPbNE4ZUv9h6LckSl9zLsYOP4MBmhIPkRaeyybt+r4UghLvq+xw/YwUcC1gqylCkL4rdVs3Lwupjm4Q==", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/cjs-module-lexer/-/cjs-module-lexer-1.4.0.tgz", + "integrity": "sha512-N1NGmowPlGBLsOZLPvm48StN04V4YvQRL0i6b7ctrVY3epjP/ct7hFLOItz6pDIvRjwpfPxi52a2UWV2ziir8g==", "dev": true, "license": "MIT" }, @@ -2466,33 +2466,33 @@ } }, "node_modules/cli-cursor": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-4.0.0.tgz", - "integrity": "sha512-VGtlMu3x/4DOtIUwEkRezxUZ2lBacNJCHash0N0WeZDBS+7Ux1dm3XWAgWYxLJFMMdOeXMHXorshEFhbMSGelg==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-5.0.0.tgz", + "integrity": "sha512-aCj4O5wKyszjMmDT4tZj93kxyydN/K5zPWSCe6/0AV/AA1pqe5ZBIw0a2ZfPQV7lL5/yb5HsUreJ6UFAF1tEQw==", "dev": true, "license": "MIT", "dependencies": { - "restore-cursor": "^4.0.0" + "restore-cursor": "^5.0.0" }, "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + "node": ">=18" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/cli-truncate": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/cli-truncate/-/cli-truncate-3.1.0.tgz", - "integrity": "sha512-wfOBkjXteqSnI59oPcJkcPl/ZmwvMMOj340qUIY1SKZCv0B9Cf4D4fAucRkIKQmsIuYK3x1rrgU7MeGRruiuiA==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/cli-truncate/-/cli-truncate-4.0.0.tgz", + "integrity": "sha512-nPdaFdQ0h/GEigbPClz11D0v/ZJEwxmeVZGeMo3Z5StPtUTkA9o1lD6QwoirYiSDzbcwn2XcjwmCp68W1IS4TA==", "dev": true, "license": "MIT", "dependencies": { "slice-ansi": "^5.0.0", - "string-width": "^5.0.0" + "string-width": "^7.0.0" }, "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + "node": ">=18" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" @@ -2609,13 +2609,13 @@ "license": "MIT" }, "node_modules/commander": { - "version": "11.0.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-11.0.0.tgz", - "integrity": "sha512-9HMlXtt/BNoYr8ooyjjNRdIilOTkVJXB+GhxMTtOKwk0R4j4lS4NpjuqmRxroBfnfTSHQIHQB7wryHhXarNjmQ==", + "version": "12.1.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-12.1.0.tgz", + "integrity": "sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA==", "dev": true, "license": "MIT", "engines": { - "node": ">=16" + "node": ">=18" } }, "node_modules/commondir": { @@ -2911,13 +2911,6 @@ "node": ">=6.0.0" } }, - "node_modules/eastasianwidth": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", - "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==", - "dev": true, - "license": "MIT" - }, "node_modules/ejs": { "version": "3.1.10", "resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.10.tgz", @@ -2935,9 +2928,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.5.8", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.8.tgz", - "integrity": "sha512-4Nx0gP2tPNBLTrFxBMHpkQbtn2hidPVr/+/FTtcCiBYTucqc70zRyVZiOLj17Ui3wTO7SQ1/N+hkHYzJjBzt6A==", + "version": "1.5.13", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.13.tgz", + "integrity": "sha512-lbBcvtIJ4J6sS4tb5TLp1b4LyfCdMkwStzXPyAgVgTRAsep4bvrAGaBOP7ZJtQMNJpSQ9SqG4brWOroNaQtm7Q==", "dev": true, "license": "ISC" }, @@ -2955,12 +2948,25 @@ } }, "node_modules/emoji-regex": { - "version": "9.2.2", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", - "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==", + "version": "10.4.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.4.0.tgz", + "integrity": "sha512-EC+0oUMY1Rqm4O6LLrgjtYDvcVYTy7chDnM4Q7030tP4Kwj3u/pR6gP9ygnp2CJMK5Gq+9Q2oqmrFJAz01DXjw==", "dev": true, "license": "MIT" }, + "node_modules/environment": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/environment/-/environment-1.1.0.tgz", + "integrity": "sha512-xUtoPkMggbz0MPyPiIWr1Kp4aeWJjDZ6SMvURhimjdZgsRuDplF5/s9hcgGhyXMhs+6vpnuoiZ2kFiu3FMnS8Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/error-ex": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", @@ -3119,9 +3125,9 @@ "license": "MIT" }, "node_modules/escalade": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.2.tgz", - "integrity": "sha512-ErCHMCae19vR8vQGe50xIsVomy19rg6gFu3+r3jkEO46suLMWBksvVyoGgQV+jOfl84ZSOSlmv6Gxa89PmTGmA==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", + "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==", "dev": true, "license": "MIT", "engines": { @@ -3220,9 +3226,9 @@ } }, "node_modules/eslint-module-utils": { - "version": "2.8.1", - "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.8.1.tgz", - "integrity": "sha512-rXDXR3h7cs7dy9RNpUlQf80nX31XWJEyGq1tRMo+6GsO5VmTe4UTwtmonAD4ZkAsrfMVDA2wlGJ3790Ys+D49Q==", + "version": "2.8.2", + "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.8.2.tgz", + "integrity": "sha512-3XnC5fDyc8M4J2E8pt8pmSVRX2M+5yWMCfI/kDZwauQeFgzQOuhcRBFKjTeJagqgk4sFKxe1mvNVnaWwImx/Tg==", "dev": true, "license": "MIT", "dependencies": { @@ -3931,6 +3937,19 @@ "node": "6.* || 8.* || >= 10.*" } }, + "node_modules/get-east-asian-width": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/get-east-asian-width/-/get-east-asian-width-1.2.0.tgz", + "integrity": "sha512-2nk+7SIVb14QrgXFHcm84tD4bKQz0RxPuMT8Ag5KPOq7J5fEmAg0UbXdTOSHqNuHSU28k55qnceesxXRZGzKWA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/get-func-name": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.2.tgz", @@ -4458,9 +4477,9 @@ } }, "node_modules/is-core-module": { - "version": "2.15.0", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.15.0.tgz", - "integrity": "sha512-Dd+Lb2/zvk9SKy1TGCt1wFJFo/MWBPMX5x7KcvLajWTGuomczdQX61PvY5yK6SVACwpoexWo81IfFyoKY2QnTA==", + "version": "2.15.1", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.15.1.tgz", + "integrity": "sha512-z0vtXSwucUJtANQWldhbtbt7BnL0vxiFjIdDLAatwhDYty2bad6s+rijD6Ri4YuYJubLzIJLUidCh09e1djEVQ==", "dev": true, "license": "MIT", "dependencies": { @@ -5584,13 +5603,16 @@ } }, "node_modules/lilconfig": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/lilconfig/-/lilconfig-2.1.0.tgz", - "integrity": "sha512-utWOt/GHzuUxnLKxB6dk81RoOeoNeHgbrXiuGk4yyF5qlRz+iIVWu56E2fqGHFrXz0QNUhLB/8nKqvRH66JKGQ==", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/lilconfig/-/lilconfig-3.1.2.tgz", + "integrity": "sha512-eop+wDAvpItUys0FWkHIKeC9ybYrTGbU41U5K7+bttZZeohvnY7M9dZ5kB21GNWiFT2q1OoPTvncPCgSOVO5ow==", "dev": true, "license": "MIT", "engines": { - "node": ">=10" + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/antonk52" } }, "node_modules/lines-and-columns": { @@ -5601,28 +5623,28 @@ "license": "MIT" }, "node_modules/lint-staged": { - "version": "13.3.0", - "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-13.3.0.tgz", - "integrity": "sha512-mPRtrYnipYYv1FEE134ufbWpeggNTo+O/UPzngoaKzbzHAthvR55am+8GfHTnqNRQVRRrYQLGW9ZyUoD7DsBHQ==", + "version": "15.2.10", + "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-15.2.10.tgz", + "integrity": "sha512-5dY5t743e1byO19P9I4b3x8HJwalIznL5E1FWYnU6OWw33KxNBSLAc6Cy7F2PsFEO8FKnLwjwm5hx7aMF0jzZg==", "dev": true, "license": "MIT", "dependencies": { - "chalk": "5.3.0", - "commander": "11.0.0", - "debug": "4.3.4", - "execa": "7.2.0", - "lilconfig": "2.1.0", - "listr2": "6.6.1", - "micromatch": "4.0.5", - "pidtree": "0.6.0", - "string-argv": "0.3.2", - "yaml": "2.3.1" + "chalk": "~5.3.0", + "commander": "~12.1.0", + "debug": "~4.3.6", + "execa": "~8.0.1", + "lilconfig": "~3.1.2", + "listr2": "~8.2.4", + "micromatch": "~4.0.8", + "pidtree": "~0.6.0", + "string-argv": "~0.3.2", + "yaml": "~2.5.0" }, "bin": { "lint-staged": "bin/lint-staged.js" }, "engines": { - "node": "^16.14.0 || >=18.0.0" + "node": ">=18.12.0" }, "funding": { "url": "https://opencollective.com/lint-staged" @@ -5641,56 +5663,51 @@ "url": "https://github.com/chalk/chalk?sponsor=1" } }, - "node_modules/lint-staged/node_modules/debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "ms": "2.1.2" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, "node_modules/lint-staged/node_modules/execa": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/execa/-/execa-7.2.0.tgz", - "integrity": "sha512-UduyVP7TLB5IcAQl+OzLyLcS/l32W/GLg+AhHJ+ow40FOk2U3SAllPwR44v4vmdFwIWqpdwxxpQbF1n5ta9seA==", + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/execa/-/execa-8.0.1.tgz", + "integrity": "sha512-VyhnebXciFV2DESc+p6B+y0LjSm0krU4OgJN44qFAhBY0TJ+1V61tYD2+wHusZ6F9n5K+vl8k0sTy7PEfV4qpg==", "dev": true, "license": "MIT", "dependencies": { "cross-spawn": "^7.0.3", - "get-stream": "^6.0.1", - "human-signals": "^4.3.0", + "get-stream": "^8.0.1", + "human-signals": "^5.0.0", "is-stream": "^3.0.0", "merge-stream": "^2.0.0", "npm-run-path": "^5.1.0", "onetime": "^6.0.0", - "signal-exit": "^3.0.7", + "signal-exit": "^4.1.0", "strip-final-newline": "^3.0.0" }, "engines": { - "node": "^14.18.0 || ^16.14.0 || >=18.0.0" + "node": ">=16.17" }, "funding": { "url": "https://github.com/sindresorhus/execa?sponsor=1" } }, + "node_modules/lint-staged/node_modules/get-stream": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-8.0.1.tgz", + "integrity": "sha512-VaUJspBffn/LMCJVoMvSAdmscJyS1auj5Zulnn5UoYcY531UWmdwhRWkcGKnGU93m5HSXP9LP2usOryrBtQowA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/lint-staged/node_modules/human-signals": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-4.3.1.tgz", - "integrity": "sha512-nZXjEF2nbo7lIw3mgYjItAfgQXog3OjJogSbKa2CQIIvSGWcKgeJnQlNXip6NglNzYH45nSRiEVimMvYL8DDqQ==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-5.0.0.tgz", + "integrity": "sha512-AXcZb6vzzrFAUE61HnN4mpLqd/cSIwNQjtNWR0euPm6y0iqx3G4gOXaIDdtdDwZmhwe82LA6+zinmW4UBWVePQ==", "dev": true, "license": "Apache-2.0", "engines": { - "node": ">=14.18.0" + "node": ">=16.17.0" } }, "node_modules/lint-staged/node_modules/is-stream": { @@ -5706,20 +5723,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/lint-staged/node_modules/micromatch": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", - "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", - "dev": true, - "license": "MIT", - "dependencies": { - "braces": "^3.0.2", - "picomatch": "^2.3.1" - }, - "engines": { - "node": ">=8.6" - } - }, "node_modules/lint-staged/node_modules/mimic-fn": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-4.0.0.tgz", @@ -5778,6 +5781,19 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/lint-staged/node_modules/signal-exit": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", + "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/lint-staged/node_modules/strip-final-newline": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-3.0.0.tgz", @@ -5792,29 +5808,21 @@ } }, "node_modules/listr2": { - "version": "6.6.1", - "resolved": "https://registry.npmjs.org/listr2/-/listr2-6.6.1.tgz", - "integrity": "sha512-+rAXGHh0fkEWdXBmX+L6mmfmXmXvDGEKzkjxO+8mP3+nI/r/CWznVBvsibXdxda9Zz0OW2e2ikphN3OwCT/jSg==", + "version": "8.2.4", + "resolved": "https://registry.npmjs.org/listr2/-/listr2-8.2.4.tgz", + "integrity": "sha512-opevsywziHd3zHCVQGAj8zu+Z3yHNkkoYhWIGnq54RrCVwLz0MozotJEDnKsIBLvkfLGN6BLOyAeRrYI0pKA4g==", "dev": true, "license": "MIT", "dependencies": { - "cli-truncate": "^3.1.0", + "cli-truncate": "^4.0.0", "colorette": "^2.0.20", "eventemitter3": "^5.0.1", - "log-update": "^5.0.1", - "rfdc": "^1.3.0", - "wrap-ansi": "^8.1.0" + "log-update": "^6.1.0", + "rfdc": "^1.4.1", + "wrap-ansi": "^9.0.0" }, "engines": { - "node": ">=16.0.0" - }, - "peerDependencies": { - "enquirer": ">= 2.3.0 < 3" - }, - "peerDependenciesMeta": { - "enquirer": { - "optional": true - } + "node": ">=18.0.0" } }, "node_modules/locate-path": { @@ -5872,36 +5880,36 @@ } }, "node_modules/log-update": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/log-update/-/log-update-5.0.1.tgz", - "integrity": "sha512-5UtUDQ/6edw4ofyljDNcOVJQ4c7OjDro4h3y8e1GQL5iYElYclVHJ3zeWchylvMaKnDbDilC8irOVyexnA/Slw==", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/log-update/-/log-update-6.1.0.tgz", + "integrity": "sha512-9ie8ItPR6tjY5uYJh8K/Zrv/RMZ5VOlOWvtZdEHYSTFKZfIBPQa9tOAEeAWhd+AnIneLJ22w5fjOYtoutpWq5w==", "dev": true, "license": "MIT", "dependencies": { - "ansi-escapes": "^5.0.0", - "cli-cursor": "^4.0.0", - "slice-ansi": "^5.0.0", - "strip-ansi": "^7.0.1", - "wrap-ansi": "^8.0.1" + "ansi-escapes": "^7.0.0", + "cli-cursor": "^5.0.0", + "slice-ansi": "^7.1.0", + "strip-ansi": "^7.1.0", + "wrap-ansi": "^9.0.0" }, "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + "node": ">=18" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/log-update/node_modules/ansi-escapes": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-5.0.0.tgz", - "integrity": "sha512-5GFMVX8HqE/TB+FuBJGuO5XG0WrsA6ptUqoODaT/n9mmUaZFkqnBueB4leqGBCmrUHnCnC4PCZTCd0E7QQ83bA==", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-7.0.0.tgz", + "integrity": "sha512-GdYO7a61mR0fOlAsvC9/rIHf7L96sBc6dEWzeOu+KAea5bZyQRPIpojrVoI4AXGJS/ycu/fBTdLrUkA4ODrvjw==", "dev": true, "license": "MIT", "dependencies": { - "type-fest": "^1.0.2" + "environment": "^1.0.0" }, "engines": { - "node": ">=12" + "node": ">=18" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" @@ -5920,33 +5928,66 @@ "url": "https://github.com/chalk/ansi-regex?sponsor=1" } }, - "node_modules/log-update/node_modules/strip-ansi": { + "node_modules/log-update/node_modules/ansi-styles": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz", + "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/log-update/node_modules/is-fullwidth-code-point": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-5.0.0.tgz", + "integrity": "sha512-OVa3u9kkBbw7b8Xw5F9P+D/T9X+Z4+JruYVNapTjPYZYUznQ5YfWeFkOj606XYYW8yugTfC8Pj0hYqvi4ryAhA==", + "dev": true, + "license": "MIT", + "dependencies": { + "get-east-asian-width": "^1.0.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/log-update/node_modules/slice-ansi": { "version": "7.1.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", - "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", + "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-7.1.0.tgz", + "integrity": "sha512-bSiSngZ/jWeX93BqeIAbImyTbEihizcwNjFoRUIY/T1wWQsfsm2Vw1agPKylXvQTU7iASGdHhyqRlqQzfz+Htg==", "dev": true, "license": "MIT", "dependencies": { - "ansi-regex": "^6.0.1" + "ansi-styles": "^6.2.1", + "is-fullwidth-code-point": "^5.0.0" }, "engines": { - "node": ">=12" + "node": ">=18" }, "funding": { - "url": "https://github.com/chalk/strip-ansi?sponsor=1" + "url": "https://github.com/chalk/slice-ansi?sponsor=1" } }, - "node_modules/log-update/node_modules/type-fest": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-1.4.0.tgz", - "integrity": "sha512-yGSza74xk0UG8k+pLh5oeoYirvIiWo5t0/o3zHHAO2tRDiZcxWP7fywNlXhqb6/r6sWvwi+RsyQMWhVLe4BVuA==", + "node_modules/log-update/node_modules/strip-ansi": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", + "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", "dev": true, - "license": "(MIT OR CC0-1.0)", + "license": "MIT", + "dependencies": { + "ansi-regex": "^6.0.1" + }, "engines": { - "node": ">=10" + "node": ">=12" }, "funding": { - "url": "https://github.com/sponsors/sindresorhus" + "url": "https://github.com/chalk/strip-ansi?sponsor=1" } }, "node_modules/loupe": { @@ -6020,9 +6061,9 @@ } }, "node_modules/micromatch": { - "version": "4.0.7", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.7.tgz", - "integrity": "sha512-LPP/3KorzCwBxfeUuZmaR6bG2kdeHSbe0P2tY3FLRU4vYrjYz5hI4QZwV0njUx3jeuKe67YukQ1LSPZBKDqO/Q==", + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", + "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", "dev": true, "license": "MIT", "dependencies": { @@ -6043,6 +6084,19 @@ "node": ">=6" } }, + "node_modules/mimic-function": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/mimic-function/-/mimic-function-5.0.1.tgz", + "integrity": "sha512-VP79XUPxV2CigYP3jWwAUFSku2aKqBH7uTAapFWCBqutsbmDo96KY5o8uh6U+/YSIn5OxJnXp73beVkpqMIGhA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/minimatch": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", @@ -7272,22 +7326,51 @@ } }, "node_modules/restore-cursor": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-4.0.0.tgz", - "integrity": "sha512-I9fPXU9geO9bHOt9pHHOhOkYerIMsmVaWB0rA2AI9ERh/+x/i7MV5HKBNrg+ljO5eoPVgCcnFuRjJ9uH6I/3eg==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-5.1.0.tgz", + "integrity": "sha512-oMA2dcrw6u0YfxJQXm342bFKX/E4sG9rbTzO9ptUcR/e8A33cHuvStiYOwH7fszkZlZ1z/ta9AAoPk2F4qIOHA==", "dev": true, "license": "MIT", "dependencies": { - "onetime": "^5.1.0", - "signal-exit": "^3.0.2" + "onetime": "^7.0.0", + "signal-exit": "^4.1.0" }, "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + "node": ">=18" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/restore-cursor/node_modules/onetime": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-7.0.0.tgz", + "integrity": "sha512-VXJjc87FScF88uafS3JllDgvAm+c/Slfz06lorj2uAY34rlUu0Nt+v8wreiImcrgAjjIHp1rXpTDlLOGw29WwQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "mimic-function": "^5.0.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/restore-cursor/node_modules/signal-exit": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", + "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/reusify": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", @@ -7685,18 +7768,18 @@ } }, "node_modules/string-width": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", - "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz", + "integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==", "dev": true, "license": "MIT", "dependencies": { - "eastasianwidth": "^0.2.0", - "emoji-regex": "^9.2.2", - "strip-ansi": "^7.0.1" + "emoji-regex": "^10.3.0", + "get-east-asian-width": "^1.0.0", + "strip-ansi": "^7.1.0" }, "engines": { - "node": ">=12" + "node": ">=18" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" @@ -7908,21 +7991,21 @@ } }, "node_modules/ts-jest": { - "version": "29.2.4", - "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.2.4.tgz", - "integrity": "sha512-3d6tgDyhCI29HlpwIq87sNuI+3Q6GLTTCeYRHCs7vDz+/3GCMwEtV9jezLyl4ZtnBgx00I7hm8PCP8cTksMGrw==", + "version": "29.2.5", + "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.2.5.tgz", + "integrity": "sha512-KD8zB2aAZrcKIdGk4OwpJggeLcH1FgrICqDSROWqlnJXGCXK4Mn6FcdK2B6670Xr73lHMG1kHw8R87A0ecZ+vA==", "dev": true, "license": "MIT", "dependencies": { - "bs-logger": "0.x", + "bs-logger": "^0.2.6", "ejs": "^3.1.10", - "fast-json-stable-stringify": "2.x", + "fast-json-stable-stringify": "^2.1.0", "jest-util": "^29.0.0", "json5": "^2.2.3", - "lodash.memoize": "4.x", - "make-error": "1.x", - "semver": "^7.5.3", - "yargs-parser": "^21.0.1" + "lodash.memoize": "^4.1.2", + "make-error": "^1.3.6", + "semver": "^7.6.3", + "yargs-parser": "^21.1.1" }, "bin": { "ts-jest": "cli.js" @@ -8339,18 +8422,18 @@ "license": "Apache-2.0" }, "node_modules/wrap-ansi": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", - "integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==", + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-9.0.0.tgz", + "integrity": "sha512-G8ura3S+3Z2G+mkgNRq8dqaFZAuxfsxpBB8OCTGRTCtp+l/v9nbFNmCUP1BZMts3G1142MsZfn6eeUKrr4PD1Q==", "dev": true, "license": "MIT", "dependencies": { - "ansi-styles": "^6.1.0", - "string-width": "^5.0.1", - "strip-ansi": "^7.0.1" + "ansi-styles": "^6.2.1", + "string-width": "^7.0.0", + "strip-ansi": "^7.1.0" }, "engines": { - "node": ">=12" + "node": ">=18" }, "funding": { "url": "https://github.com/chalk/wrap-ansi?sponsor=1" @@ -8437,11 +8520,14 @@ "license": "ISC" }, "node_modules/yaml": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.3.1.tgz", - "integrity": "sha512-2eHWfjaoXgTBC2jNM1LRef62VQa0umtvRiDSk6HSzW7RvS5YtkabJrwYLLEKWBc8a5U2PTSCs+dJjUTJdlHsWQ==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.5.0.tgz", + "integrity": "sha512-2wWLbGbYDiSqqIKoPjar3MPgB94ErzCtrNE1FdqGuaO0pi2JGjmE8aW8TDZwzU7vuxcGRdL/4gPQwQ7hD5AMSw==", "dev": true, "license": "ISC", + "bin": { + "yaml": "bin.mjs" + }, "engines": { "node": ">= 14" } diff --git a/package.json b/package.json index 5c8a6ad..d110016 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mnemonica", - "version": "0.9.984", + "version": "0.9.985", "description": "abstract technique that aids information retention : instance inheritance system", "type": "commonjs", "main": "./build/index.js", @@ -33,6 +33,7 @@ "example": "npm run build && node ./test/example.js", "example:ts": "npx tsc ./test-ts/*.ts && npx eslint --fix ./test-ts/*.js && node ./test-ts/test-no-types.js && node ./test-ts/test-with-types.js", "lint": "npx eslint --fix", + "lint:src": "npx eslint --fix ./src", "lint:test": "npx eslint --fix ./test", "test": "npm run build && mocha --allow-uncaught test/index.js", "test:cov": "npm run build && nyc --reporter=lcov mocha --allow-uncaught --ui bdd --reporter spec ./test/index.js", @@ -64,7 +65,7 @@ "homepage": "https://github.com/wentout/mnemonica#readme", "devDependencies": { "@types/jest": "^29.5.12", - "@types/node": "^18.19.44", + "@types/node": "^18.19.48", "@typescript-eslint/eslint-plugin": "^5.62.0", "@typescript-eslint/parser": "^5.62.0", "chai": "^4.5.0", @@ -75,11 +76,11 @@ "husky": "^8.0.3", "jest": "^29.7.0", "json5": "^2.2.3", - "lint-staged": "^13.3.0", + "lint-staged": "^15.2.10", "mocha": "^10.7.3", "mocha-lcov-reporter": "^1.3.0", "nyc": "^15.1.0", - "ts-jest": "^29.2.4", + "ts-jest": "^29.2.5", "typescript": "^5.5.4" }, "engines": { diff --git a/src/api/types/InstanceCreator.ts b/src/api/types/InstanceCreator.ts index 67820b0..3d5e083 100644 --- a/src/api/types/InstanceCreator.ts +++ b/src/api/types/InstanceCreator.ts @@ -92,11 +92,11 @@ const invokePostHooks = function ( this: any ) { return { - type : type.invokeHook( hookType, hookData ), + type: type.invokeHook( hookType, hookData ), - collection : collection.invokeHook( hookType, hookData ), + collection: collection.invokeHook( hookType, hookData ), - namespace : namespace.invokeHook( hookType, hookData ) + namespace: namespace.invokeHook( hookType, hookData ) }; @@ -113,13 +113,13 @@ const bindMethod = function ( this: any, instance: any, methodName: string, Meth // || instance; const applyTo = this !== undefined ? this : from; const exceptionReason = { - method : MethodItself, + method: MethodItself, methodName, - this : this, + this: this, from, instance, applyTo, - asNew : false, + asNew: false, args, }; @@ -135,8 +135,8 @@ const bindMethod = function ( this: any, instance: any, methodName: string, Meth if ( answer instanceof Promise ) { answer = answer.catch( ( error ) => { odp( exceptionReason, 'error', { - value : error, - enumerable : true + value: error, + enumerable: true } ); throw bindedMethodErrorHandler( exceptionReason ); } ); @@ -145,20 +145,20 @@ const bindMethod = function ( this: any, instance: any, methodName: string, Meth return answer; } catch ( error ) { odp( exceptionReason, 'error', { - value : error, - enumerable : true + value: error, + enumerable: true } ); throw bindedMethodErrorHandler( exceptionReason ); } }; }, - enumerable : true + enumerable: true } ); }; const bindProtoMethods = function ( this: any ) { -// eslint-disable-next-line @typescript-eslint/no-this-alias + // eslint-disable-next-line @typescript-eslint/no-this-alias const self = this; const { inheritedInstance, @@ -402,7 +402,9 @@ export const InstanceCreator = function ( this: any, type: any, existentInstance try { - self.inheritedInstance = new self.InstanceModificator( ...args ); + const answer = new self.InstanceModificator( ...args ); + // debugger; + self.inheritedInstance = answer; } catch ( error ) { @@ -412,7 +414,9 @@ export const InstanceCreator = function ( this: any, type: any, existentInstance } else { - self.inheritedInstance = new self.InstanceModificator( ...args ); + const answer = new self.InstanceModificator( ...args ); + // debugger; + self.inheritedInstance = answer; } diff --git a/src/api/types/TypeProxy.ts b/src/api/types/TypeProxy.ts index 6216b69..b7150f3 100644 --- a/src/api/types/TypeProxy.ts +++ b/src/api/types/TypeProxy.ts @@ -32,16 +32,16 @@ const { import { InstanceCreator } from './InstanceCreator'; -export const TypeProxy = function (__type__: any, Uranus: any) { - Object.assign(this, { +export const TypeProxy = function ( __type__: any, Uranus: any ) { + Object.assign( this, { __type__, Uranus - }); - const typeProxy = new Proxy(InstanceCreator, this); + } ); + const typeProxy = new Proxy( InstanceCreator, this ); return typeProxy; } as ConstructorFunction; -TypeProxy.prototype.get = function (target: any, prop: string) { +TypeProxy.prototype.get = function ( target: any, prop: string ) { const { __type__: type @@ -50,113 +50,113 @@ TypeProxy.prototype.get = function (target: any, prop: string) { // prototype of proxy // const instance = Reflect.getPrototypeOf(receiver); - if (prop === 'prototype') { + if ( prop === 'prototype' ) { return type.proto; } const propDeclaration = type[ prop ]; - if (propDeclaration) { + if ( propDeclaration ) { return propDeclaration; } // used for existent props with value // undefined || null || false - if (hop(type, prop)) { + if ( hop( type, prop ) ) { return propDeclaration; } // SomeType.SomeSubType - if (type.subtypes.has(prop)) { - return type.subtypes.get(prop); + if ( type.subtypes.has( prop ) ) { + return type.subtypes.get( prop ); } - return Reflect.get(target, prop); + return Reflect.get( target, prop ); }; -TypeProxy.prototype.set = function (__: any, name: string, value: any) { +TypeProxy.prototype.set = function ( __: any, name: string, value: any ) { const { __type__: type } = this; // is about setting a prototype to Type - if (name === 'prototype') { - checkProto(value); + if ( name === 'prototype' ) { + checkProto( value ); type.proto = value; return true; } - if (typeof name !== 'string' || !name.length) { - throw new WRONG_TYPE_DEFINITION('should use non empty string as TypeName'); + if ( typeof name !== 'string' || !name.length ) { + throw new WRONG_TYPE_DEFINITION( 'should use non empty string as TypeName' ); } - if (typeof value !== 'function') { - throw new WRONG_TYPE_DEFINITION('should use function for type definition'); + if ( typeof value !== 'function' ) { + throw new WRONG_TYPE_DEFINITION( 'should use function for type definition' ); } const TypeName = name; const Constructor = value; - type.define(TypeName, Constructor); + type.define( TypeName, Constructor ); return true; }; -TypeProxy.prototype.apply = function (__: any, Uranus: any, args: any[]) { +TypeProxy.prototype.apply = function ( __: any, Uranus: any, args: any[] ) { const type = this.__type__; let instance = null; - if (Uranus) { - const InstanceCreatorProxy = new TypeProxy(type, Uranus); - instance = new InstanceCreatorProxy(...args); + if ( Uranus ) { + const InstanceCreatorProxy = new TypeProxy( type, Uranus ); + instance = new InstanceCreatorProxy( ...args ); } else { - instance = this.construct(null, args); + instance = this.construct( null, args ); } return instance; }; // tslint:disable-next-line: only-arrow-functions -const makeSubTypeProxy = function (subtype: any, inheritedInstance: any) { +const makeSubTypeProxy = function ( subtype: any, inheritedInstance: any ) { - const subtypeProxy = new Proxy(InstanceCreator, { + const subtypeProxy = new Proxy( InstanceCreator, { - get (Target, _prop) { + get ( Target, _prop ) { - if (_prop === Symbol.hasInstance) { - return getTypeChecker(subtype.TypeName); + if ( _prop === Symbol.hasInstance ) { + return getTypeChecker( subtype.TypeName ); } - return Reflect.get(Target, _prop); + return Reflect.get( Target, _prop ); }, - construct (Target, _args) { - return new Target(subtype, inheritedInstance, _args); + construct ( Target, _args ) { + return new Target( subtype, inheritedInstance, _args ); }, - apply (Target, thisArg = inheritedInstance, _args) { + apply ( Target, thisArg = inheritedInstance, _args ) { // if we would make new keyword obligatory // then we should avoid it here, with throw Error - let existentInstance = reflectPrimitiveWrappers(thisArg); + let existentInstance = reflectPrimitiveWrappers( thisArg ); // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore - if (!existentInstance[ SymbolGaia ]) { - const gaia = new Mnemosyne(subtype.namespace, new Gaia(existentInstance)); - existentInstance = new Proxy(gaia, { - get : gaiaProxyHandlerGet - }); + if ( !existentInstance[ SymbolGaia ] ) { + const gaia = new Mnemosyne( subtype.namespace, new Gaia( existentInstance ) ); + existentInstance = new Proxy( gaia, { + get: gaiaProxyHandlerGet + } ); } - const entity = new Target(subtype, existentInstance, _args); + const entity = new Target( subtype, existentInstance, _args ); return entity; }, - }); + } ); return subtypeProxy; }; @@ -181,7 +181,7 @@ const MnemonicaInstanceProps = [ '__creator__' -].concat(MnemosynePrototypeKeys); +].concat( MnemosynePrototypeKeys ); const staticProps = [ @@ -205,15 +205,15 @@ const staticProps = [ 'showDiff', ] - .concat(MnemonicaInstanceProps) - .concat(Object.getOwnPropertyNames(Object.prototype)) - .concat(Object.getOwnPropertyNames(Function.prototype)) - .reduce((obj, key) => { + .concat( MnemonicaInstanceProps ) + .concat( Object.getOwnPropertyNames( Object.prototype ) ) + .concat( Object.getOwnPropertyNames( Function.prototype ) ) + .reduce( ( obj, key ) => { obj[ key ] = true; return obj; - }, Object.create(null)); + }, Object.create( null ) ); -const gaiaProxyHandlerGet = (target: any, prop: string, receiver: any) => { +const gaiaProxyHandlerGet = ( target: any, prop: string, receiver: any ) => { // Node.js 22 Reflect.get Behaviour Changed here // cause something gone wrong with prop assignment @@ -221,17 +221,17 @@ const gaiaProxyHandlerGet = (target: any, prop: string, receiver: any) => { // nave not yet checked other staticProps, // just fixed this below // while using conditional for staticProps - const result = Reflect.get(target, prop, receiver); + const result = Reflect.get( target, prop, receiver ); - if (result !== undefined) { + if ( result !== undefined ) { return result; } - if (typeof prop === 'symbol') { + if ( typeof prop === 'symbol' ) { return result; } - if (staticProps[ prop ]) { + if ( staticProps[ prop ] ) { /* const mayBeResult = Reflect.get(target, prop); if (mayBeResult !== undefined) { @@ -242,7 +242,7 @@ const gaiaProxyHandlerGet = (target: any, prop: string, receiver: any) => { } // prototype of proxy - const instance: any = Reflect.getPrototypeOf(receiver); + const instance: any = Reflect.getPrototypeOf( receiver ); const { __type__: { @@ -253,16 +253,16 @@ const gaiaProxyHandlerGet = (target: any, prop: string, receiver: any) => { }, } = instance; - const subtype = subtypes.has(prop) ? - subtypes.get(prop) : + const subtype = subtypes.has( prop ) ? + subtypes.get( prop ) : strictChain ? undefined : - findParentSubType(instance, prop); + findParentSubType( instance, prop ); - return subtype ? makeSubTypeProxy(subtype, receiver) : result; + return subtype ? makeSubTypeProxy( subtype, receiver ) : result; }; -TypeProxy.prototype.construct = function (__: any, args: any[]) { +TypeProxy.prototype.construct = function ( __: any, args: any[] ) { // new.target id equal with target here @@ -273,13 +273,20 @@ TypeProxy.prototype.construct = function (__: any, args: any[]) { // constructs new Gaia -> new Mnemosyne // 2 build the first instance in chain - const uranus = reflectPrimitiveWrappers(Uranus); - const gaia = new Mnemosyne(type.namespace, new Gaia(uranus)); - const gaiaProxy = new Proxy(gaia, { - get : gaiaProxyHandlerGet - }); - - const instance = new InstanceCreator(type, gaiaProxy, args); + const uranus = reflectPrimitiveWrappers( Uranus ); + const gaia = new Mnemosyne( type.namespace, new Gaia( uranus ) ); + const gaiaProxy = new Proxy( gaia, { + get: gaiaProxyHandlerGet + } ); + + if ( args[ 0 ] === 'NullishReturn' ) { + debugger; + } + const instance = new InstanceCreator( type, gaiaProxy, args ); + if ( args[ 0 ] === 'NullishReturn' ) { + instance; + debugger; + } return instance; diff --git a/src/api/types/compileNewModificatorFunctionBody.ts b/src/api/types/compileNewModificatorFunctionBody.ts index 4fb8925..c385ce9 100644 --- a/src/api/types/compileNewModificatorFunctionBody.ts +++ b/src/api/types/compileNewModificatorFunctionBody.ts @@ -34,7 +34,7 @@ const getClassConstructor = ( ConstructHandler: any, CreationHandler: any, ) => { return class extends ConstructHandler { - constructor ( ...args: any[] ) { + constructor( ...args: any[] ) { const answer = super( ...args ); // debugger; return CreationHandler.call( this, answer ); @@ -43,9 +43,22 @@ const getClassConstructor = ( ConstructHandler: any, CreationHandler: any, ) => }; const getFunctionConstructor = ( ConstructHandler: any, CreationHandler: any, ) => { + const newable = Object.hasOwnProperty.call( ConstructHandler, 'prototype' ); + // const hasReturnStatement = ConstructHandler.toString().indexOf('return') > -1; return function ( this: any, ...args: any[] ) { - const answer = ConstructHandler.call( this, ...args ); - // debugger; + let answer; + // if (!new.target) { + // debugger; + // } + // if (hasReturnStatement || !newable) { + if ( !newable ) { + answer = ConstructHandler.call( this, ...args ); + } else { + const _proto = ConstructHandler.prototype; + ConstructHandler.prototype = this.constructor.prototype; + answer = new ConstructHandler( ...args ); + ConstructHandler.prototype = _proto; + } return CreationHandler.call( this, answer ); }; }; @@ -57,12 +70,15 @@ const compileNewModificatorFunctionBody = function ( FunctionName: string, asCla if ( asClass ) { ModificationBody = getClassConstructor( ConstructHandler, CreationHandler ); } else { + // const ReNamedConstructHandler = {} as any; + // ReNamedConstructHandler[FunctionName] = ConstructHandler; + // ModificationBody = getFunctionConstructor(ReNamedConstructHandler[FunctionName], CreationHandler); ModificationBody = getFunctionConstructor( ConstructHandler, CreationHandler ); } ModificationBody.prototype.constructor = ModificationBody; Object.defineProperty( ModificationBody.prototype.constructor, 'name', { - value : FunctionName, - writable : false + value: FunctionName, + writable: false } ); Object.defineProperty( ModificationBody, SymbolConstructorName, { get () { diff --git a/test/AsyncNewTest.js b/test/AsyncNewTest.js new file mode 100644 index 0000000..f075149 --- /dev/null +++ b/test/AsyncNewTest.js @@ -0,0 +1,12 @@ +'use strict'; + +const sss = async function () { + this.m = 1; +}; + +console.log(Object.hasOwnProperty.call(sss, 'prototype')); +try { + new sss; +} catch (error) { + console.error(error); +} diff --git a/test/environment.js b/test/environment.js index 05bb24d..6100c1d 100644 --- a/test/environment.js +++ b/test/environment.js @@ -1,10 +1,10 @@ 'use strict'; -const { assert, expect } = require('chai'); +const { assert, expect } = require( 'chai' ); -const mnemonica = require('..'); +const mnemonica = require( '..' ); -const hop = (o, p) => Object.prototype.hasOwnProperty.call(o, p); +const hop = ( o, p ) => Object.prototype.hasOwnProperty.call( o, p ); const { define, @@ -33,10 +33,10 @@ const { defineStackCleaner } = mnemonica; -const dirname = require('path').resolve(__dirname, '../build'); -const stackCleanerRegExp = new RegExp(dirname); +const dirname = require( 'path' ).resolve( __dirname, '../build' ); +const stackCleanerRegExp = new RegExp( dirname ); -const tests = (opts) => { +const tests = ( opts ) => { const { user, @@ -71,9 +71,30 @@ const tests = (opts) => { merged } = opts; - describe('Check Environment', () => { + describe( 'Check Environment', () => { - describe('interface test', () => { + describe( 'constructors may give any answer', () => { + + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/new + /* + If the constructor function returns a non-primitive, + this return value becomes the result of the whole new expression. + Otherwise, if the constructor function doesn't return anything or returns a primitive, + newInstance is returned instead. + (Normally constructors don't return a value, but they can choose + to do so to override the normal object creation process.) + */ + const NullishReturn = define( 'NullishReturn', () => { + debugger; + return null; + } ); + + const nullR = new NullishReturn( 'NullishReturn' ); + + expect( nullR ).instanceOf( Object ); + + } ); + describe( 'interface test', () => { const interface_keys = [ 'SymbolSubtypeCollection', @@ -109,46 +130,46 @@ const tests = (opts) => { ]; - const mnemonica_keys = Object.keys(mnemonica); + const mnemonica_keys = Object.keys( mnemonica ); - it('interface length', () => { - expect(mnemonica_keys.length).equal(interface_keys.length); - }); + it( 'interface length', () => { + expect( mnemonica_keys.length ).equal( interface_keys.length ); + } ); - it('interface keys', () => { - const missingKeys = interface_keys.filter(key => { - return !mnemonica_keys.includes(key); - }); - expect(missingKeys.length).equal(0); - }); + it( 'interface keys', () => { + const missingKeys = interface_keys.filter( key => { + return !mnemonica_keys.includes( key ); + } ); + expect( missingKeys.length ).equal( 0 ); + } ); - it('mnemonica keys', () => { - const missingKeys = mnemonica_keys.filter(key => { - return !interface_keys.includes(key); - }); - expect(missingKeys.length).equal(0); - }); + it( 'mnemonica keys', () => { + const missingKeys = mnemonica_keys.filter( key => { + return !interface_keys.includes( key ); + } ); + expect( missingKeys.length ).equal( 0 ); + } ); - }); + } ); - describe('named constructor define', async () => { + describe( 'named constructor define', async () => { - const NamedFunction = UserType.define(async function NamedFunction () { + const NamedFunction = UserType.define( async function NamedFunction () { this.type = 'function'; return this; }, { getTypeValue () { return this.type; } - }); + } ); - it('named function definition exist', () => { - expect(user.__subtypes__.has('NamedFunction')).is.true; - }); + it( 'named function definition exist', () => { + expect( user.__subtypes__.has( 'NamedFunction' ) ).is.true; + } ); - const NamedClassPtr = UserType.define(() => { + const NamedClassPtr = UserType.define( () => { return class NamedClass { - constructor (snc) { + constructor ( snc ) { this.type = 'class'; this.snc = snc; } @@ -157,11 +178,11 @@ const tests = (opts) => { return this.type; } }; - }); + } ); - UserType.define(function () { + UserType.define( function () { return class NamedClass2 { - constructor (snc) { + constructor ( snc ) { this.type = 'class'; this.snc = snc; } @@ -170,442 +191,442 @@ const tests = (opts) => { return this.type; } }; - }); + } ); - const SubNamedClassPtr = NamedClassPtr.define(() => { + const SubNamedClassPtr = NamedClassPtr.define( () => { return class SubNamedClass { constructor () { this.type = 'subclass'; } }; - }); + } ); - it('named class definition exist', () => { - expect(user.__subtypes__.has('NamedClass')).is.true; - }); + it( 'named class definition exist', () => { + expect( user.__subtypes__.has( 'NamedClass' ) ).is.true; + } ); const nf = await new user.NamedFunction(); - it('instance made through named function instanceof & props', () => { - expect(nf).instanceOf(NamedFunction); - }); - it('instance made with named function props', () => { - expect(nf.type).is.equal('function'); - }); - it('instance made with named function prototype methods', () => { - expect(nf.getTypeValue()).is.equal('function'); - }); - - const nc = new user.NamedClass(1); - - it('instance made through named class instanceof', () => { - expect(nc).instanceOf(NamedClassPtr); - }); - it('instance made with named class props', () => { - expect(nc.type).is.equal('class'); - }); - it('instance made with named class prototype methods', () => { - expect(nc.getTypeValue()).is.equal('class'); - }); + it( 'instance made through named function instanceof & props', () => { + expect( nf ).instanceOf( NamedFunction ); + } ); + it( 'instance made with named function props', () => { + expect( nf.type ).is.equal( 'function' ); + } ); + it( 'instance made with named function prototype methods', () => { + expect( nf.getTypeValue() ).is.equal( 'function' ); + } ); + + const nc = new user.NamedClass( 1 ); + + it( 'instance made through named class instanceof', () => { + expect( nc ).instanceOf( NamedClassPtr ); + } ); + it( 'instance made with named class props', () => { + expect( nc.type ).is.equal( 'class' ); + } ); + it( 'instance made with named class prototype methods', () => { + expect( nc.getTypeValue() ).is.equal( 'class' ); + } ); try { var snc1 = new nc.SubNamedClass(); - var snc2 = new user.NamedClass(2).SubNamedClass(); - } catch (err) { - console.error(err); + var snc2 = new user.NamedClass( 2 ).SubNamedClass(); + } catch ( err ) { + console.error( err ); } - it('instance made through sub-named class instanceof', () => { - expect(snc1).instanceOf(NamedClassPtr); - expect(snc1).instanceOf(SubNamedClassPtr); - expect(snc2).instanceOf(NamedClassPtr); - expect(snc2).instanceOf(SubNamedClassPtr); - }); + it( 'instance made through sub-named class instanceof', () => { + expect( snc1 ).instanceOf( NamedClassPtr ); + expect( snc1 ).instanceOf( SubNamedClassPtr ); + expect( snc2 ).instanceOf( NamedClassPtr ); + expect( snc2 ).instanceOf( SubNamedClassPtr ); + } ); - it('sub instance made with named class prototype methods', () => { - expect(snc1.getTypeValue()).is.equal('subclass'); - expect(snc2.getTypeValue()).is.equal('subclass'); - }); + it( 'sub instance made with named class prototype methods', () => { + expect( snc1.getTypeValue() ).is.equal( 'subclass' ); + expect( snc2.getTypeValue() ).is.equal( 'subclass' ); + } ); - it('instance made with sub-named class props', () => { + it( 'instance made with sub-named class props', () => { - expect(snc1.type).is.equal('subclass'); + expect( snc1.type ).is.equal( 'subclass' ); const extracted1 = snc1.extract(); - expect(extracted1.email).is.equal('went.out@gmail.com'); - expect(extracted1.snc).is.equal(1); - const parsed1 = parse(snc1); - expect(parsed1.props.type).is.equal('subclass'); - expect(parsed1.name).is.equal('SubNamedClass'); + expect( extracted1.email ).is.equal( 'went.out@gmail.com' ); + expect( extracted1.snc ).is.equal( 1 ); + const parsed1 = parse( snc1 ); + expect( parsed1.props.type ).is.equal( 'subclass' ); + expect( parsed1.name ).is.equal( 'SubNamedClass' ); - expect(snc2.type).is.equal('subclass'); + expect( snc2.type ).is.equal( 'subclass' ); const extracted2 = snc2.extract(); - expect(extracted2.email).is.equal('went.out@gmail.com'); - expect(extracted2.snc).is.equal(2); - const parsed2 = parse(snc2); - expect(parsed2.props.type).is.equal('subclass'); - expect(parsed2.name).is.equal('SubNamedClass'); + expect( extracted2.email ).is.equal( 'went.out@gmail.com' ); + expect( extracted2.snc ).is.equal( 2 ); + const parsed2 = parse( snc2 ); + expect( parsed2.props.type ).is.equal( 'subclass' ); + expect( parsed2.name ).is.equal( 'SubNamedClass' ); - }); + } ); - }); + } ); - describe('error defineStackCleaner test ', () => { + describe( 'error defineStackCleaner test ', () => { let madeError = null; try { - defineStackCleaner(null); - } catch (error) { + defineStackCleaner( null ); + } catch ( error ) { madeError = error; } - it('defineStackCleaner wrong definition should be instancof error', () => { - expect(madeError).instanceOf(Error); - }); - - it('defineStackCleaner wrong definition should be instancof error', () => { - expect(madeError).instanceOf(errors.BASE_MNEMONICA_ERROR); - expect(madeError).instanceOf(errors.WRONG_STACK_CLEANER); - }); - }); - - describe('core env tests', () => { - - it('Symbol Gaia', () => { - expect(userTC[ SymbolGaia ][ MNEMONICA ] === GAIA).is.true; - }); - it('.SubTypes definition is correct Regular', () => { - expect(hop(userTC, 'WithoutPassword')).is.false; - }); - it('.SubTypes definition is correct Regular FirstChild', () => { + it( 'defineStackCleaner wrong definition should be instancof error', () => { + expect( madeError ).instanceOf( Error ); + } ); + + it( 'defineStackCleaner wrong definition should be instancof error', () => { + expect( madeError ).instanceOf( errors.BASE_MNEMONICA_ERROR ); + expect( madeError ).instanceOf( errors.WRONG_STACK_CLEANER ); + } ); + } ); + + describe( 'core env tests', () => { + + it( 'Symbol Gaia', () => { + expect( userTC[ SymbolGaia ][ MNEMONICA ] === GAIA ).is.true; + } ); + it( '.SubTypes definition is correct Regular', () => { + expect( hop( userTC, 'WithoutPassword' ) ).is.false; + } ); + it( '.SubTypes definition is correct Regular FirstChild', () => { // 0.8.4 -- changed interface, no more methods inside of prototype chain // expect(Object.getPrototypeOf(Object.getPrototypeOf(userTC)).hasOwnProperty('WithoutPassword')).is.true; - expect(userTC.__subtypes__.has('WithoutPassword')).is.true; - }); + expect( userTC.__subtypes__.has( 'WithoutPassword' ) ).is.true; + } ); - it('.SubTypes definition is correct Regular Nested Children', () => { + it( '.SubTypes definition is correct Regular Nested Children', () => { assert.notEqual( - Object.getPrototypeOf(Object.getPrototypeOf(overMore)), - Object.getPrototypeOf(Object.getPrototypeOf(moreOver)) + Object.getPrototypeOf( Object.getPrototypeOf( overMore ) ), + Object.getPrototypeOf( Object.getPrototypeOf( moreOver ) ) ); - expect(overMore.__subtypes__.has('EvenMore')).is.true; - expect(moreOver.__subtypes__.has('OverMore')).is.true; + expect( overMore.__subtypes__.has( 'EvenMore' ) ).is.true; + expect( moreOver.__subtypes__.has( 'OverMore' ) ).is.true; // 0.8.4 -- changed interface, no more methods inside of prototype chain // expect(Object.getPrototypeOf(Object.getPrototypeOf(overMore)).hasOwnProperty('EvenMore')).is.true; // expect(Object.getPrototypeOf(Object.getPrototypeOf(moreOver)).hasOwnProperty('OverMore')).is.true; - }); - - it('namespaces shoud be defined', () => { - expect(namespaces).exist.and.is.a('map'); - }); - it('defaultNamespace shoud be defined', () => { - expect(defaultNamespace).to.be.an('object') - .and.equal(namespaces.get(SymbolDefaultNamespace)); - expect(defaultNamespace.name).to.be.a('symbol') - .and.equal(SymbolDefaultNamespace); - }); - it('SymbolDefaultTypesCollection shoud be default', () => { - expect(types[ SymbolDefaultTypesCollection ]).equal(true); - }); - it('MNEMONICA shoud be defined', () => { - expect(MNEMONICA).to.be.a('string').and.equal('Mnemonica'); - }); - it('MNEMOSYNE shoud be defined', () => { - expect(MNEMOSYNE).to.be.a('string').and.equal('Mnemosyne'); - }); - it('SymbolSubtypeCollection shoud be defined', () => { - expect(SymbolSubtypeCollection).to.be.a('symbol'); - }); - it('SymbolConstructorName shoud be defined', () => { - expect(SymbolConstructorName).to.be.a('symbol'); - }); - it('instance checking works', () => { - expect(true instanceof UserType).to.be.false; - expect(undefined instanceof UserType).to.be.false; - expect(Object.create(null) instanceof UserType).to.be.false; - }); + } ); + + it( 'namespaces shoud be defined', () => { + expect( namespaces ).exist.and.is.a( 'map' ); + } ); + it( 'defaultNamespace shoud be defined', () => { + expect( defaultNamespace ).to.be.an( 'object' ) + .and.equal( namespaces.get( SymbolDefaultNamespace ) ); + expect( defaultNamespace.name ).to.be.a( 'symbol' ) + .and.equal( SymbolDefaultNamespace ); + } ); + it( 'SymbolDefaultTypesCollection shoud be default', () => { + expect( types[ SymbolDefaultTypesCollection ] ).equal( true ); + } ); + it( 'MNEMONICA shoud be defined', () => { + expect( MNEMONICA ).to.be.a( 'string' ).and.equal( 'Mnemonica' ); + } ); + it( 'MNEMOSYNE shoud be defined', () => { + expect( MNEMOSYNE ).to.be.a( 'string' ).and.equal( 'Mnemosyne' ); + } ); + it( 'SymbolSubtypeCollection shoud be defined', () => { + expect( SymbolSubtypeCollection ).to.be.a( 'symbol' ); + } ); + it( 'SymbolConstructorName shoud be defined', () => { + expect( SymbolConstructorName ).to.be.a( 'symbol' ); + } ); + it( 'instance checking works', () => { + expect( true instanceof UserType ).to.be.false; + expect( undefined instanceof UserType ).to.be.false; + expect( Object.create( null ) instanceof UserType ).to.be.false; + } ); try { - createTypesCollection({}); - } catch (error) { - it('should register types collection for proper namespace', () => { - expect(error.message).is.equal(ErrorMessages.NAMESPACE_DOES_NOT_EXIST); - }); + createTypesCollection( {} ); + } catch ( error ) { + it( 'should register types collection for proper namespace', () => { + expect( error.message ).is.equal( ErrorMessages.NAMESPACE_DOES_NOT_EXIST ); + } ); } try { - createTypesCollection(anotherNamespace, 'another types collection'); - } catch (error) { - it('should dismiss register types collection with the same name', () => { - expect(error.message).is.equal(ErrorMessages.ASSOCIATION_EXISTS); - }); + createTypesCollection( anotherNamespace, 'another types collection' ); + } catch ( error ) { + it( 'should dismiss register types collection with the same name', () => { + expect( error.message ).is.equal( ErrorMessages.ASSOCIATION_EXISTS ); + } ); } - it('should refer defaultCollection from defaultTypes.subtypes', () => { - expect(types.subtypes).equal(defaultCollection); - }); - it('should refer defaultCollection from defaultTypes.subtypes', () => { - expect(defaultCollection).instanceof(Map); - }); - it('should refer defaultTypes from defaultNamespace', () => { - expect(defaultNamespace.typesCollections.has(types)).is.true; - }); - it('should create collections in defaultNamespace by default', () => { - expect(anotherDefaultTypesCollection.namespace).equal(defaultNamespace); - }); - it('should create instances for in anotherDefaultTypesCollection', () => { - expect(someADTCInstance.test).equal(123); - }); - - it('decorate works correctly', () => { - expect(myDecoratedSubInstance.sub_field).equal(321); - expect(myDecoratedSubInstance.field).equal(123); - }); - - it('apply & call works correctly', () => { - - expect(SubOfSomeADTCTypePre.existentInstance).equal(someADTCInstance); - expect(SubOfSomeADTCTypePost.existentInstance).equal(someADTCInstance); - expect(subOfSomeADTCInstanceANoArgs.test).equal(123); - expect(subOfSomeADTCInstanceA.test).equal(123); - expect(subOfSomeADTCInstanceANoArgs.sub_test).equal(321); - expect(subOfSomeADTCInstanceA.sub_test).equal(321); - expect(subOfSomeADTCInstanceA.args).deep.to.equal([ 1, 2, 3 ]); - - expect(subOfSomeADTCInstanceC.test).equal(123); - expect(subOfSomeADTCInstanceC.sub_test).equal(321); - expect(subOfSomeADTCInstanceC.args).deep.to.equal([ 1, 2, 3 ]); - - expect(subOfSomeADTCInstanceB.test).equal(123); - expect(subOfSomeADTCInstanceB.sub_test).equal(321); - expect(subOfSomeADTCInstanceB.args).deep.to.equal([ 1, 2, 3 ]); - - }); - - it('non strict chain works correctly', () => { - - expect(backSub.sub_test).equal(321); - expect(backSub.constructor.name).equal('SubOfSomeADTCType'); - expect(backSub.__parent__.constructor.name).equal('SubOfSomeADTCType'); - expect(backSub.__parent__.__parent__.constructor.name).equal('SomeADTCType'); - expect(backSub.__parent__.__parent__.__parent__.constructor.name).equal('Mnemonica'); - - }); - - describe('should create type from Proxy.set()', () => { - it('type creation from Proxy.set()', () => { - const userProxyTyped = user.ProxyTyped('aha'); - expect(userProxyTyped.str).equal('aha'); - expect(userProxyTyped.proxyTyped).is.true; - expect(UserType.ProxyTyped.prototype.proxyTyped).is.true; - expect(userProxyTyped.SaySomething()).equal('something : true'); - }); + it( 'should refer defaultCollection from defaultTypes.subtypes', () => { + expect( types.subtypes ).equal( defaultCollection ); + } ); + it( 'should refer defaultCollection from defaultTypes.subtypes', () => { + expect( defaultCollection ).instanceof( Map ); + } ); + it( 'should refer defaultTypes from defaultNamespace', () => { + expect( defaultNamespace.typesCollections.has( types ) ).is.true; + } ); + it( 'should create collections in defaultNamespace by default', () => { + expect( anotherDefaultTypesCollection.namespace ).equal( defaultNamespace ); + } ); + it( 'should create instances for in anotherDefaultTypesCollection', () => { + expect( someADTCInstance.test ).equal( 123 ); + } ); + + it( 'decorate works correctly', () => { + expect( myDecoratedSubInstance.sub_field ).equal( 321 ); + expect( myDecoratedSubInstance.field ).equal( 123 ); + } ); + + it( 'apply & call works correctly', () => { + + expect( SubOfSomeADTCTypePre.existentInstance ).equal( someADTCInstance ); + expect( SubOfSomeADTCTypePost.existentInstance ).equal( someADTCInstance ); + expect( subOfSomeADTCInstanceANoArgs.test ).equal( 123 ); + expect( subOfSomeADTCInstanceA.test ).equal( 123 ); + expect( subOfSomeADTCInstanceANoArgs.sub_test ).equal( 321 ); + expect( subOfSomeADTCInstanceA.sub_test ).equal( 321 ); + expect( subOfSomeADTCInstanceA.args ).deep.to.equal( [ 1, 2, 3 ] ); + + expect( subOfSomeADTCInstanceC.test ).equal( 123 ); + expect( subOfSomeADTCInstanceC.sub_test ).equal( 321 ); + expect( subOfSomeADTCInstanceC.args ).deep.to.equal( [ 1, 2, 3 ] ); + + expect( subOfSomeADTCInstanceB.test ).equal( 123 ); + expect( subOfSomeADTCInstanceB.sub_test ).equal( 321 ); + expect( subOfSomeADTCInstanceB.args ).deep.to.equal( [ 1, 2, 3 ] ); + + } ); + + it( 'non strict chain works correctly', () => { + + expect( backSub.sub_test ).equal( 321 ); + expect( backSub.constructor.name ).equal( 'SubOfSomeADTCType' ); + expect( backSub.__parent__.constructor.name ).equal( 'SubOfSomeADTCType' ); + expect( backSub.__parent__.__parent__.constructor.name ).equal( 'SomeADTCType' ); + expect( backSub.__parent__.__parent__.__parent__.constructor.name ).equal( 'Mnemonica' ); + + } ); + + describe( 'should create type from Proxy.set()', () => { + it( 'type creation from Proxy.set()', () => { + const userProxyTyped = user.ProxyTyped( 'aha' ); + expect( userProxyTyped.str ).equal( 'aha' ); + expect( userProxyTyped.proxyTyped ).is.true; + expect( UserType.ProxyTyped.prototype.proxyTyped ).is.true; + expect( userProxyTyped.SaySomething() ).equal( 'something : true' ); + } ); try { UserType.ProxyType1 = null; - } catch (error) { - it('should respect the rules', () => { - expect(error).instanceOf(Error); - }); - it('thrown error instanceof WRONG_ARGUMENTS_USED', () => { - expect(error).instanceOf(errors.WRONG_TYPE_DEFINITION); - }); - it('thrown error should be ok with props', () => { - expect(error.message).exist.and.is.a('string'); - assert.equal(error.message, 'wrong type definition : should use function for type definition'); - }); + } catch ( error ) { + it( 'should respect the rules', () => { + expect( error ).instanceOf( Error ); + } ); + it( 'thrown error instanceof WRONG_ARGUMENTS_USED', () => { + expect( error ).instanceOf( errors.WRONG_TYPE_DEFINITION ); + } ); + it( 'thrown error should be ok with props', () => { + expect( error.message ).exist.and.is.a( 'string' ); + assert.equal( error.message, 'wrong type definition : should use function for type definition' ); + } ); } try { UserType[ '' ] = function () { }; - } catch (error) { - it('should respect the rules', () => { - expect(error).instanceOf(Error); - }); - it('thrown error instanceof WRONG_ARGUMENTS_USED', () => { - expect(error).instanceOf(errors.WRONG_TYPE_DEFINITION); - }); - it('thrown error should be ok with props', () => { - expect(error.message).exist.and.is.a('string'); - assert.equal(error.message, 'wrong type definition : should use non empty string as TypeName'); - }); + } catch ( error ) { + it( 'should respect the rules', () => { + expect( error ).instanceOf( Error ); + } ); + it( 'thrown error instanceof WRONG_ARGUMENTS_USED', () => { + expect( error ).instanceOf( errors.WRONG_TYPE_DEFINITION ); + } ); + it( 'thrown error should be ok with props', () => { + expect( error.message ).exist.and.is.a( 'string' ); + assert.equal( error.message, 'wrong type definition : should use non empty string as TypeName' ); + } ); } - }); + } ); try { userTC.UserTypeMissing(); - } catch (error) { - it('should fail on missing constructs', () => { - expect(error).instanceOf(Error); - expect(error).instanceOf(TypeError); - }); + } catch ( error ) { + it( 'should fail on missing constructs', () => { + expect( error ).instanceOf( Error ); + expect( error ).instanceOf( TypeError ); + } ); } - }); + } ); - describe('sibling test', () => { - const UserTypePtr1 = user.sibling('UserType'); + describe( 'sibling test', () => { + const UserTypePtr1 = user.sibling( 'UserType' ); const { UserType: UserTypePtr2 } = user.sibling; - it('direct sibling works', () => { - expect(UserType).equal(UserTypePtr1); - }); - it('destructured sibling works', () => { - expect(UserType).equal(UserTypePtr2); - }); - }); - - describe('base error shoud be defined', () => { - it('BASE_MNEMONICA_ERROR exists', () => { - expect(errors.BASE_MNEMONICA_ERROR).to.exist; - }); + it( 'direct sibling works', () => { + expect( UserType ).equal( UserTypePtr1 ); + } ); + it( 'destructured sibling works', () => { + expect( UserType ).equal( UserTypePtr2 ); + } ); + } ); + + describe( 'base error shoud be defined', () => { + it( 'BASE_MNEMONICA_ERROR exists', () => { + expect( errors.BASE_MNEMONICA_ERROR ).to.exist; + } ); try { throw new errors.BASE_MNEMONICA_ERROR(); - } catch (error) { - it('base error instanceof Error', () => { - expect(error).instanceOf(Error); - }); - it('base error instanceof BASE_MNEMONICA_ERROR', () => { - expect(error).instanceOf(errors.BASE_MNEMONICA_ERROR); - }); - it('base error .message is correct', () => { - expect(error.message).is.equal(ErrorMessages.BASE_ERROR_MESSAGE); - }); + } catch ( error ) { + it( 'base error instanceof Error', () => { + expect( error ).instanceOf( Error ); + } ); + it( 'base error instanceof BASE_MNEMONICA_ERROR', () => { + expect( error ).instanceOf( errors.BASE_MNEMONICA_ERROR ); + } ); + it( 'base error .message is correct', () => { + expect( error.message ).is.equal( ErrorMessages.BASE_ERROR_MESSAGE ); + } ); } - }); + } ); - describe('should respect DFD', () => { - const BadBadType = define('BadBadType', function () { + describe( 'should respect DFD', () => { + const BadBadType = define( 'BadBadType', function () { return null; }, { constructor () { } }, { submitStack : true - }); + } ); - const badbad = new BadBadType({}); + const badbad = new BadBadType( {} ); - it('checks primitives are omitted as spec describes', () => { - expect(badbad).instanceOf(BadBadType); - }); + it( 'checks primitives are omitted as spec describes', () => { + expect( badbad ).instanceOf( BadBadType ); + } ); - it('checks prototype constructor property is omited', () => { - expect(badbad.constructor.name).equal('BadBadType'); - }); + it( 'checks prototype constructor property is omited', () => { + expect( badbad.constructor.name ).equal( 'BadBadType' ); + } ); - }); + } ); - describe('should respect DFD', () => { - const BadType = define('BadType', function (NotThis) { + describe( 'should respect DFD', () => { + const BadType = define( 'BadType', function ( NotThis ) { // returns not instanceof this return NotThis; }, {}, { submitStack : true - }); + } ); var hookInstance; - BadType.registerHook('creationError', (_hookInstance) => { + BadType.registerHook( 'creationError', ( _hookInstance ) => { hookInstance = _hookInstance; return true; - }); + } ); // try { // debugger; - const errored = new BadType({}); + const errored = new BadType( {} ); // } catch (error) { const stackstart = '<-- creation of [ BadType ] traced -->'; - it('should respect the rules', () => { - expect(errored).instanceOf(Error); - expect(hookInstance.inheritedInstance).instanceOf(Error); - }); - it('should be instanceof BadType', () => { - expect(errored).instanceOf(BadType); - expect(hookInstance.inheritedInstance).instanceOf(BadType); - }); - it('thrown error instanceof WRONG_MODIFICATION_PATTERN', () => { - expect(errored).instanceOf(errors.WRONG_MODIFICATION_PATTERN); - expect(hookInstance.inheritedInstance).instanceOf(errors.WRONG_MODIFICATION_PATTERN); - }); - it('thrown error should be ok with props', () => { - expect(errored.message).exist.and.is.a('string'); - assert.equal(errored.message, 'wrong modification pattern : should inherit from mnemonica instance'); - }); - it('thrown error should have own .stack property', () => { - assert.equal(hop(errored, 'stack'), true); - }); - it('thrown error.stack should have seekable definition without stack cleaner', () => { + it( 'should respect the rules', () => { + expect( errored ).instanceOf( Error ); + expect( hookInstance.inheritedInstance ).instanceOf( Error ); + } ); + it( 'should be instanceof BadType', () => { + expect( errored ).instanceOf( BadType ); + expect( hookInstance.inheritedInstance ).instanceOf( BadType ); + } ); + it( 'thrown error instanceof WRONG_MODIFICATION_PATTERN', () => { + expect( errored ).instanceOf( errors.WRONG_MODIFICATION_PATTERN ); + expect( hookInstance.inheritedInstance ).instanceOf( errors.WRONG_MODIFICATION_PATTERN ); + } ); + it( 'thrown error should be ok with props', () => { + expect( errored.message ).exist.and.is.a( 'string' ); + assert.equal( errored.message, 'wrong modification pattern : should inherit from mnemonica instance' ); + } ); + it( 'thrown error should have own .stack property', () => { + assert.equal( hop( errored, 'stack' ), true ); + } ); + it( 'thrown error.stack should have seekable definition without stack cleaner', () => { debugger; - expect(errored.stack.indexOf(stackstart)).equal(1); - expect(errored.stack - .indexOf('environment.js') > 0).is.true; + expect( errored.stack.indexOf( stackstart ) ).equal( 1 ); + expect( errored.stack + .indexOf( 'environment.js' ) > 0 ).is.true; // .equal(96); - }); - it('thrown error.stack should have seekable definition without Error.captureStackTrace', () => { + } ); + it( 'thrown error.stack should have seekable definition without Error.captureStackTrace', () => { const { captureStackTrace } = Error; Error.captureStackTrace = null; - const errored1 = new BadType({}); + const errored1 = new BadType( {} ); Error.captureStackTrace = captureStackTrace; - expect(errored1.stack.indexOf(stackstart)).equal(1); - expect(errored1.stack - .indexOf('environment.js') > 0).is.true; - }); - it('thrown error.stack should have seekable definition with stack cleaner', () => { - defineStackCleaner(stackCleanerRegExp); - const errored2 = new BadType({}); - expect(errored2.stack.indexOf(stackstart)).equal(1); - expect(errored2.stack - .indexOf('environment.js') > 0).is.true; - }); - }); - - describe('should not hack DFD', () => { - const BadTypeReThis = define('BadTypeReThis', function () { + expect( errored1.stack.indexOf( stackstart ) ).equal( 1 ); + expect( errored1.stack + .indexOf( 'environment.js' ) > 0 ).is.true; + } ); + it( 'thrown error.stack should have seekable definition with stack cleaner', () => { + defineStackCleaner( stackCleanerRegExp ); + const errored2 = new BadType( {} ); + expect( errored2.stack.indexOf( stackstart ) ).equal( 1 ); + expect( errored2.stack + .indexOf( 'environment.js' ) > 0 ).is.true; + } ); + } ); + + describe( 'should not hack DFD', () => { + const BadTypeReThis = define( 'BadTypeReThis', function () { // removing constructor this.constructor = undefined; - }); - const ThrownHackType = BadTypeReThis.define('ThrownHackType'); + } ); + const ThrownHackType = BadTypeReThis.define( 'ThrownHackType' ); try { new BadTypeReThis().ThrownHackType(); - } catch (error) { - it('should respect construction rules', () => { - expect(error).instanceOf(Error); - }); - it('should be instanceof BadTypeReThis', () => { - expect(error).instanceOf(BadTypeReThis); - }); - it('should be not instanceof ThrownHackType', () => { + } catch ( error ) { + it( 'should respect construction rules', () => { + expect( error ).instanceOf( Error ); + } ); + it( 'should be instanceof BadTypeReThis', () => { + expect( error ).instanceOf( BadTypeReThis ); + } ); + it( 'should be not instanceof ThrownHackType', () => { // cause there was no .constructor - expect(error).not.instanceOf(ThrownHackType); - }); - it('thrown error instanceof WRONG_MODIFICATION_PATTERN', () => { - expect(error).instanceOf(errors.WRONG_MODIFICATION_PATTERN); - }); - it('thrown error should be ok with props', () => { - expect(error.message).exist.and.is.a('string'); - assert.equal(error.message, 'wrong modification pattern : should inherit from mnemonica instance'); - }); + expect( error ).not.instanceOf( ThrownHackType ); + } ); + it( 'thrown error instanceof WRONG_MODIFICATION_PATTERN', () => { + expect( error ).instanceOf( errors.WRONG_MODIFICATION_PATTERN ); + } ); + it( 'thrown error should be ok with props', () => { + expect( error.message ).exist.and.is.a( 'string' ); + assert.equal( error.message, 'wrong modification pattern : should inherit from mnemonica instance' ); + } ); } - }); + } ); - describe('subtype property inside type re-definition', () => { - const BadTypeReInConstruct = define('BadTypeReInConstruct', function () { }); - BadTypeReInConstruct.define('ExistentConstructor', function () { + describe( 'subtype property inside type re-definition', () => { + const BadTypeReInConstruct = define( 'BadTypeReInConstruct', function () { } ); + BadTypeReInConstruct.define( 'ExistentConstructor', function () { this.ExistentConstructor = undefined; - }); + } ); let errored = null; try { const badType = new BadTypeReInConstruct(); const existent = badType.ExistentConstructor(); existent.ExistentConstructor(); - } catch (error) { + } catch ( error ) { errored = error; } - it('Thrown with General JS Error', () => { - expect(errored).instanceOf(Error); - }); - }); + it( 'Thrown with General JS Error', () => { + expect( errored ).instanceOf( Error ); + } ); + } ); - describe('should define through typesCollection proxy', () => { - it('check typesCollection proxified creation', () => { + describe( 'should define through typesCollection proxy', () => { + it( 'check typesCollection proxified creation', () => { types.ProxifiedCreation = function () { }; - }); - }); + } ); + } ); - describe('should throw with wrong definition', () => { + describe( 'should throw with wrong definition', () => { [ [ 'wrong type definition : expect prototype to be an object', () => { - define('Wrong', function () { }, true); + define( 'Wrong', function () { }, true ); }, errors.WRONG_TYPE_DEFINITION ], [ 'wrong type definition : TypeName should start with Uppercase Letter', () => { // next line same as @@ -619,83 +640,83 @@ const tests = (opts) => { define(); }, errors.WRONG_TYPE_DEFINITION ], [ 'handler must be a function', () => { - define('NoConstructFunctionType', NaN, '', 'false'); + define( 'NoConstructFunctionType', NaN, '', 'false' ); }, errors.HANDLER_MUST_BE_A_FUNCTION ], [ 'handler must be a function', () => { - define(() => { + define( () => { return { name : null }; - }); + } ); }, errors.HANDLER_MUST_BE_A_FUNCTION ], [ 'this type has already been declared', () => { - define('UserTypeConstructor', () => { + define( 'UserTypeConstructor', () => { return function WithoutPassword () { }; - }); + } ); }, errors.ALREADY_DECLARED ], [ 'typename must be a string', () => { - define('UserType.UserTypePL1', () => { + define( 'UserType.UserTypePL1', () => { return function () { }; - }); + } ); }, errors.TYPENAME_MUST_BE_A_STRING ], - ].forEach(entry => { + ].forEach( entry => { const [ errorMessage, fn, err ] = entry; - it(`check throw with : '${errorMessage}'`, () => { - expect(fn).throw(); + it( `check throw with : '${errorMessage}'`, () => { + expect( fn ).throw(); try { fn(); - } catch (error) { - expect(error).to.be.an - .instanceof(err); - expect(error).to.be.an - .instanceof(Error); - expect(error.message).equal(errorMessage); + } catch ( error ) { + expect( error ).to.be.an + .instanceof( err ); + expect( error ).to.be.an + .instanceof( Error ); + expect( error.message ).equal( errorMessage ); } - }); - }); - }); - - describe('another namespace instances', () => { - it('Another Nnamespace has both defined collections', () => { - expect(anotherNamespace.typesCollections.has(anotherTypesCollection)).is.true; - expect(anotherNamespace.typesCollections.has(oneElseTypesCollection)).is.true; - }); - it('Another Nnamespace typesCollections gather types', () => { + } ); + } ); + } ); + + describe( 'another namespace instances', () => { + it( 'Another Nnamespace has both defined collections', () => { + expect( anotherNamespace.typesCollections.has( anotherTypesCollection ) ).is.true; + expect( anotherNamespace.typesCollections.has( oneElseTypesCollection ) ).is.true; + } ); + it( 'Another Nnamespace typesCollections gather types', () => { // expect(anotherTypesCollection).hasOwnProperty('AnotherCollectionType'); - expect(hop(anotherTypesCollection, 'AnotherCollectionType')).is.true; + expect( hop( anotherTypesCollection, 'AnotherCollectionType' ) ).is.true; // expect(oneElseTypesCollection).hasOwnProperty('OneElseCollectionType'); - expect(hop(anotherTypesCollection, 'SomethingThatDoesNotExist')).is.false; - expect(hop(oneElseTypesCollection, 'OneElseCollectionType')).is.true; - expect(hop(oneElseTypesCollection, 'SomethingThatDoesNotExist')).is.false; - }); - - it('Instance Of Another Nnamespace and AnotherCollectionType', () => { - expect(anotherCollectionInstance).instanceOf(AnotherCollectionType); - }); - it('anotherCollectionInstance.TestForAddition pass gaia proxy', () => { - expect(anotherCollectionInstance.TestForAddition).equal('passed'); - }); - it('starter Instance can extend', () => { + expect( hop( anotherTypesCollection, 'SomethingThatDoesNotExist' ) ).is.false; + expect( hop( oneElseTypesCollection, 'OneElseCollectionType' ) ).is.true; + expect( hop( oneElseTypesCollection, 'SomethingThatDoesNotExist' ) ).is.false; + } ); + + it( 'Instance Of Another Nnamespace and AnotherCollectionType', () => { + expect( anotherCollectionInstance ).instanceOf( AnotherCollectionType ); + } ); + it( 'anotherCollectionInstance.TestForAddition pass gaia proxy', () => { + expect( anotherCollectionInstance.TestForAddition ).equal( 'passed' ); + } ); + it( 'starter Instance can extend', () => { const { on, check } = anotherCollectionInstance; - expect(check).equal('check'); - expect(on).equal(process.on); - }); - it('Instance Of OneElse Nnamespace and OneElseCollectionType', () => { - expect(oneElseCollectionInstance).instanceOf(OneElseCollectionType); - }); - it('Instance circular .toJSON works', () => { - const circularExtracted = JSON.parse(toJSON(oneElseCollectionInstance)); + expect( check ).equal( 'check' ); + expect( on ).equal( process.on ); + } ); + it( 'Instance Of OneElse Nnamespace and OneElseCollectionType', () => { + expect( oneElseCollectionInstance ).instanceOf( OneElseCollectionType ); + } ); + it( 'Instance circular .toJSON works', () => { + const circularExtracted = JSON.parse( toJSON( oneElseCollectionInstance ) ); const { description } = circularExtracted.self; - expect(description).equal('This value type is not supported by JSON.stringify'); - }); - it('Instance circular .toJSON works', () => { + expect( description ).equal( 'This value type is not supported by JSON.stringify' ); + } ); + it( 'Instance circular .toJSON works', () => { const proto = Object.getPrototypeOf( Object.getPrototypeOf( Object.getPrototypeOf( - oneElseCollectionInstance))); + oneElseCollectionInstance ) ) ); const { constructor: { name, @@ -705,60 +726,60 @@ const tests = (opts) => { }, [ SymbolConstructorName ]: namespaceName } = proto; - expect(name).equal(MNEMONICA); - expect(protoConstructSymbol).equal(MNEMONICA); - expect(namespaceName).equal('anotherNamespace'); - }); - }); + expect( name ).equal( MNEMONICA ); + expect( protoConstructSymbol ).equal( MNEMONICA ); + expect( namespaceName ).equal( 'anotherNamespace' ); + } ); + } ); - describe('hooks environment', () => { + describe( 'hooks environment', () => { try { defaultNamespace.registerFlowChecker(); - } catch (error) { - it('Thrown with Missing Callback', () => { - expect(error).instanceOf(Error); - expect(error).instanceOf(errors.MISSING_CALLBACK_ARGUMENT); - }); + } catch ( error ) { + it( 'Thrown with Missing Callback', () => { + expect( error ).instanceOf( Error ); + expect( error ).instanceOf( errors.MISSING_CALLBACK_ARGUMENT ); + } ); } try { - defaultNamespace.registerFlowChecker(() => { }); - } catch (error) { - it('Thrown with Re-Definition', () => { - expect(error).instanceOf(Error); - expect(error).instanceOf(errors.FLOW_CHECKER_REDEFINITION); - }); + defaultNamespace.registerFlowChecker( () => { } ); + } catch ( error ) { + it( 'Thrown with Re-Definition', () => { + expect( error ).instanceOf( Error ); + expect( error ).instanceOf( errors.FLOW_CHECKER_REDEFINITION ); + } ); } try { - defaultNamespace.registerHook('WrongHookType', () => { }); - } catch (error) { - it('Thrown with Re-Definition', () => { - expect(error).instanceOf(Error); - expect(error).instanceOf(errors.WRONG_HOOK_TYPE); - }); + defaultNamespace.registerHook( 'WrongHookType', () => { } ); + } catch ( error ) { + it( 'Thrown with Re-Definition', () => { + expect( error ).instanceOf( Error ); + expect( error ).instanceOf( errors.WRONG_HOOK_TYPE ); + } ); } try { - defaultNamespace.registerHook('postCreation'); - } catch (error) { - it('Thrown with Re-Definition', () => { - expect(error).instanceOf(Error); - expect(error).instanceOf(errors.MISSING_HOOK_CALLBACK); - }); + defaultNamespace.registerHook( 'postCreation' ); + } catch ( error ) { + it( 'Thrown with Re-Definition', () => { + expect( error ).instanceOf( Error ); + expect( error ).instanceOf( errors.MISSING_HOOK_CALLBACK ); + } ); } - }); + } ); - describe('strict chain test', () => { - it('deep chained type should be undefined', () => { - expect(userWithoutPassword.WithoutPassword).equal(undefined); - }); - }); + describe( 'strict chain test', () => { + it( 'deep chained type should be undefined', () => { + expect( userWithoutPassword.WithoutPassword ).equal( undefined ); + } ); + } ); - describe('check uncained construction', () => { - it('check instance creation without chain', () => { - expect(unchainedUserWithoutPassword).instanceof(UserWithoutPassword); - }); - }); + describe( 'check uncained construction', () => { + it( 'check instance creation without chain', () => { + expect( unchainedUserWithoutPassword ).instanceof( UserWithoutPassword ); + } ); + } ); - describe('merge tests', () => { + describe( 'merge tests', () => { const mergedSample = { OverMoreSign : 'OverMoreSign', WithAdditionalSignSign : 'WithAdditionalSignSign', @@ -769,108 +790,108 @@ const tests = (opts) => { sign : 'userWithoutPassword_2.WithAdditionalSign', str : 're-defined OverMore str', }; - it('merge works correctly', () => { - assert.deepEqual(merged.extract(), mergedSample); - }); + it( 'merge works correctly', () => { + assert.deepEqual( merged.extract(), mergedSample ); + } ); - describe('wrong A 1', () => { + describe( 'wrong A 1', () => { try { - merge(null, userTC); - } catch (error) { - it('should respect the rules', () => { - expect(error).instanceOf(Error); - }); - it('thrown error instanceof WRONG_ARGUMENTS_USED', () => { - expect(error).instanceOf(errors.WRONG_ARGUMENTS_USED); - }); - it('thrown error should be ok with props', () => { - expect(error.message).exist.and.is.a('string'); - assert.equal(error.message, 'wrong arguments : should use proper invocation : A should be an object'); - }); + merge( null, userTC ); + } catch ( error ) { + it( 'should respect the rules', () => { + expect( error ).instanceOf( Error ); + } ); + it( 'thrown error instanceof WRONG_ARGUMENTS_USED', () => { + expect( error ).instanceOf( errors.WRONG_ARGUMENTS_USED ); + } ); + it( 'thrown error should be ok with props', () => { + expect( error.message ).exist.and.is.a( 'string' ); + assert.equal( error.message, 'wrong arguments : should use proper invocation : A should be an object' ); + } ); } - }); - describe('wrong A 2', () => { + } ); + describe( 'wrong A 2', () => { const Cstr = function () { }; - Cstr.prototype.clone = Object.create({}); + Cstr.prototype.clone = Object.create( {} ); const d = new Cstr(); try { - merge(d, userTC); - } catch (error) { - it('should respect the rules', () => { - expect(error).instanceOf(Error); - }); - it('thrown error instanceof WRONG_ARGUMENTS_USED', () => { - expect(error).instanceOf(errors.WRONG_ARGUMENTS_USED); - }); - it('thrown error should be ok with props', () => { - expect(error.message).exist.and.is.a('string'); - assert.equal(error.message, 'wrong arguments : should use proper invocation : A should have A.fork()'); - }); + merge( d, userTC ); + } catch ( error ) { + it( 'should respect the rules', () => { + expect( error ).instanceOf( Error ); + } ); + it( 'thrown error instanceof WRONG_ARGUMENTS_USED', () => { + expect( error ).instanceOf( errors.WRONG_ARGUMENTS_USED ); + } ); + it( 'thrown error should be ok with props', () => { + expect( error.message ).exist.and.is.a( 'string' ); + assert.equal( error.message, 'wrong arguments : should use proper invocation : A should have A.fork()' ); + } ); } - }); - describe('wrong B', () => { + } ); + describe( 'wrong B', () => { try { - merge(userTC, null); - } catch (error) { - it('should respect the rules', () => { - expect(error).instanceOf(Error); - }); - it('thrown error instanceof WRONG_ARGUMENTS_USED', () => { - expect(error).instanceOf(errors.WRONG_ARGUMENTS_USED); - }); - it('thrown error should be ok with props', () => { - expect(error.message).exist.and.is.a('string'); - assert.equal(error.message, 'wrong arguments : should use proper invocation : B should be an object'); - }); + merge( userTC, null ); + } catch ( error ) { + it( 'should respect the rules', () => { + expect( error ).instanceOf( Error ); + } ); + it( 'thrown error instanceof WRONG_ARGUMENTS_USED', () => { + expect( error ).instanceOf( errors.WRONG_ARGUMENTS_USED ); + } ); + it( 'thrown error should be ok with props', () => { + expect( error.message ).exist.and.is.a( 'string' ); + assert.equal( error.message, 'wrong arguments : should use proper invocation : B should be an object' ); + } ); } - }); - }); - - describe('chain repeat check', () => { - const keys1_1 = Object.keys(userTC); - const keys1_2 = Object.keys(chained); - const keys2_1 = Object.keys(userWithoutPassword); - const keys2_2 = Object.keys(derived); - it('simple chain is ok', () => { - assert.deepEqual(keys1_1, keys1_2); - assert.deepEqual(keys2_1, keys2_2); - }); - it('real chain is ok too', () => { - assert.deepEqual(rounded.extract(), chained2.extract()); - }); - }); - - }); - - describe('immediate error shape', () => { - const ErroredShapePtr = UserType.define(class ErroredShape { + } ); + } ); + + describe( 'chain repeat check', () => { + const keys1_1 = Object.keys( userTC ); + const keys1_2 = Object.keys( chained ); + const keys2_1 = Object.keys( userWithoutPassword ); + const keys2_2 = Object.keys( derived ); + it( 'simple chain is ok', () => { + assert.deepEqual( keys1_1, keys1_2 ); + assert.deepEqual( keys2_1, keys2_2 ); + } ); + it( 'real chain is ok too', () => { + assert.deepEqual( rounded.extract(), chained2.extract() ); + } ); + } ); + + } ); + + describe( 'immediate error shape', () => { + const ErroredShapePtr = UserType.define( class ErroredShape { constructor () { this.shape = 321; } - }); + } ); const esi = new ErroredShapePtr; - assert.equal(esi.shape, 321); + assert.equal( esi.shape, 321 ); let errorPtr; try { new ErroredShapePtr; - } catch (error) { + } catch ( error ) { errorPtr = error; } - it('wrong ErroredShapePtr creation instanceof Error', () => { - expect(errorPtr).instanceOf(Error); - }); - it('wrong .exception() creation instanceof WRONG_INSTANCE_INVOCATION', () => { - expect(errorPtr).instanceOf(errors.PROTOTYPE_USED_TWICE); - }); - it('wrong .exception() creation should have nice message', () => { - expect(errorPtr.message.includes('.prototype used twice')).is.true; - expect(errorPtr.message.includes('ErroredShape')).is.true; - }); - }); + it( 'wrong ErroredShapePtr creation instanceof Error', () => { + expect( errorPtr ).instanceOf( Error ); + } ); + it( 'wrong .exception() creation instanceof WRONG_INSTANCE_INVOCATION', () => { + expect( errorPtr ).instanceOf( errors.PROTOTYPE_USED_TWICE ); + } ); + it( 'wrong .exception() creation should have nice message', () => { + expect( errorPtr.message.includes( '.prototype used twice' ) ).is.true; + expect( errorPtr.message.includes( 'ErroredShape' ) ).is.true; + } ); + } ); - describe('delayed error shape', () => { + describe( 'delayed error shape', () => { class DelayedErrorShape { constructor () { @@ -878,166 +899,166 @@ const tests = (opts) => { } } - const ErroredShapePtr = UserType.define(() => { + const ErroredShapePtr = UserType.define( () => { return class ShapeMyError extends DelayedErrorShape { }; - }); + } ); const esi = new ErroredShapePtr; - assert.equal(esi.shape, 321); + assert.equal( esi.shape, 321 ); let errorPtr; try { new ErroredShapePtr; - } catch (error) { + } catch ( error ) { errorPtr = error; } - it('wrong ErroredShapePtr creation instanceof Error', () => { - expect(errorPtr).instanceOf(Error); - }); - it('wrong .exception() creation instanceof WRONG_INSTANCE_INVOCATION', () => { - expect(errorPtr).instanceOf(errors.PROTOTYPE_USED_TWICE); - }); - it('wrong .exception() creation should have nice message', () => { - expect(errorPtr.message.includes('.prototype used twice')).is.true; - expect(errorPtr.message.includes('DelayedErrorShape')).is.true; - expect(errorPtr.message.includes('ShapeMyError')).is.true; - }); - }); - - describe('wrong namespace creation', () => { + it( 'wrong ErroredShapePtr creation instanceof Error', () => { + expect( errorPtr ).instanceOf( Error ); + } ); + it( 'wrong .exception() creation instanceof WRONG_INSTANCE_INVOCATION', () => { + expect( errorPtr ).instanceOf( errors.PROTOTYPE_USED_TWICE ); + } ); + it( 'wrong .exception() creation should have nice message', () => { + expect( errorPtr.message.includes( '.prototype used twice' ) ).is.true; + expect( errorPtr.message.includes( 'DelayedErrorShape' ) ).is.true; + expect( errorPtr.message.includes( 'ShapeMyError' ) ).is.true; + } ); + } ); + + describe( 'wrong namespace creation', () => { try { - createNamespace('wrong config namespace', true); - } catch (error) { - it('should avoid namespace creation with wrong config', () => { - expect(error.message).is.equal(ErrorMessages.OPTIONS_ERROR); - }); + createNamespace( 'wrong config namespace', true ); + } catch ( error ) { + it( 'should avoid namespace creation with wrong config', () => { + expect( error.message ).is.equal( ErrorMessages.OPTIONS_ERROR ); + } ); } const goodNamespaceDescription = 'good config namespace'; - const goodNamespace = createNamespace('good_config_namespace', goodNamespaceDescription); - it('namespace with string instead of config should have description', () => { - expect(goodNamespace[ SymbolConfig ].description).is.equal(goodNamespaceDescription); - }); + const goodNamespace = createNamespace( 'good_config_namespace', goodNamespaceDescription ); + it( 'namespace with string instead of config should have description', () => { + expect( goodNamespace[ SymbolConfig ].description ).is.equal( goodNamespaceDescription ); + } ); - const goodNamespaceTC = goodNamespace.createTypesCollection('good namespace types collection', { + const goodNamespaceTC = goodNamespace.createTypesCollection( 'good namespace types collection', { useOldStyle : true - }); - it('namespace types collection creation check', () => { - expect(goodNamespaceTC[ SymbolConfig ].useOldStyle).is.equal(true); - expect(goodNamespaceTC[ SymbolConfig ].strictChain).is.equal(true); - }); + } ); + it( 'namespace types collection creation check', () => { + expect( goodNamespaceTC[ SymbolConfig ].useOldStyle ).is.equal( true ); + expect( goodNamespaceTC[ SymbolConfig ].strictChain ).is.equal( true ); + } ); - }); + } ); - describe('prepareException', () => { + describe( 'prepareException', () => { let errorInstance = null; - let exceptionError = new Error('asdf'); + let exceptionError = new Error( 'asdf' ); try { - throw new someADTCInstance.exception(exceptionError, 1, 2, 3); - } catch (error) { + throw new someADTCInstance.exception( exceptionError, 1, 2, 3 ); + } catch ( error ) { errorInstance = error; } - it('.exception() shoud have own stack property', () => { - expect(hop(errorInstance, 'stack')).equal(true); + it( '.exception() shoud have own stack property', () => { + expect( hop( errorInstance, 'stack' ) ).equal( true ); // console.log(errorInstance.stack.indexOf('<-- of constructor definitions stack -->'), '!!!!!!!!!!!!!'); // expect(errorInstance.stack.indexOf('<-- of constructor definitions stack -->')).equal(1985); v20 // expect(errorInstance.stack.indexOf('<-- of constructor definitions stack -->')).equal(2126); v22 - expect(errorInstance.stack.indexOf('<-- of constructor definitions stack -->') > 1000).equal(true); + expect( errorInstance.stack.indexOf( '<-- of constructor definitions stack -->' ) > 1000 ).equal( true ); // process.exit(0); - }); - it('.exception() shoud create instanceof Error', () => { - expect(errorInstance).instanceOf(Error); - }); - it('.exception() shoud create instanceof CreationType', () => { - expect(errorInstance).instanceOf(someADTCInstance.__type__); - }); - it('.exception() args should exists create instanceof CreationType', () => { - expect(errorInstance).instanceOf(someADTCInstance.__type__); - }); - it('.exception() .instance should be existent instance', () => { - expect(errorInstance.instance).equal(someADTCInstance); - }); - it('.exception() should have nice .args property', () => { - expect(errorInstance.args[ 0 ]).equal(1); - expect(errorInstance.args[ 1 ]).equal(2); - expect(errorInstance.args[ 2 ]).equal(3); - }); - - it('.exception() .extract() works property', () => { - assert.deepOwnInclude(errorInstance.extract(), someADTCInstance.extract()); - assert.deepOwnInclude(someADTCInstance.extract(), errorInstance.extract()); - }); - it('.exception() .extract() works property', () => { - assert.deepOwnInclude(errorInstance.parse(), parse(someADTCInstance)); - assert.deepOwnInclude(parse(someADTCInstance), errorInstance.parse()); - }); + } ); + it( '.exception() shoud create instanceof Error', () => { + expect( errorInstance ).instanceOf( Error ); + } ); + it( '.exception() shoud create instanceof CreationType', () => { + expect( errorInstance ).instanceOf( someADTCInstance.__type__ ); + } ); + it( '.exception() args should exists create instanceof CreationType', () => { + expect( errorInstance ).instanceOf( someADTCInstance.__type__ ); + } ); + it( '.exception() .instance should be existent instance', () => { + expect( errorInstance.instance ).equal( someADTCInstance ); + } ); + it( '.exception() should have nice .args property', () => { + expect( errorInstance.args[ 0 ] ).equal( 1 ); + expect( errorInstance.args[ 1 ] ).equal( 2 ); + expect( errorInstance.args[ 2 ] ).equal( 3 ); + } ); + + it( '.exception() .extract() works property', () => { + assert.deepOwnInclude( errorInstance.extract(), someADTCInstance.extract() ); + assert.deepOwnInclude( someADTCInstance.extract(), errorInstance.extract() ); + } ); + it( '.exception() .extract() works property', () => { + assert.deepOwnInclude( errorInstance.parse(), parse( someADTCInstance ) ); + assert.deepOwnInclude( parse( someADTCInstance ), errorInstance.parse() ); + } ); let wrongErrorInstanceNoNew = null; try { - throw someADTCInstance.exception(exceptionError, 1, 2, 3); - } catch (error) { + throw someADTCInstance.exception( exceptionError, 1, 2, 3 ); + } catch ( error ) { wrongErrorInstanceNoNew = error; } - it('wrong .exception() creation instanceof Error', () => { - expect(wrongErrorInstanceNoNew).instanceOf(Error); - }); - it('wrong .exception() creation instanceof WRONG_INSTANCE_INVOCATION', () => { - expect(wrongErrorInstanceNoNew).instanceOf(errors.WRONG_INSTANCE_INVOCATION); - }); - it('wrong .exception() creation should have nice message', () => { - expect(wrongErrorInstanceNoNew.message.includes('exception should be made with new keyword')).is.true; - }); + it( 'wrong .exception() creation instanceof Error', () => { + expect( wrongErrorInstanceNoNew ).instanceOf( Error ); + } ); + it( 'wrong .exception() creation instanceof WRONG_INSTANCE_INVOCATION', () => { + expect( wrongErrorInstanceNoNew ).instanceOf( errors.WRONG_INSTANCE_INVOCATION ); + } ); + it( 'wrong .exception() creation should have nice message', () => { + expect( wrongErrorInstanceNoNew.message.includes( 'exception should be made with new keyword' ) ).is.true; + } ); let wrongErrorInstanceIsNotAnError = null; try { - throw new someADTCInstance.exception('asdf', 1, 2, 3); - } catch (error) { + throw new someADTCInstance.exception( 'asdf', 1, 2, 3 ); + } catch ( error ) { wrongErrorInstanceIsNotAnError = error; } - it('wrong .exception() creation instanceof Error', () => { - expect(wrongErrorInstanceIsNotAnError).instanceOf(Error); - }); - it('wrong .exception() creation instanceof WRONG_ARGUMENTS_USED', () => { - expect(wrongErrorInstanceIsNotAnError).instanceOf(errors.WRONG_ARGUMENTS_USED); - }); - it('wrong .exception() creation should have nice message', () => { - expect(wrongErrorInstanceIsNotAnError.message.includes('error must be instanceof Error')).is.true; - }); - - it('wrong .exception() .instance should be existent instance', () => { - expect(wrongErrorInstanceIsNotAnError.instance).equal(someADTCInstance); - }); - it('wrong .exception() .error should be given error', () => { - expect(wrongErrorInstanceIsNotAnError.error).equal('asdf'); - }); - it('wrong .exception() .args should be given args', () => { - expect(wrongErrorInstanceIsNotAnError.args[ 0 ]).equal(1); - expect(wrongErrorInstanceIsNotAnError.args[ 1 ]).equal(2); - expect(wrongErrorInstanceIsNotAnError.args[ 2 ]).equal(3); - }); + it( 'wrong .exception() creation instanceof Error', () => { + expect( wrongErrorInstanceIsNotAnError ).instanceOf( Error ); + } ); + it( 'wrong .exception() creation instanceof WRONG_ARGUMENTS_USED', () => { + expect( wrongErrorInstanceIsNotAnError ).instanceOf( errors.WRONG_ARGUMENTS_USED ); + } ); + it( 'wrong .exception() creation should have nice message', () => { + expect( wrongErrorInstanceIsNotAnError.message.includes( 'error must be instanceof Error' ) ).is.true; + } ); + + it( 'wrong .exception() .instance should be existent instance', () => { + expect( wrongErrorInstanceIsNotAnError.instance ).equal( someADTCInstance ); + } ); + it( 'wrong .exception() .error should be given error', () => { + expect( wrongErrorInstanceIsNotAnError.error ).equal( 'asdf' ); + } ); + it( 'wrong .exception() .args should be given args', () => { + expect( wrongErrorInstanceIsNotAnError.args[ 0 ] ).equal( 1 ); + expect( wrongErrorInstanceIsNotAnError.args[ 1 ] ).equal( 2 ); + expect( wrongErrorInstanceIsNotAnError.args[ 2 ] ).equal( 3 ); + } ); let wrongErrorInstanceIsNotAConstructor = null; try { - throw new someADTCInstance.exception.call(null, 'asdf', 1, 2, 3); - } catch (error) { + throw new someADTCInstance.exception.call( null, 'asdf', 1, 2, 3 ); + } catch ( error ) { wrongErrorInstanceIsNotAConstructor = error; } - it('wrong .exception() creation instanceof Error', () => { - expect(wrongErrorInstanceIsNotAConstructor).instanceOf(Error); - }); - it('wrong .exception() creation instanceof TypeError', () => { + it( 'wrong .exception() creation instanceof Error', () => { + expect( wrongErrorInstanceIsNotAConstructor ).instanceOf( Error ); + } ); + it( 'wrong .exception() creation instanceof TypeError', () => { // is not a constructor - expect(wrongErrorInstanceIsNotAConstructor).instanceOf(TypeError); - }); + expect( wrongErrorInstanceIsNotAConstructor ).instanceOf( TypeError ); + } ); - }); + } ); }; diff --git a/test/hookSamples.js b/test/hookSamples.js index e7d9e97..df7ada1 100644 --- a/test/hookSamples.js +++ b/test/hookSamples.js @@ -87,6 +87,8 @@ const namespaceFlowCheckerSample = [ 'UserTypeConstructor', 'UserTypeConstructor', 'UserTypeConstructor', + 'NullishReturn', + 'NullishReturn', 'NamedFunction', 'BadBadType', 'BadBadType', diff --git a/test/hooks.js b/test/hooks.js index e06faa7..a5bc12a 100644 --- a/test/hooks.js +++ b/test/hooks.js @@ -1,13 +1,13 @@ 'use strict'; -const { assert } = require('chai'); +const { assert } = require( 'chai' ); const { defaultTypes: types, defaultNamespace, -} = require('..'); +} = require( '..' ); -const tests = (opts) => { +const tests = ( opts ) => { const { userTypeHooksInvocations, @@ -20,43 +20,43 @@ const tests = (opts) => { } = opts; - describe('Hooks Tests', () => { - it('check invocations test', () => { - const { namespaceFlowCheckerSample } = require('./hookSamples'); - namespaceFlowCheckerInvocations.forEach((el, idx) => { + describe( 'Hooks Tests', () => { + it( 'check invocations test', () => { + const { namespaceFlowCheckerSample } = require( './hookSamples' ); + namespaceFlowCheckerInvocations.forEach( ( el, idx ) => { const nst = namespaceFlowCheckerSample[ idx ]; const elt = el.TypeName; - // if (nst != elt) { - // console.log(idx); - // debugger; - // } - assert.equal(nst, elt); - }); - }); - it('check invocations count', () => { - assert.equal(8, userTypeHooksInvocations.length); + if ( nst != elt ) { + console.log( idx, nst, elt ); + debugger; + } + assert.equal( nst, elt ); + } ); + } ); + it( 'check invocations count', () => { + assert.equal( 8, userTypeHooksInvocations.length ); debugger; // +2 - assert.equal(181, namespaceFlowCheckerInvocations.length); + assert.equal( 183, namespaceFlowCheckerInvocations.length ); // +2 - assert.equal(169, typesFlowCheckerInvocations.length); + assert.equal( 171, typesFlowCheckerInvocations.length ); // +1 - assert.equal(92, typesPreCreationInvocations.length); + assert.equal( 93, typesPreCreationInvocations.length ); // there are two errors on creation // checked before // that is why, and with clones // +1 - assert.equal(77, typesPostCreationInvocations.length); + assert.equal( 78, typesPostCreationInvocations.length ); // +1 - assert.equal(98, namespacePreCreationInvocations.length); + assert.equal( 99, namespacePreCreationInvocations.length ); // there are two registered Hooks, that is why // +2 - assert.equal(166, namespacePostCreationInvocations.length); - }); - }); + assert.equal( 168, namespacePostCreationInvocations.length ); + } ); + } ); - describe('check invocations of "this"', () => { - userTypeHooksInvocations.forEach(entry => { + describe( 'check invocations of "this"', () => { + userTypeHooksInvocations.forEach( entry => { const { self, opts: { @@ -65,51 +65,51 @@ const tests = (opts) => { sort, kind, } = entry; - it(`'this' for ${kind}-hook of ${sort} should refer to type ${type.TypeName}`, () => { - assert.equal(self, type); - }); - }); - typesPreCreationInvocations.forEach(entry => { + it( `'this' for ${kind}-hook of ${sort} should refer to type ${type.TypeName}`, () => { + assert.equal( self, type ); + } ); + } ); + typesPreCreationInvocations.forEach( entry => { const { self, sort, kind, } = entry; - it(`'this' for ${kind}-hook of ${sort} should refer to type defaultTypes`, () => { - assert.equal(self, types); - }); - }); - typesPostCreationInvocations.forEach(entry => { + it( `'this' for ${kind}-hook of ${sort} should refer to type defaultTypes`, () => { + assert.equal( self, types ); + } ); + } ); + typesPostCreationInvocations.forEach( entry => { const { self, sort, kind, } = entry; - it(`'this' for ${kind}-hook of ${sort} should refer to type defaultTypes`, () => { - assert.equal(self, types); - }); - }); - namespacePreCreationInvocations.forEach(entry => { + it( `'this' for ${kind}-hook of ${sort} should refer to type defaultTypes`, () => { + assert.equal( self, types ); + } ); + } ); + namespacePreCreationInvocations.forEach( entry => { const { self, sort, kind, } = entry; - it(`'this' for ${kind}-hook of ${sort} should refer to type defaultNamespace`, () => { - assert.equal(self, defaultNamespace); - }); - }); - namespacePostCreationInvocations.forEach(entry => { + it( `'this' for ${kind}-hook of ${sort} should refer to type defaultNamespace`, () => { + assert.equal( self, defaultNamespace ); + } ); + } ); + namespacePostCreationInvocations.forEach( entry => { const { self, sort, kind, } = entry; - it(`'this' for ${kind}-hook of ${sort} should refer to type defaultNamespace`, () => { - assert.equal(self, defaultNamespace); - }); - }); - }); + it( `'this' for ${kind}-hook of ${sort} should refer to type defaultNamespace`, () => { + assert.equal( self, defaultNamespace ); + } ); + } ); + } ); }; diff --git a/test/index.js b/test/index.js index 60c11d5..ab49f8e 100644 --- a/test/index.js +++ b/test/index.js @@ -300,20 +300,33 @@ const AsyncWOReturnNAR = define('AsyncWOReturnNAR', async function () { }, {}, { awaitReturn : false }); +const constructNested = function () { + const DoNestedConstruct = this.NestedConstruct; + return new DoNestedConstruct(); +}; + +var new_targets = []; + const Main = define('Main', function () { - this.constructNested = function () { - return new this.NestedConstruct(); - }; + if (new.target) { + new_targets.push(this.constructor.name); + } + this.constructNested = constructNested; }); const NestedConstruct = Main.define('NestedConstruct', function () { + if (new.target) { + new_targets.push(this.constructor.name); + } // 1. direct // throw new Error('Nested Constructor Special Error'); // 2. sub this.nested = new this.NestedSubError(123); }); NestedConstruct.define('NestedSubError', function (...args) { + if (new.target) { + new_targets.push(this.constructor.name); + } this.args = args; - debugger; throw new Error('Nested SubError Constructor Special Error'); }); @@ -339,7 +352,6 @@ const AsyncType = define('AsyncType', async function (data) { erroredNestedConstructMethod () { // will throw RangeError : max stack size - debugger; const main = new Main(); main.nested = main.constructNested(); }, @@ -1160,7 +1172,7 @@ describe('Main Test', () => { } = asyncInstanceClone; let thrown; - + new_targets = []; try { debugger; erroredNestedConstructMethod(); @@ -1169,6 +1181,10 @@ describe('Main Test', () => { thrown = error; } + expect(new_targets[ 0 ]).equal('Main'); + expect(new_targets[ 1 ]).equal('NestedConstruct'); + expect(new_targets[ 2 ]).equal('NestedSubError'); + expect(thrown).instanceOf(Error); expect(thrown).not.instanceOf(AsyncType); expect(thrown.message).exist.and.is.a('string'); @@ -1180,9 +1196,9 @@ describe('Main Test', () => { args, instance } = thrown; - assert.equal(args[ 0 ], 123); assert.equal(instance.constructor.name, 'NestedSubError'); + debugger; const parsed = thrown.parse(); assert.equal(parsed.name, 'NestedSubError'); diff --git a/test/v8bug.js b/test/v8bug.js new file mode 100644 index 0000000..c09f42c --- /dev/null +++ b/test/v8bug.js @@ -0,0 +1,64 @@ +'use strict'; + + +// though Error.prototype.stack is non standard +// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/stack + +const myErrorObject = new Error('my error'); +myErrorObject.prop = 123; +const hop = (o, p) => Object.prototype.hasOwnProperty.call(o, p); + +// nodejs v20 & v22 it works properly +console.log(hop(myErrorObject, 'stack')); +// and for Firefox this property above just does not exists at all +// hop(Object.getPrototypeOf(myErrorObject), 'stack'); + + +const myIntermediateObject = {}; + +Object.setPrototypeOf(myIntermediateObject, myErrorObject); + +console.log(myIntermediateObject instanceof Error); + +myIntermediateObject.stack = myErrorObject.stack; +// it doesn't matter which value you assign there, +// for example uncomment the next line +// myIntermediateObject.stack = 'myErrorObject.stack'; +myIntermediateObject.prop = 123; + +// this works properly for node.js v20, but not for v22 +console.log(':', hop(myIntermediateObject, 'stack')); +console.log(':', hop(myIntermediateObject, 'prop')); + +const myCorrectedObject = {}; +Object.setPrototypeOf(myCorrectedObject, myErrorObject); +console.log(myCorrectedObject instanceof Error); + +Object.defineProperty(myCorrectedObject, 'stack', { + get () { + return myErrorObject.stack; + } +}); + +// nodejs v20 & v22 it works properly +console.log(hop(myCorrectedObject, 'stack')); + + + +// so for objects with Error in prototoype chain +// it optimizes .stack property + +// general behaviour works correctly for both +const base = { + stack : 'str', + prop : 123 +}; + +const sup = {}; + +Object.setPrototypeOf(sup, base); + +sup.stack = 'str'; +sup.prop = 123; +console.log(hop(sup, 'stack')); +console.log(hop(sup, 'prop'));