├── .editorconfig ├── .eslintignore ├── .eslintrc.js ├── .gitattributes ├── .gitconfig ├── .github └── workflows │ └── node.js.yml ├── .gitignore ├── .husky └── pre-commit ├── LICENSE ├── README.md ├── build ├── api │ ├── errors │ │ ├── exceptionConstructor.d.ts │ │ ├── exceptionConstructor.js │ │ ├── exceptionConstructor.js.map │ │ ├── index.d.ts │ │ ├── index.js │ │ ├── index.js.map │ │ ├── throwModificationError.d.ts │ │ ├── throwModificationError.js │ │ └── throwModificationError.js.map │ ├── hooks │ │ ├── flowCheckers.d.ts │ │ ├── flowCheckers.js │ │ ├── flowCheckers.js.map │ │ ├── index.d.ts │ │ ├── index.js │ │ ├── index.js.map │ │ ├── invokeHook.d.ts │ │ ├── invokeHook.js │ │ ├── invokeHook.js.map │ │ ├── registerHook.d.ts │ │ ├── registerHook.js │ │ └── registerHook.js.map │ ├── index.d.ts │ ├── index.js │ ├── index.js.map │ ├── types │ │ ├── InstanceCreator.d.ts │ │ ├── InstanceCreator.js │ │ ├── InstanceCreator.js.map │ │ ├── InstanceModificator.d.ts │ │ ├── InstanceModificator.js │ │ ├── InstanceModificator.js.map │ │ ├── Mnemosyne.d.ts │ │ ├── Mnemosyne.js │ │ ├── Mnemosyne.js.map │ │ ├── TypeProxy.d.ts │ │ ├── TypeProxy.js │ │ ├── TypeProxy.js.map │ │ ├── addProps.d.ts │ │ ├── addProps.js │ │ ├── addProps.js.map │ │ ├── compileNewModificatorFunctionBody.d.ts │ │ ├── compileNewModificatorFunctionBody.js │ │ ├── compileNewModificatorFunctionBody.js.map │ │ ├── createInstanceModificator.d.ts │ │ ├── createInstanceModificator.js │ │ ├── createInstanceModificator.js.map │ │ ├── index.d.ts │ │ ├── index.js │ │ ├── index.js.map │ │ ├── obeyConstructor.d.ts │ │ ├── obeyConstructor.js │ │ └── obeyConstructor.js.map │ └── utils │ │ ├── index.d.ts │ │ ├── index.js │ │ └── index.js.map ├── constants │ ├── index.d.ts │ ├── index.js │ └── index.js.map ├── descriptors │ ├── errors │ │ ├── index.d.ts │ │ ├── index.js │ │ └── index.js.map │ ├── index.d.ts │ ├── index.js │ ├── index.js.map │ └── types │ │ ├── index.d.ts │ │ ├── index.js │ │ └── index.js.map ├── index.d.ts ├── index.js ├── index.js.map ├── types │ ├── index.d.ts │ ├── index.js │ └── index.js.map └── utils │ ├── collectConstructors.d.ts │ ├── collectConstructors.js │ ├── collectConstructors.js.map │ ├── defineStackCleaner.d.ts │ ├── defineStackCleaner.js │ ├── defineStackCleaner.js.map │ ├── extract.d.ts │ ├── extract.js │ ├── extract.js.map │ ├── hop.d.ts │ ├── hop.js │ ├── hop.js.map │ ├── index.d.ts │ ├── index.js │ ├── index.js.map │ ├── merge.d.ts │ ├── merge.js │ ├── merge.js.map │ ├── parent.d.ts │ ├── parent.js │ ├── parent.js.map │ ├── parse.d.ts │ ├── parse.js │ ├── parse.js.map │ ├── pick.d.ts │ ├── pick.js │ ├── pick.js.map │ ├── toJSON.d.ts │ ├── toJSON.js │ └── toJSON.js.map ├── examples ├── AsyncNewTest.js ├── ClassReName.js └── v8bug.js ├── jest.config.js ├── module ├── .eslintrc ├── index.js └── package.json ├── package-lock.json ├── package.json ├── src ├── api │ ├── errors │ │ ├── exceptionConstructor.ts │ │ ├── index.ts │ │ └── throwModificationError.ts │ ├── hooks │ │ ├── flowCheckers.ts │ │ ├── index.ts │ │ ├── invokeHook.ts │ │ └── registerHook.ts │ ├── index.ts │ ├── types │ │ ├── InstanceCreator.ts │ │ ├── InstanceModificator.ts │ │ ├── Mnemosyne.ts │ │ ├── TypeProxy.ts │ │ ├── addProps.ts │ │ ├── compileNewModificatorFunctionBody.ts │ │ ├── createInstanceModificator.ts │ │ ├── index.ts │ │ └── obeyConstructor.ts │ └── utils │ │ └── index.ts ├── constants │ └── index.ts ├── descriptors │ ├── errors │ │ └── index.ts │ ├── index.ts │ └── types │ │ └── index.ts ├── index.ts ├── types │ └── index.ts └── utils │ ├── collectConstructors.ts │ ├── defineStackCleaner.ts │ ├── extract.ts │ ├── hop.ts │ ├── index.ts │ ├── merge.ts │ ├── parent.ts │ ├── parse.ts │ ├── pick.ts │ └── toJSON.ts ├── test-jest └── index.ts ├── test-ts ├── test-decorate.js ├── test-decorate.ts ├── test-example.ts ├── test-no-types.js └── test-no-types.ts ├── test ├── .eslintrc.js ├── async.chain.js ├── bindProtoMethods.js ├── boundMethodErrorHandler.js ├── createInstanceModificator200XthWay.js ├── decorate.js ├── decorate.ts ├── doc.example.js ├── environment.js ├── example.js ├── hooks.js ├── index.js ├── instance.proto.js ├── nested.js ├── nested.more.js ├── parse.js ├── parseSamples.js ├── perf.js ├── test.mjs ├── throw-type-error.js └── uncaughtExceptionTest.js ├── tsconfig.jest.json └── tsconfig.json /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: https://EditorConfig.org 2 | 3 | root = true 4 | 5 | [*] 6 | trim_trailing_whitespace = false 7 | indent_style = tab 8 | indent_size = 4 9 | end_of_line = lf 10 | charset = utf-8 11 | insert_final_newline = true 12 | 13 | [{package*.json,*.yml}] 14 | indent_style = space 15 | indent_size = 2 16 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | test/example.js 2 | test/decorate.js 3 | build/**/*.d.ts 4 | .eslintrc.js 5 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | parser: "@typescript-eslint/parser", 3 | env: { 4 | node: true, 5 | es6: true, 6 | mocha: true, 7 | }, 8 | extends: [ 9 | 'eslint:recommended', 10 | 'plugin:@typescript-eslint/eslint-recommended', 11 | 'plugin:@typescript-eslint/recommended' 12 | ], 13 | parserOptions: { 14 | ecmaVersion: 2018, 15 | sourceType: 'module' 16 | }, 17 | plugins: [ 18 | 'mocha', 19 | 'eslint-plugin-no-arrow-this', 20 | '@typescript-eslint' 21 | ], 22 | rules: { 23 | 'indent': [ 'error', 'tab' ], 24 | 'key-spacing': [ 25 | 'warn', 26 | { 27 | beforeColon: true, 28 | afterColon: true, 29 | align: 'colon', 30 | }, 31 | ], 32 | 'linebreak-style': [ 'error', 'unix' ], 33 | 'quotes': [ 'error', 'single' ], 34 | 'semi': [ 'error', 'always' ], 35 | 'no-unused-vars': 'off', 36 | '@typescript-eslint/no-unused-vars': 'error', 37 | 'no-shadow': [ 38 | 'error', 39 | { 40 | builtinGlobals: true, 41 | hoist: 'all', 42 | allow: [], 43 | }, 44 | ], 45 | 'array-bracket-spacing': [ 'error', 'always' ], 46 | 'computed-property-spacing': [ 'error', 'always' ], 47 | 'object-curly-spacing': [ 'error', 'always' ], 48 | 'space-before-function-paren': [ 49 | 'error', { 50 | 'anonymous': 'always', 51 | 'named': 'always', 52 | 'asyncArrow': 'always' 53 | } 54 | ], 55 | 'prefer-template': 'warn', 56 | 'prefer-spread': 'warn', 57 | 'no-useless-concat': 'warn', 58 | 'prefer-rest-params': 'warn', 59 | 'prefer-destructuring': 'warn', 60 | 'no-useless-computed-key': 'warn', 61 | 'no-useless-constructor': 'warn', 62 | 'no-useless-rename': 'warn', 63 | 'no-this-before-super': 'warn', 64 | 'no-new-symbol': 'warn', 65 | 'no-duplicate-imports': 'warn', 66 | 'no-confusing-arrow': 'warn', 67 | 'no-multi-assign': 'warn', 68 | 'no-lonely-if': 'warn', 69 | 'newline-per-chained-call': 'warn', 70 | 'new-cap': 'warn', 71 | 'func-name-matching': 'error', 72 | // 'consistent-this' : 'error', 73 | 'line-comment-position': [ 74 | 'warn', 75 | { 76 | position: 'above', 77 | }, 78 | ], 79 | 'no-arrow-this/no-arrow-this': [ 80 | 'error', 81 | { 82 | onlyGlobals: true, 83 | }, 84 | ], 85 | '@typescript-eslint/no-var-requires': 'off', 86 | '@typescript-eslint/no-empty-function': 'off', 87 | '@typescript-eslint/no-explicit-any': 'off', 88 | yoda: 'warn', 89 | }, 90 | overrides: [ { 91 | files: [ 'build/**/*.js' ], 92 | rules: { 93 | 'no-multi-assign': 0, 94 | '@typescript-eslint/no-this-alias': 0, 95 | 'prefer-destructuring': 0, 96 | 'new-cap': 0 97 | } 98 | } ] 99 | }; 100 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | 2 | # Automatically normalize line endings for all text-based files 3 | # http://git-scm.com/docs/gitattributes#_end_of_line_conversion 4 | 5 | # For the following file types, normalize line endings to LF on 6 | # checkin and prevent conversion to CRLF when they are checked out 7 | # (this is required in order to prevent newline related issues like, 8 | # for example, after the build script is run) 9 | *.html text eol=lf 10 | *.css text eol=lf 11 | *.less text eol=lf 12 | *.scss text eol=lf 13 | *.sss text eol=lf 14 | *.sass text eol=lf 15 | *.js text eol=lf 16 | *.json text eol=lf 17 | *.yml text eol=lf 18 | *.yaml text eol=lf 19 | *.md text eol=lf 20 | *.sh text eol=lf 21 | *.txt text eol=lf 22 | *.xml text eol=lf 23 | -------------------------------------------------------------------------------- /.gitconfig: -------------------------------------------------------------------------------- 1 | [core] 2 | hooksPath = .husky/_ 3 | -------------------------------------------------------------------------------- /.github/workflows/node.js.yml: -------------------------------------------------------------------------------- 1 | # This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions 3 | 4 | name: Node.js CI 5 | 6 | on: 7 | push: 8 | branches: [ master, proto ] 9 | pull_request: 10 | branches: [ master, proto ] 11 | 12 | jobs: 13 | build: 14 | 15 | runs-on: ubuntu-latest 16 | 17 | strategy: 18 | matrix: 19 | node-version: [18.x, 20.x, 22.x] 20 | 21 | steps: 22 | - uses: actions/checkout@v2 23 | - name: Use Node.js ${{ matrix.node-version }} 24 | uses: actions/setup-node@v1 25 | with: 26 | node-version: ${{ matrix.node-version }} 27 | - run: npm ci 28 | - run: npm run build --if-present 29 | - run: npm test 30 | 31 | 32 | test: 33 | runs-on: ubuntu-latest 34 | 35 | steps: 36 | - uses: actions/checkout@master 37 | - name: Use Node.js 20.x 38 | uses: actions/setup-node@master 39 | with: 40 | node-version: 20.x 41 | 42 | - name: npm install 43 | run: npm install 44 | 45 | - name: Test 46 | run: npm run test:cov 47 | 48 | - name: Coveralls Start Parallel Build 49 | uses: coverallsapp/github-action@master 50 | with: 51 | github-token: ${{ secrets.GITHUB_TOKEN }} 52 | debug: true 53 | parallel: true 54 | 55 | finish: 56 | needs: test 57 | runs-on: ubuntu-latest 58 | steps: 59 | - name: Coveralls Finish Build 60 | uses: coverallsapp/github-action@master 61 | with: 62 | github-token: ${{ secrets.GITHUB_TOKEN }} 63 | debug: true 64 | parallel-finished: true 65 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | npm-debug.log 3 | .env 4 | todo.txt 5 | back.* 6 | coverage 7 | coveragejest 8 | .nyc_output 9 | .idea 10 | test/example.js 11 | .npmrc 12 | .vscode 13 | -------------------------------------------------------------------------------- /.husky/pre-commit: -------------------------------------------------------------------------------- 1 | #npm run build 2 | #npx lint-staged 3 | #npm run test:cov 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 https://github.com/wentout 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /build/api/errors/exceptionConstructor.d.ts: -------------------------------------------------------------------------------- 1 | declare const prepareException: (this: any, target: any, error: Error, ...args: any[]) => any; 2 | export default prepareException; 3 | -------------------------------------------------------------------------------- /build/api/errors/exceptionConstructor.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | const constants_1 = require("../../constants"); 4 | const { odp } = constants_1.constants; 5 | const errors_1 = require("../../descriptors/errors"); 6 | const { WRONG_ARGUMENTS_USED, WRONG_INSTANCE_INVOCATION } = errors_1.ErrorsTypes; 7 | const errors_2 = require("../errors"); 8 | const utils_1 = require("../../utils"); 9 | const { parse } = utils_1.utils; 10 | const utils_2 = require("../utils"); 11 | const { makeFakeModificatorType } = utils_2.default; 12 | const InstanceModificator_1 = require("../types/InstanceModificator"); 13 | const checkThrowArgs = (instance, target, error, args) => { 14 | let wrongThrow; 15 | if (!target) { 16 | throw new WRONG_INSTANCE_INVOCATION('exception should be made with new keyword'); 17 | } 18 | if (!(error instanceof Error)) { 19 | wrongThrow = new WRONG_ARGUMENTS_USED('error must be instanceof Error'); 20 | } 21 | if (!(wrongThrow instanceof Error)) { 22 | return; 23 | } 24 | odp(wrongThrow, 'instance', { 25 | get() { 26 | return instance; 27 | } 28 | }); 29 | odp(wrongThrow, 'error', { 30 | get() { 31 | return error; 32 | } 33 | }); 34 | odp(wrongThrow, 'args', { 35 | get() { 36 | return args; 37 | } 38 | }); 39 | throw wrongThrow; 40 | }; 41 | const exceptionConsctructHandler = function (opts) { 42 | const { instance, TypeName, typeStack, args, error } = opts; 43 | const exception = this; 44 | odp(exception, 'args', { 45 | get() { 46 | return args; 47 | } 48 | }); 49 | odp(exception, 'originalError', { 50 | get() { 51 | return error; 52 | } 53 | }); 54 | odp(exception, 'instance', { 55 | get() { 56 | return instance; 57 | } 58 | }); 59 | odp(exception, 'extract', { 60 | get() { 61 | return () => { 62 | return instance.extract(); 63 | }; 64 | } 65 | }); 66 | odp(exception, 'parse', { 67 | get() { 68 | return () => { 69 | return parse(instance); 70 | }; 71 | } 72 | }); 73 | const errorStack = exception.stack.split('\n'); 74 | const stack = []; 75 | const title = `\n<-- lifecycle of [ ${TypeName} ] traced -->`; 76 | errors_2.getStack.call(exception, title, [], prepareException); 77 | stack.push(...exception.stack); 78 | stack.push('<-- with the following error -->'); 79 | errorStack.forEach((line) => { 80 | if (!stack.includes(line)) { 81 | stack.push(line); 82 | } 83 | }); 84 | stack.push('\n<-- of constructor definitions stack -->'); 85 | stack.push(...typeStack); 86 | const exceptionStack = (0, errors_2.cleanupStack)(stack).join('\n'); 87 | odp(exception, 'stack', { 88 | get() { 89 | return exceptionStack; 90 | } 91 | }); 92 | return exception; 93 | }; 94 | const prepareException = function (target, error, ...args) { 95 | const instance = this; 96 | checkThrowArgs(instance, target, error, args); 97 | const { __type__, __creator__ } = instance; 98 | const { stack: typeStack, TypeName } = __type__; 99 | const ExceptionCreator = Object.create(__creator__); 100 | ExceptionCreator.config = Object.assign({}, __creator__.config); 101 | ExceptionCreator.config.blockErrors = false; 102 | ExceptionCreator.existentInstance = error; 103 | ExceptionCreator.ModificatorType = makeFakeModificatorType(TypeName, function () { 104 | return exceptionConsctructHandler.call(this, { 105 | instance, 106 | TypeName, 107 | typeStack, 108 | args, 109 | error 110 | }); 111 | }); 112 | ExceptionCreator.InstanceModificator = (0, InstanceModificator_1.makeInstanceModificator)(ExceptionCreator); 113 | return new ExceptionCreator.InstanceModificator(); 114 | }; 115 | exports.default = prepareException; 116 | //# sourceMappingURL=exceptionConstructor.js.map -------------------------------------------------------------------------------- /build/api/errors/exceptionConstructor.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"exceptionConstructor.js","sourceRoot":"","sources":["../../../src/api/errors/exceptionConstructor.ts"],"names":[],"mappings":"AAAA,YAA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AA,6CAAuB,EAAE,gBAAgB,CAAE,CAAC;IAEnF,OAAO,IAAI,gBAAgB,CAAC,mBAAmB,EAAE,CAAC;AACnD,CAAC,CAAC;AAEF,kBAAe,gBAAgB,CAAC"} -------------------------------------------------------------------------------- /build/api/errors/index.d.ts: -------------------------------------------------------------------------------- 1 | export declare const stackCleaners: RegExp[]; 2 | export declare const cleanupStack: (stack: string[]) => string[]; 3 | export declare const getStack: (this: any, title: string, stackAddition: string[], tillFunction?: CallableFunction) => any; 4 | export declare class BASE_MNEMONICA_ERROR extends Error { 5 | static [x: symbol]: String; 6 | constructor(message: string | undefined, additionalStack: string[]); 7 | } 8 | export declare const constructError: (name: string, message: string) => { 9 | prototype: { 10 | constructor: CallableFunction; 11 | }; 12 | }; 13 | -------------------------------------------------------------------------------- /build/api/errors/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.constructError = exports.BASE_MNEMONICA_ERROR = exports.getStack = exports.cleanupStack = exports.stackCleaners = void 0; 4 | const constants_1 = require("../../constants"); 5 | const { odp, SymbolConstructorName, MNEMONICA, ErrorMessages, } = constants_1.constants; 6 | const { BASE_ERROR_MESSAGE } = ErrorMessages; 7 | exports.stackCleaners = []; 8 | const cleanupStack = (stack) => { 9 | const cleaned = stack.reduce((arr, line) => { 10 | exports.stackCleaners.forEach(cleanerRegExp => { 11 | if (!cleanerRegExp.test(line)) { 12 | arr.push(line); 13 | } 14 | }); 15 | return arr; 16 | }, []); 17 | return cleaned.length ? cleaned : stack; 18 | }; 19 | exports.cleanupStack = cleanupStack; 20 | const getStack = function (title, stackAddition, tillFunction) { 21 | if (Error.captureStackTrace) { 22 | Error.captureStackTrace(this, tillFunction || exports.getStack); 23 | } 24 | else { 25 | this.stack = (new Error()).stack; 26 | } 27 | this.stack = this.stack.split('\n').slice(1); 28 | this.stack = (0, exports.cleanupStack)(this.stack); 29 | this.stack.unshift(title); 30 | if (Array.isArray(stackAddition) && stackAddition.length) { 31 | this.stack.push(...stackAddition); 32 | } 33 | this.stack.push('\n'); 34 | return this.stack; 35 | }; 36 | exports.getStack = getStack; 37 | class BASE_MNEMONICA_ERROR extends Error { 38 | constructor(message = BASE_ERROR_MESSAGE, additionalStack) { 39 | super(message); 40 | const BaseStack = this.stack; 41 | odp(this, 'BaseStack', { 42 | get() { 43 | return BaseStack; 44 | } 45 | }); 46 | const stack = (0, exports.cleanupStack)(BaseStack.split('\n')); 47 | if (additionalStack) { 48 | stack.unshift(...additionalStack); 49 | } 50 | this.stack = stack.join('\n'); 51 | } 52 | static get [SymbolConstructorName]() { 53 | return new String(`base of : ${MNEMONICA} : errors`); 54 | } 55 | } 56 | exports.BASE_MNEMONICA_ERROR = BASE_MNEMONICA_ERROR; 57 | Object.defineProperty(BASE_MNEMONICA_ERROR.prototype.constructor, 'name', { 58 | get() { 59 | return new String('BASE_MNEMONICA_ERROR'); 60 | } 61 | }); 62 | const constructError = (name, message) => { 63 | const NamedErrorConstructor = class extends BASE_MNEMONICA_ERROR { 64 | constructor(addition, stack) { 65 | const saying = addition ? `${message} : ${addition}` : `${message}`; 66 | super(saying, stack); 67 | } 68 | }; 69 | const reNamer = {}; 70 | reNamer[name] = NamedErrorConstructor; 71 | Object.defineProperty(reNamer[name].prototype.constructor, 'name', { 72 | get() { 73 | return new String(name); 74 | } 75 | }); 76 | return reNamer[name]; 77 | }; 78 | exports.constructError = constructError; 79 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /build/api/errors/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/errors/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAEb,+CAA4C;AAE5C,MAAM,EACL,GAAG,EACH,qBAAqB,EACrB,SAAS,EACT,aAAa,GACb,GAAG,qBAAS,CAAC;AAEd,MAAM,EACL,kBAAkB,EAClB,GAAG,aAAa,CAAC;AAEL,QAAA,aAAa,GAAa,EAAE,CA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AC,CAAC,CAAC,GAAG,OAAO,EAAE,CAAC;YACpE,KAAK,CAAE,MAAM,EAAE,KAAK,CAAE,CAAC;QACxB,CAAC;KACD,CAAC;IAEF,MAAM,OAAO,GAAG,EAMf,CAAC;IACF,OAAO,CAAE,IAAI,CAAE,GAAG,qBAAqB,CAAC;IACxC,MAAM,CAAC,cAAc,CAAE,OAAO,CAAE,IAAI,CAAE,CAAC,SAAS,CAAC,WAAW,EAAE,MAAM,EAAE;QACrE,GAAG;YACF,OAAO,IAAI,MAAM,CAAE,IAAI,CAAE,CAAC;QAC3B,CAAC;KACD,CAAE,CAAC;IACJ,OAAO,OAAO,CAAE,IAAI,CAAE,CAAC;AACxB,CAAC,CAAC;AAtBW,QAAA,cAAc,kBAsBzB"} -------------------------------------------------------------------------------- /build/api/errors/throwModificationError.d.ts: -------------------------------------------------------------------------------- 1 | export declare const throwModificationError: (this: any, error: any) => void; 2 | -------------------------------------------------------------------------------- /build/api/errors/throwModificationError.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.throwModificationError = void 0; 4 | const constants_1 = require("../../constants"); 5 | const { odp, SymbolReplaceUranus, } = constants_1.constants; 6 | const errors_1 = require("../../descriptors/errors"); 7 | const { BASE_MNEMONICA_ERROR } = errors_1.ErrorsTypes; 8 | const _1 = require("./"); 9 | const utils_1 = require("../utils"); 10 | const { makeFakeModificatorType } = utils_1.default; 11 | const utils_2 = require("../../utils"); 12 | const { parse } = utils_2.utils; 13 | const InstanceModificator_1 = require("../types/InstanceModificator"); 14 | const throwModificationError = function (error) { 15 | const self = this; 16 | const { TypeName, type: { stack: typeStack }, args } = self; 17 | const exceptionReason = error.exceptionReason || error; 18 | if (error.exceptionReason !== undefined) { 19 | error.reasons.push(error.exceptionReason); 20 | error.surplus.push(error); 21 | throw error; 22 | } 23 | odp(error, 'exceptionReason', { 24 | get() { 25 | return exceptionReason; 26 | }, 27 | enumerable: true 28 | }); 29 | const reasons = [exceptionReason]; 30 | odp(error, 'reasons', { 31 | get() { 32 | return reasons; 33 | }, 34 | enumerable: true 35 | }); 36 | const surplus = []; 37 | odp(error, 'surplus', { 38 | get() { 39 | return surplus; 40 | }, 41 | enumerable: true 42 | }); 43 | self.ModificatorType = makeFakeModificatorType(TypeName); 44 | self.InstanceModificator = (0, InstanceModificator_1.makeInstanceModificator)(self); 45 | const erroredInstance = new self.InstanceModificator(); 46 | erroredInstance[SymbolReplaceUranus](error); 47 | const stack = []; 48 | if (error instanceof BASE_MNEMONICA_ERROR) { 49 | stack.push(error.stack); 50 | } 51 | else { 52 | const title = `\n<-- creation of [ ${TypeName} ] traced -->`; 53 | _1.getStack.call(erroredInstance, title, [], exports.throwModificationError); 54 | stack.push(...erroredInstance.stack); 55 | const errorStack = error.stack.split('\n'); 56 | stack.push('<-- with the following error -->'); 57 | errorStack.forEach((line) => { 58 | if (!stack.includes(line)) { 59 | stack.push(line); 60 | } 61 | }); 62 | stack.push('\n<-- of constructor definitions stack -->'); 63 | stack.push(...typeStack); 64 | } 65 | const erroredInstanceStack = (0, _1.cleanupStack)(stack).join('\n'); 66 | odp(erroredInstance, 'stack', { 67 | get() { 68 | return erroredInstanceStack; 69 | } 70 | }); 71 | self.inheritedInstance = erroredInstance; 72 | const results = self.invokePostHooks(); 73 | const { type, collection, } = results; 74 | if (type.has(true) || collection.has(true)) { 75 | return; 76 | } 77 | odp(erroredInstance, 'args', { 78 | get() { 79 | return args; 80 | } 81 | }); 82 | odp(erroredInstance, 'originalError', { 83 | get() { 84 | return error; 85 | } 86 | }); 87 | odp(erroredInstance, 'instance', { 88 | get() { 89 | return erroredInstance; 90 | } 91 | }); 92 | odp(erroredInstance, 'extract', { 93 | get() { 94 | return () => { 95 | return erroredInstance.__self__.extract(); 96 | }; 97 | } 98 | }); 99 | odp(erroredInstance, 'parse', { 100 | get() { 101 | return () => { 102 | return parse(erroredInstance); 103 | }; 104 | } 105 | }); 106 | throw erroredInstance; 107 | }; 108 | exports.throwModificationError = throwModificationError; 109 | //# sourceMappingURL=throwModificationError.js.map -------------------------------------------------------------------------------- /build/api/errors/throwModificationError.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"throwModificationError.js","sourceRoot":"","sources":["../../../src/api/errors/throwModificationError.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAEb,+CAA4C;AAC5C,MAAM,EACL,GAAG,EACH,mBAAmB,GAEnB,GAAG,qBAAS,CAAC;AAEd,qDAAuD;AACvD,MAAM,EACL,oBAAoB,EACpB,GAAG,oBAAW,CAAC;AAEhB,yBAA4C;AAE5C,oCAAkC;AAClC,MAAM,EACL,uBAAuB,EACvB,GAAG,eAAU,CAAC;AAEf,uCAAoC;AACpC,MAAM,EACL,KAAK,EACL,GAAG,aAAK,CAAC;AAEV,sEAAuE;AAEhE,MAAM,sBAAsB,GAAG,UAAsB,KAAU;IAIrE,MAAM,IAAI,GAAG,IAAI,CAAC;IAElB,MAAM,EACL,QAAQ,EACR,IAAI,EAAE,EACL,KAAK,EAAE,SAAS,EAChB,EACD,IAAI,EACJ,GAAG,IAAI,CAAC;IAMT,MAAM,eAAe,GAAG,KAAK,CAAC,eAAe,IAAI,KAAK,CAAC;IAEvD,IAAK,KAAK,CAAC,eAAe,KAAK,SAAS,EAAG,CAAC;QAE3C,KAAK,CAAC,OAAO,CAAC,IAAI,CAAE,KAAK,CAAC,eAAe,CAAE,CAAC;QAC5C,KAAK,CAAC,OAAO,CAAC,IAAI,CAAE,KAAK,CAAE,CAAC;QAE5B,MAAM,KAAK,CAAC;IAEb,CAAC;IAED,GAAG,CAAE,KAAK,EAAE,iBAAiB,EAAE;QAC9B,GAAG;YACF,OAAO,eAAe,CAAC;QACxB,CAAC;QACD,UAAU,EAAG,IAAI;KACjB,CAAE,CAAC;IAEJ,MAAM,OAAO,GAAkC,CAAE,eAAe,CAAE,CAAC;IAEnE,GAAG,CAAE,KAAK,EAAE,SAAS,EAAE;QACtB,GAAG;YACF,OAAO,O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;KACD,CAAE,CAAC;IAEJ,MAAM,eAAe,CAAC;AAEvB,CAAC,CAAC;AAzJW,QAAA,sBAAsB,0BAyJjC"} -------------------------------------------------------------------------------- /build/api/hooks/flowCheckers.d.ts: -------------------------------------------------------------------------------- 1 | export declare const flowCheckers: WeakMap; 2 | export declare const registerFlowChecker: (this: any, cb: () => unknown) => void; 3 | -------------------------------------------------------------------------------- /build/api/hooks/flowCheckers.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.registerFlowChecker = exports.flowCheckers = void 0; 4 | const errors_1 = require("../../descriptors/errors"); 5 | const { MISSING_CALLBACK_ARGUMENT, FLOW_CHECKER_REDEFINITION, } = errors_1.ErrorsTypes; 6 | exports.flowCheckers = new WeakMap(); 7 | const registerFlowChecker = function (cb) { 8 | if (typeof cb !== 'function') { 9 | throw new MISSING_CALLBACK_ARGUMENT; 10 | } 11 | if (exports.flowCheckers.has(this)) { 12 | throw new FLOW_CHECKER_REDEFINITION; 13 | } 14 | exports.flowCheckers.set(this, cb); 15 | }; 16 | exports.registerFlowChecker = registerFlowChecker; 17 | //# sourceMappingURL=flowCheckers.js.map -------------------------------------------------------------------------------- /build/api/hooks/flowCheckers.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"flowCheckers.js","sourceRoot":"","sources":["../../../src/api/hooks/flowCheckers.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAEb,qDAAuD;AACvD,MAAM,EACL,yBAAyB,EACzB,yBAAyB,GACzB,GAAG,oBAAW,CAAC;AAEH,QAAA,YAAY,GAAG,IAAI,OAAO,EAAE,CAAC;AACnC,MAAM,mBAAmB,GAAG,UAAqB,EAAiB;IAExE,IAAK,OAAO,EAAE,KAAK,UAAU,EAAG,CAAC;QAChC,MAAM,IAAI,yBAAyB,CAAC;IACrC,CAAC;IAED,IAAK,oBAAY,CAAC,GAAG,CAAE,IAAI,CAAE,EAAG,CAAC;QAChC,MAAM,IAAI,yBAAyB,CAAC;IACrC,CAAC;IAED,oBAAY,CAAC,GAAG,CAAE,IAAI,EAAE,EAAE,CAAE,CAAC;AAE9B,CAAC,CAAC;AAZW,QAAA,mBAAmB,uBAY9B"} -------------------------------------------------------------------------------- /build/api/hooks/index.d.ts: -------------------------------------------------------------------------------- 1 | export { invokeHook } from './invokeHook'; 2 | export { registerHook } from './registerHook'; 3 | export { registerFlowChecker } from './flowCheckers'; 4 | -------------------------------------------------------------------------------- /build/api/hooks/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.registerFlowChecker = exports.registerHook = exports.invokeHook = void 0; 4 | var invokeHook_1 = require("./invokeHook"); 5 | Object.defineProperty(exports, "invokeHook", { enumerable: true, get: function () { return invokeHook_1.invokeHook; } }); 6 | var registerHook_1 = require("./registerHook"); 7 | Object.defineProperty(exports, "registerHook", { enumerable: true, get: function () { return registerHook_1.registerHook; } }); 8 | var flowCheckers_1 = require("./flowCheckers"); 9 | Object.defineProperty(exports, "registerFlowChecker", { enumerable: true, get: function () { return flowCheckers_1.registerFlowChecker; } }); 10 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /build/api/hooks/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/hooks/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAEb,2CAA0C;AAAjC,wGAAA,UAAU,OAAA;AACnB,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AACrB,+CAAqD;AAA5C,mHAAA,mBAAmB,OAAA"} -------------------------------------------------------------------------------- /build/api/hooks/invokeHook.d.ts: -------------------------------------------------------------------------------- 1 | export declare const invokeHook: (this: any, hookType: string, opts: { 2 | [index: string]: any; 3 | }) => Set; 4 | -------------------------------------------------------------------------------- /build/api/hooks/invokeHook.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.invokeHook = void 0; 4 | const constants_1 = require("../../constants"); 5 | const { MNEMONICA, } = constants_1.constants; 6 | const flowCheckers_1 = require("./flowCheckers"); 7 | const hop_1 = require("../../utils/hop"); 8 | const invokeHook = function (hookType, opts) { 9 | const { type, existentInstance, inheritedInstance, args, creator } = opts; 10 | const invocationResults = new Set(); 11 | const self = this; 12 | if ((0, hop_1.hop)(self.hooks, hookType)) { 13 | const { TypeName, } = type; 14 | const hookArgs = { 15 | type, 16 | TypeName, 17 | existentInstance: existentInstance.constructor.name === MNEMONICA ? 18 | null : existentInstance, 19 | args, 20 | }; 21 | if (typeof inheritedInstance === 'object') { 22 | Object.assign(hookArgs, { 23 | inheritedInstance, 24 | throwModificationError(error) { 25 | creator.throwModificationError(error); 26 | } 27 | }); 28 | } 29 | this.hooks[hookType].forEach((hook) => { 30 | const result = hook.call(self, hookArgs); 31 | invocationResults.add(result); 32 | }); 33 | const flowChecker = flowCheckers_1.flowCheckers.get(this); 34 | if (typeof flowChecker === 'function') { 35 | flowChecker 36 | .call(this, Object.assign({}, { 37 | invocationResults, 38 | hookType, 39 | }, hookArgs)); 40 | } 41 | } 42 | return invocationResults; 43 | }; 44 | exports.invokeHook = invokeHook; 45 | //# sourceMappingURL=invokeHook.js.map -------------------------------------------------------------------------------- /build/api/hooks/invokeHook.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"invokeHook.js","sourceRoot":"","sources":["../../../src/api/hooks/invokeHook.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAEb,+CAA4C;AAC5C,MAAM,EACL,SAAS,GACT,GAAG,qBAAS,CAAC;AAEd,iDAA8C;AAE9C,yCAAsC;AAE/B,MAAM,UAAU,GAAG,UAAsB,QAAgB,EAAE,IAAgC;IAEjG,MAAM,EACL,IAAI,EACJ,gBAAgB,EAChB,iBAAiB,EACjB,IAAI,EAEJ,OAAO,EACP,GAAG,IAAI,CAAC;IAET,MAAM,iBAAiB,GAAG,IAAI,GAAG,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Hook.d.ts: -------------------------------------------------------------------------------- 1 | export declare const registerHook: (this: any, hookType: string, cb: CallableFunction) => void; 2 | -------------------------------------------------------------------------------- /build/api/hooks/registerHook.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.registerHook = void 0; 4 | const errors_1 = require("../../descriptors/errors"); 5 | const { WRONG_HOOK_TYPE, MISSING_HOOK_CALLBACK, } = errors_1.ErrorsTypes; 6 | const hooksTypes = [ 7 | 'preCreation', 8 | 'postCreation', 9 | 'creationError', 10 | ]; 11 | const registerHook = function (hookType, cb) { 12 | if (!hooksTypes.includes(hookType)) { 13 | throw new WRONG_HOOK_TYPE; 14 | } 15 | if (typeof cb !== 'function') { 16 | throw new MISSING_HOOK_CALLBACK; 17 | } 18 | if (!this.hooks[hookType]) { 19 | this.hooks[hookType] = new Set([cb]); 20 | } 21 | else { 22 | this.hooks[hookType].add(cb); 23 | } 24 | }; 25 | exports.registerHook = registerHook; 26 | //# sourceMappingURL=registerHook.js.map -------------------------------------------------------------------------------- /build/api/hooks/registerHook.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"registerHook.js","sourceRoot":"","sources":["../../../src/api/hooks/registerHook.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAEb,qDAAuD;AACvD,MAAM,EACL,eAAe,EACf,qBAAqB,GACrB,GAAG,oBAAW,CAAC;AAEhB,MAAM,UAAU,GAAG;IAClB,aAAa;IACb,cAAc;IACd,eAAe;CACf,CAAC;AAEK,MAAM,YAAY,GAAG,UAAsB,QAAgB,EAAE,EAAoB;IAEvF,IAAK,CAAC,UAAU,CAAC,QAAQ,CAAE,QAAQ,CAAE,EAAG,CAAC;QACxC,MAAM,IAAI,eAAe,CAAC;IAC3B,CAAC;IAED,IAAK,OAAO,EAAE,KAAK,UAAU,EAAG,CAAC;QAChC,MAAM,IAAI,qBAAqB,CAAC;IACjC,CAAC;IAED,IAAK,CAAC,IAAI,CAAC,KAAK,CAAE,QAAQ,CAAE,EAAG,CAAC;QAC/B,IAAI,CAAC,KAAK,CAAE,QAAQ,CAAE,GAAG,IAAI,GAAG,CAAE,CAAE,EAAE,CAAE,CAAE,CAAC;IAC5C,CAAC;SAAM,CAAC;QACP,IAAI,CAAC,KAAK,CAAE,QAAQ,CAAE,CAAC,GAAG,CAAE,EAAE,CAAE,CAAC;IAClC,CAAC;AAEF,CAAC,CAAC;AAhBW,QAAA,YAAY,gBAgBvB"} -------------------------------------------------------------------------------- /build/api/index.d.ts: -------------------------------------------------------------------------------- 1 | export * as errors from './errors'; 2 | export declare const hooks: { 3 | invokeHook: (this: any, hookType: string, opts: { 4 | [index: string]: any; 5 | }) => Set; 6 | registerHook: (this: any, hookType: string, cb: CallableFunction) => void; 7 | registerFlowChecker: (this: any, cb: () => unknown) => void; 8 | }; 9 | export declare const types: { 10 | define: any; 11 | lookup: any; 12 | }; 13 | -------------------------------------------------------------------------------- /build/api/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.types = exports.hooks = exports.errors = void 0; 4 | const hooks_1 = require("./hooks"); 5 | const types_1 = require("./types"); 6 | exports.errors = require("./errors"); 7 | exports.hooks = { 8 | invokeHook: hooks_1.invokeHook, 9 | registerHook: hooks_1.registerHook, 10 | registerFlowChecker: hooks_1.registerFlowChecker, 11 | }; 12 | exports.types = { 13 | define: types_1.define, 14 | lookup: types_1.lookup, 15 | }; 16 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /build/api/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAUb,mCAIiB;AACjB,mCAGiB;AAEjB,qCAAmC;AAEtB,QAAA,KAAK,GAAG;IACpB,UAAU,EAAV,kBAAU;IACV,YAAY,EAAZ,oBAAY;IACZ,mBAAmB,EAAnB,2BAAmB;CACnB,CAAC;AAEW,QAAA,KAAK,GAAG;IACpB,MAAM,EAAN,cAAM;IACN,MAAM,EAAN,cAAM;CACN,CAAC"} -------------------------------------------------------------------------------- /build/api/types/InstanceCreator.d.ts: -------------------------------------------------------------------------------- 1 | import { ConstructorFunction } from '../../types'; 2 | declare const InstanceCreatorPrototype: { 3 | getExistentAsyncStack: (existentInstance: import("../utils").asyncStack) => unknown; 4 | postProcessing: (this: any, continuationOf: any) => void; 5 | makeAwaiter: (this: any, type: any, then: any) => any; 6 | addProps: (this: any) => any; 7 | addThen: (this: any, then: any) => void; 8 | invokePreHooks: (this: any) => void; 9 | invokePostHooks: (this: any) => { 10 | type: any; 11 | collection: any; 12 | }; 13 | throwModificationError: (this: any, error: any) => void; 14 | }; 15 | export declare const InstanceCreator: ConstructorFunction; 16 | export {}; 17 | -------------------------------------------------------------------------------- /build/api/types/InstanceModificator.d.ts: -------------------------------------------------------------------------------- 1 | export declare const makeInstanceModificator: (self: any) => any; 2 | -------------------------------------------------------------------------------- /build/api/types/InstanceModificator.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.makeInstanceModificator = void 0; 4 | const addProps_1 = require("./addProps"); 5 | const makeInstanceModificator = (self) => { 6 | const { ModificationConstructor, existentInstance, ModificatorType, proto, } = self; 7 | const result = ModificationConstructor.call(existentInstance, ModificatorType, Object.assign({}, proto), (__proto_proto__) => { 8 | self.__proto_proto__ = __proto_proto__; 9 | addProps_1.addProps.call(self); 10 | }); 11 | return result; 12 | }; 13 | exports.makeInstanceModificator = makeInstanceModificator; 14 | //# sourceMappingURL=InstanceModificator.js.map -------------------------------------------------------------------------------- /build/api/types/InstanceModificator.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"InstanceModificator.js","sourceRoot":"","sources":["../../../src/api/types/InstanceModificator.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAEb,yCAAsC;AAE/B,MAAM,uBAAuB,GAAG,CAAE,IAAS,EAAG,EAAE;IAEtD,MAAM,EACL,uBAAuB,EACvB,gBAAgB,EAChB,eAAe,EACf,KAAK,GACL,GAAG,IAAI,CAAC;IAET,MAAM,MAAM,GAAG,uBAAuB,CAAC,IAAI,CAC1C,gBAAgB,EAChB,eAAe,EACf,MAAM,CAAC,MAAM,CAAE,EAAE,EAAE,KAAK,CAAE,EAC1B,CAAE,eAAoB,EAAG,EAAE;QAC1B,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,mBAAQ,CAAC,IAAI,CAAE,IAAI,CAAE,CAAC;IACvB,CAAC,CACD,CAAC;IAEF,OAAO,MAAM,CAAC;AACf,CAAC,CAAC;AApBW,QAAA,uBAAuB,2BAoBlC"} -------------------------------------------------------------------------------- /build/api/types/Mnemosyne.d.ts: -------------------------------------------------------------------------------- 1 | import { ConstructorFunction } from '../../types'; 2 | declare const _default: { 3 | Gaia: ConstructorFunction; 4 | Mnemosyne: ConstructorFunction<{ 5 | [x: symbol]: (() => (this: any, uranus: any) => void) | (() => string); 6 | extract(): (this: any) => { 7 | [index: string]: any; 8 | }; 9 | pick(): (this: any, ...args: any[]) => { 10 | [index: string]: any; 11 | }; 12 | parent(): (this: any, constructorLookupPath: string) => any; 13 | clone(this: any): any; 14 | fork(this: any): (this: any, ...forkArgs: any[]) => any; 15 | exception(): (error: Error, ...args: any[]) => any; 16 | sibling(): (SiblingTypeName: string) => any; 17 | }>; 18 | readonly MnemosynePrototypeKeys: string[]; 19 | }; 20 | export default _default; 21 | -------------------------------------------------------------------------------- /build/api/types/Mnemosyne.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"Mnemosyne.js","sourceRoot":"","sources":["../../../src/api/types/Mnemosyne.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAGb,+CAA4C;AAC5C,MAAM,EACL,GAAG,EACH,qBAAqB,EACrB,UAAU,EACV,mBAAmB,EAEnB,SAAS,EACT,IAAI,EACJ,MAAM,EAEN,GAAG,qBAA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CAAE,CAAC,OAAO,CAAE,CAAE,MAAc,EAAG,EAAE;QACjF,GAAG,CAAE,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE;YACjC,GAAG;gBACF,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAE,mBAAmB,EAAE,MAAM,CAAE,CAAC;gBAGhE,OAAO,YAAY,CAAC,IAAI,CAAE,IAAI,CAAE,CAAC;YAClC,CAAC;SACD,CAAE,CAAC;IACL,CAAC,CAAE,CAAC;IAGJ,GAAG,CAAE,SAAS,CAAC,SAAS,EAAE,MAAM,CAAC,WAAW,EAAE;QAC7C,GAAG;YACF,OAAO,cAAc,CAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAE,CAAC;QAChD,CAAC;KACD,CAAE,CAAC;IAEJ,GAAG,CAAE,SAAS,CAAC,SAAS,EAAE,UAAU,EAAE;QACrC,GAAG;YACF,OAAO,IAAI,CAAC;QACb,CAAC;KACD,CAAE,CAAC;IAEJ,MAAM,KAAK,GAAG,IAAI,SAAS,EAAE,CAAC;IAE9B,UAAU,CAAC,GAAG,CAAE,QAAQ,EAAE,KAAK,CAAE,CAAC;IAElC,OAAO,CAAC,cAAc,CAAE,QAAQ,EAAE,KAAK,CAAE,CAAC;AAE3C,CAAoD,CAAC;AAGrD,kBAAe;IACd,IAAI;IACJ,SAAS;IACT,IAAI,sBAAsB;QACzB,OAAO,MAAM,CAAC,IAAI,CAAE,mBAAmB,CAAE,CAAC;IAC3C,CAAC;CACD,CAAC"} -------------------------------------------------------------------------------- /build/api/types/TypeProxy.d.ts: -------------------------------------------------------------------------------- 1 | import { ConstructorFunction } from '../../types'; 2 | export declare const TypeProxy: ConstructorFunction; 3 | -------------------------------------------------------------------------------- /build/api/types/TypeProxy.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"TypeProxy.js","sourceRoot":"","sources":["../../../src/api/types/TypeProxy.ts"],"names":[],"mappings":"AACA,YAAY,CAAC;;;AAIb,+CAA4C;AAC5C,MAAM,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CAAC,CAAC;QACtB,WAAW,CAAC,CAAC;YACZ,SAAS,CAAC,CAAC;YACX,qBAAqB,CAAE,QAAQ,EAAE,IAAI,CAAE,CAAC;IAE1C,OAAO,OAAO,CAAC,CAAC,CAAC,gBAAgB,CAAE,OAAO,EAAE,QAAQ,CAAE,CAAC,CAAC,CAAC,MAAM,CAAC;AACjE,CAAC,CAAC;AAEF,iBAAS,CAAC,SAAS,CAAC,SAAS,GAAG,UAAW,EAAO,EAAE,IAAW;IAI9D,MAAM,EACL,QAAQ,EAAE,IAAI,EACd,MAAM,EACN,GAAG,IAAI,CAAC;IAIT,MAAM,MAAM,GAAG,wBAAwB,CAAE,MAAM,CAAE,CAAC;IAClD,MAAM,IAAI,GAAG,IAAI,SAAS,CAAE,IAAI,IAAI,CAAE,MAAM,CAAE,CAAE,CAAC;IACjD,MAAM,SAAS,GAAG,IAAI,KAAK,CAAE,IAAI,EAAE;QAClC,GAAG,EAAG,mBAAmB;KACzB,CAAE,CAAC;IAEJ,MAAM,QAAQ,GAAG,IAAI,iCAAe,CAAE,IAAI,EAAE,SAAS,EAAE,IAAI,CAAE,CAAC;IAC9D,OAAO,QAAQ,CAAC;AAEjB,CAAC,CAAC"} -------------------------------------------------------------------------------- /build/api/types/addProps.d.ts: -------------------------------------------------------------------------------- 1 | export declare const addProps: (this: any) => any; 2 | -------------------------------------------------------------------------------- /build/api/types/addProps.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.addProps = void 0; 4 | const constants_1 = require("../../constants"); 5 | const { odp, } = constants_1.constants; 6 | const addProps = function () { 7 | const self = this; 8 | const { type, existentInstance, args, config: { submitStack }, __proto_proto__: proto } = self; 9 | const { collection, subtypes, } = type; 10 | odp(proto, '__proto_proto__', { 11 | get() { 12 | return proto; 13 | } 14 | }); 15 | odp(proto, '__args__', { 16 | get() { 17 | return args; 18 | } 19 | }); 20 | odp(proto, '__collection__', { 21 | get() { 22 | return collection; 23 | } 24 | }); 25 | odp(proto, '__subtypes__', { 26 | get() { 27 | return subtypes; 28 | } 29 | }); 30 | odp(proto, '__type__', { 31 | get() { 32 | return type; 33 | } 34 | }); 35 | odp(proto, '__parent__', { 36 | get() { 37 | return existentInstance; 38 | } 39 | }); 40 | if (submitStack) { 41 | const { stack } = this; 42 | odp(proto, '__stack__', { 43 | get() { 44 | return stack.join('\n'); 45 | } 46 | }); 47 | } 48 | odp(proto, '__creator__', { 49 | get() { 50 | return self; 51 | } 52 | }); 53 | const timestamp = Date.now(); 54 | odp(proto, '__timestamp__', { 55 | get() { 56 | return timestamp; 57 | } 58 | }); 59 | }; 60 | exports.addProps = addProps; 61 | module.exports = { 62 | addProps: exports.addProps 63 | }; 64 | //# sourceMappingURL=addProps.js.map -------------------------------------------------------------------------------- /build/api/types/addProps.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"addProps.js","sourceRoot":"","sources":["../../../src/api/types/addProps.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAEb,+CAA4C;AAE5C,MAAM,EACL,GAAG,GACH,GAAG,qBAAS,CAAC;AAEP,MAAM,QAAQ,GAAG;IAGvB,MAAM,IAAI,GAAG,IAAI,CAAC;IAElB,MAAM,EACL,IAAI,EACJ,gBAAgB,EAChB,IAAI,EACJ,MAAM,EAAE,EACP,WAAW,EACX,EACD,eAAe,EAAE,KAAK,EACtB,GAAG,IAAI,CAAC;IAET,MAAM,EACL,UAAU,EACV,QAAQ,GACR,GAAG,IAAI,CAAC;IAET,GAAG,CAAE,KAAK,EAAE,iBAAiB,EAAE;QAC9B,GAAG;YACF,OAAO,KAAK,CAAC;QACd,CAAC;KACD,CAAE,CAAC;IAEJ,GAAG,CAAE,KAAK,EAAE,UAAU,EAAE;QACvB,GAAG;YACF,OAAO,IAAI,CAAC;QACb,CAAC;KACD,CAAE,CAAC;IAEJ,GAAG,CAAE,KAAK,EAAE,gBAAgB,EAAE;QAC7B,GAAG;YACF,OAAO,UAAU,CAAC;QACnB,CAAC;KACD,CAAE,CAAC;IAEJ,GAAG,CAAE,KAAK,EAAE,cAAc,EAAE;QAC3B,GAAG;YACF,OAAO,QAAQ,CAAC;QACjB,CAAC;KACD,CAAE,CAAC;IAEJ,GAAG,CAAE,KAAK,EAAE,UAAU,EAAE;QACvB,GAAG;YACF,OAAO,IAAI,CAAC;QACb,CAAC;KACD,CAAE,CAAC;IAEJ,GAAG,CAAE,KAAK,EAAE,YAAY,EAAE;QACzB,GAAG;YACF,OAAO,gBAAgB,CAAC;QACzB,CAAC;KACD,CAAE,CAAC;IAEJ,IAAK,WAAW,EAAG,CAAC;QACnB,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;QACvB,GAAG,CAAE,KAAK,EAAE,WAAW,EAAE;YACxB,GAAG;gBACF,OAAO,KAAK,CAAC,IAAI,CAAE,IAAI,CAAE,CAAC;YAC3B,CAAC;SACD,CAAE,CAAC;IACL,CAAC;IAED,GAAG,CAAE,KAAK,EAAE,aAAa,EAAE;QAC1B,GAAG;YACF,OAAO,IAAI,CAAC;QACb,CAAC;KACD,CAAE,CAAC;IAEJ,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAC7B,GAAG,CAAE,KAAK,EAAE,eAAe,EAAE;QAC5B,GAAG;YACF,OAAO,SAAS,CAAC;QAClB,CAAC;KACD,CAAE,CAAC;AAEL,CAAC,CAAC;AA9EW,QAAA,QAAQ,YA8EnB;AACF,MAAM,CAAC,OAAO,GAAG;IAChB,QAAQ,EAAR,gBAAQ;CACR,CAAC"} -------------------------------------------------------------------------------- /build/api/types/compileNewModificatorFunctionBody.d.ts: -------------------------------------------------------------------------------- 1 | declare const compileNewModificatorFunctionBody: (FunctionName: string, asClass?: boolean) => (ConstructHandler: any, CreationHandler: any, SymbolConstructorName: symbol) => any; 2 | export default compileNewModificatorFunctionBody; 3 | -------------------------------------------------------------------------------- /build/api/types/compileNewModificatorFunctionBody.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | const getClassConstructor = (ConstructHandler, CreationHandler) => { 4 | return class extends ConstructHandler { 5 | constructor(...args) { 6 | const answer = super(...args); 7 | return CreationHandler.call(this, answer); 8 | } 9 | }; 10 | }; 11 | const getFunctionConstructor = (ConstructHandler, CreationHandler) => { 12 | const newable = Object.hasOwnProperty.call(ConstructHandler, 'prototype'); 13 | return function (...args) { 14 | let answer; 15 | if (!newable) { 16 | answer = ConstructHandler.call(this, ...args); 17 | } 18 | else { 19 | const _proto = ConstructHandler.prototype; 20 | ConstructHandler.prototype = this.constructor.prototype; 21 | answer = new ConstructHandler(...args); 22 | ConstructHandler.prototype = _proto; 23 | } 24 | return CreationHandler.call(this, answer); 25 | }; 26 | }; 27 | const compileNewModificatorFunctionBody = function (FunctionName, asClass = false) { 28 | return function (ConstructHandler, CreationHandler, SymbolConstructorName) { 29 | return function () { 30 | let ModificationBody; 31 | if (asClass) { 32 | ModificationBody = getClassConstructor(ConstructHandler, CreationHandler); 33 | } 34 | else { 35 | ModificationBody = getFunctionConstructor(ConstructHandler, CreationHandler); 36 | } 37 | ModificationBody.prototype.constructor = ModificationBody; 38 | Object.defineProperty(ModificationBody.prototype.constructor, 'name', { 39 | value: FunctionName, 40 | writable: false 41 | }); 42 | Object.defineProperty(ModificationBody, SymbolConstructorName, { 43 | get() { 44 | return FunctionName; 45 | } 46 | }); 47 | return ModificationBody; 48 | }; 49 | }; 50 | }; 51 | exports.default = compileNewModificatorFunctionBody; 52 | //# sourceMappingURL=compileNewModificatorFunctionBody.js.map -------------------------------------------------------------------------------- /build/api/types/compileNewModificatorFunctionBody.js.map: -------------------------------------------------------------------------------- 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,E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,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;oBAEF,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"} -------------------------------------------------------------------------------- /build/api/types/createInstanceModificator.d.ts: -------------------------------------------------------------------------------- 1 | export default function (obey: CallableFunction): (this: object, ModificatorType: CallableFunction, ModificatorTypePrototype: { 2 | [index: string]: unknown; 3 | }, addProps: CallableFunction) => CallableFunction; 4 | -------------------------------------------------------------------------------- /build/api/types/createInstanceModificator.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.default = default_1; 4 | function default_1(obey) { 5 | const CreateInstanceModificator = function (ModificatorType, ModificatorTypePrototype, addProps) { 6 | const existentInstance = this; 7 | const Mnemosyne = {}; 8 | Reflect.setPrototypeOf(Mnemosyne, existentInstance); 9 | addProps(Mnemosyne); 10 | Object.defineProperty(Mnemosyne, 'constructor', { 11 | get() { 12 | return ModificatorType; 13 | }, 14 | enumerable: false 15 | }); 16 | Object.entries(ModificatorTypePrototype).forEach((entry) => { 17 | const [name, value] = entry; 18 | if (name !== 'constructor') { 19 | (ModificatorType.prototype[name] = value); 20 | } 21 | }); 22 | ModificatorType.prototype.constructor = ModificatorType; 23 | Reflect.setPrototypeOf(ModificatorType.prototype, Mnemosyne); 24 | obey(existentInstance, ModificatorType); 25 | return ModificatorType; 26 | }; 27 | return CreateInstanceModificator; 28 | } 29 | //# sourceMappingURL=createInstanceModificator.js.map -------------------------------------------------------------------------------- /build/api/types/createInstanceModificator.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"createInstanceModificator.js","sourceRoot":"","sources":["../../../src/api/types/createInstanceModificator.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,4BAkEC;AAlED,mBAA0B,IAAsB;IAE/C,MAAM,yBAAyB,GAAG,UAEjC,eAAiC,EACjC,wBAAwD,EACxD,QAA0B;QAI1B,MAAM,gBAAgB,GAAG,IAAI,CAAC;QAK9B,MAAM,SAAS,GAAG,EAAE,CAAC;QACrB,OAAO,CAAC,cAAc,CAAE,SAAS,EAAE,gBAAgB,CAAE,CAAC;QACtD,QAAQ,CAAE,SAAS,CAAE,CAAC;QAItB,MAAM,CAAC,cAAc,CAAE,SAAS,EAAE,aAAa,EAAE;YAChD,GAAG;gBACF,OAAO,eAAe,CAAC;YACxB,CAAC;YACD,UAAU,EAAG,KAAK;SAClB,CAAE,CAAC;QAIJ,MAAM,CAAC,OAAO,CAAE,wBAAwB,CAAE,CAAC,OAAO,CAAE,CAAE,KAAK,EAAG,EAAE;YAC/D,MAAM,CAAE,IAAI,EAAE,KAAK,CAAE,GAAG,KAAK,CAAC;YAC9B,IACC,IAAI,KAAK,aAAa,EAGrB,CAAC;gBACF,CAAE,eAAe,CAAC,SAAS,CAAE,IAAI,CAAE,GAAG,KAAK,CAAE,CAAC;YAC/C,CAAC;QACF,CAAC,CAAE,CAAC;QAGJ,eAAe,CAAC,SAAS,CAAC,WAAW,GAAG,eAAe,CAAC;QASxD,OAAO,CAAC,cAAc,CAAE,eAAe,CAAC,SAAS,EAAE,SAAS,CAAE,CAAC;QAG/D,IAAI,CAAE,gBAAgB,EAAE,eAAe,CAAE,CAAC;QAE1C,OAAO,eAAe,CAAC;IAMxB,CAAC,CAAC;IAEF,OAAO,yBAAyB,CAAC;AAElC,CAAC"} -------------------------------------------------------------------------------- /build/api/types/index.d.ts: -------------------------------------------------------------------------------- 1 | export declare const define: any; 2 | export declare const lookup: any; 3 | -------------------------------------------------------------------------------- /build/api/types/obeyConstructor.d.ts: -------------------------------------------------------------------------------- 1 | export declare const obey: (existentInstance: any, ModificatorType: any) => void; 2 | -------------------------------------------------------------------------------- /build/api/types/obeyConstructor.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.obey = void 0; 4 | const constants_1 = require("../../constants"); 5 | const { SymbolUsed } = constants_1.constants; 6 | const errors_1 = require("../../descriptors/errors"); 7 | const { PROTOTYPE_USED_TWICE, } = errors_1.ErrorsTypes; 8 | const obey = (existentInstance, ModificatorType) => { 9 | let protoConstructor = ModificatorType; 10 | while (protoConstructor instanceof Function) { 11 | if (Object.prototype.hasOwnProperty.call(protoConstructor, SymbolUsed) && protoConstructor[SymbolUsed]) { 12 | const error = new PROTOTYPE_USED_TWICE(`${protoConstructor.name}.prototype > ${ModificatorType.name}`); 13 | throw error; 14 | } 15 | const sample = Reflect.getPrototypeOf(protoConstructor); 16 | if (sample instanceof Function) { 17 | protoConstructor = sample; 18 | } 19 | else { 20 | Object.defineProperty(protoConstructor, SymbolUsed, { 21 | get() { 22 | return true; 23 | } 24 | }); 25 | break; 26 | } 27 | } 28 | Reflect.setPrototypeOf(protoConstructor, existentInstance.constructor); 29 | }; 30 | exports.obey = obey; 31 | //# sourceMappingURL=obeyConstructor.js.map -------------------------------------------------------------------------------- /build/api/types/obeyConstructor.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"obeyConstructor.js","sourceRoot":"","sources":["../../../src/api/types/obeyConstructor.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAEb,+CAA4C;AAC5C,MAAM,EACL,UAAU,EACV,GAAG,qBAAS,CAAC;AAEd,qDAAuD;AACvD,MAAM,EACL,oBAAoB,GACpB,GAAG,oBAAW,CAAC;AAET,MAAM,IAAI,GAAG,CAAE,gBAAqB,EAAE,eAAoB,EAAG,EAAE;IACrE,IAAI,gBAAgB,GAAQ,eAAe,CAAC;IAC5C,OAAQ,gBAAgB,YAAY,QAAQ,EAAG,CAAC;QAC/C,IAAK,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAE,gBAAgB,EAAE,UAAU,CAAE,IAAI,gBAAgB,CAAE,UAAU,CAAE,EAAE,CAAC;YAC7G,MAAM,KAAK,GAAG,IAAI,oBAAoB,CAAE,GAAG,gBAAgB,CAAC,IAAI,gBAAgB,eAAe,CAAC,IAAI,EAAE,CAAE,CAAC;YACzG,MAAM,KAAK,CAAC;QACb,CAAC;QACD,MAAM,MAAM,GAAG,OAAO,CAAC,cAAc,CAAE,gBAAgB,CAAE,CAAC;QAC1D,IAAK,MAAM,YAAY,QAAQ,EAAG,CAAC;YAClC,gBAAgB,GAAG,MAAM,CAAC;QAC3B,CAAC;aAAM,CAAC;YACP,MAAM,CAAC,cAAc,CAAE,gBAAgB,EAAE,UAAU,EAAE;gBACpD,GAAG;oBACF,OAAO,IAAI,CAAC;gBACb,CAAC;aACD,CAAE,CAAC;YACJ,MAAM;QACP,CAAC;IACF,CAAC;IACD,OAAO,CAAC,cAAc,CAAE,gBAAgB,EAAE,gBAAgB,CAAC,WAAW,CAAE,CAAC;AAC1E,CAAC,CAAC;AApBW,QAAA,IAAI,QAoBf"} -------------------------------------------------------------------------------- /build/api/utils/index.d.ts: -------------------------------------------------------------------------------- 1 | export type asyncStack = { 2 | __stack__?: string; 3 | __type__: { 4 | isSubType: boolean; 5 | }; 6 | parent: () => asyncStack; 7 | }; 8 | type parentSub = { 9 | __type__: { 10 | subtypes: Map; 11 | }; 12 | __parent__: parentSub; 13 | }; 14 | declare const TypesUtils: { 15 | isClass: (fn: CallableFunction) => boolean; 16 | CreationHandler: (this: unknown, constructionAnswer: unknown) => unknown; 17 | checkProto: (proto: unknown) => void; 18 | getTypeChecker: (TypeName: string) => unknown; 19 | getTypeSplitPath: (path: string) => string[]; 20 | getExistentAsyncStack: (existentInstance: asyncStack) => unknown; 21 | checkTypeName: (name: string) => void; 22 | findSubTypeFromParent: (instance: parentSub, subType: string) => parentSub; 23 | makeFakeModificatorType: (TypeName: string, fakeModificator?: () => void) => any; 24 | reflectPrimitiveWrappers: (_thisArg: unknown) => unknown; 25 | }; 26 | export default TypesUtils; 27 | -------------------------------------------------------------------------------- /build/api/utils/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/utils/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,+CAA4C;AAC5C,qDAAuD;AACvD,uCAAoC;AAEpC,MAAM,EACL,GAAG,EACH,qBAAqB,EACrB,SAAS,EACT,SAAS,EACT,IAAI,EACJ,MAAM,EACN,GAAG,qBAAS,CAAC;AAEd,MAAM,EACL,qBAAqB,GACrB,GAAG,oBAAW,CAAC;AAEhB,MAAM,EACL,mBAAmB,EACnB,GAAG,aAAK,CAAC;AAGV,MAAM,eAAe,GAAG,UAA0B,kBAA2B;IAS5E,IAAK,kBAAkB,YAAY,MAAM,EAAG,CAAC;QAC5C,OAAO,kBAAkB,CAAC;IAC3B,CAAC;IACD,OAAO,IAAI,CAAC;AACb,CAAC,CAAC;AAEF,kGAA2F;AAE3F,MAAM,UAAU,GAAG,CAAE,KAAc,EAAG,EAAE;IACvC,IAAK,CAAC,CAAE,KAAK,YAAY,MAAM,CAAE,EAAG,CAAC;QACpC,MAAM,IAAI,qBAAqB,CAAE,kCAAkC,CAAE,CAAC;IACvE,CAAC;AACF,CAAC,CAAC;AAEF,MAAM,cAAc,GAAG,CAAE,QAAgB,EAAG,EAAE;IAC7C,MAAM,MAAM,GAAY,CAAE,QAAgB,EAAG,EAAE;QAE9C,IAAK,OAAO,QAAQ,KAAK,QAAQ,EAAG,CAAC;YACpC,OAAO,KAAK,CAAC;QACd,CAAC;QAGD,IAAK,CAAC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QAC1B,QAAQ,YAAY,OAAO;QAC3B,QAAQ,YAAY,MAAM,EACzB,CAAC;QACF,GAAG,CAAE,OAAO,EAAE,MAAM,CAAC,WAAW,EAAE;YACjC,GAAG;gBACF,OAAO,GAAG,EAAE;oBACX,OAAO,QAAQ,CAAC,OAAO,EAAE,CAAC;gBAC3B,CAAC,CAAC;YACH,CAAC;SACD,CAAE,CAAC;IACL,CAAC;IAED,OAAO,OAAO,CAAC;AAChB,CAAC,CAAC;AAEF,MAAM,UAAU,GAAG;IAClB,OAAO;IACP,eAAe;IACf,UAAU;IACV,cAAc;IACd,gBAAgB;IAChB,qBAAqB;IACrB,aAAa;IACb,qBAAqB;IACrB,uBAAuB;IACvB,wBAAwB;CACxB,CAAC;AAEF,kBAAe,UAAU,CAAC"} -------------------------------------------------------------------------------- /build/constants/index.d.ts: -------------------------------------------------------------------------------- 1 | export declare const constants: { 2 | readonly SymbolParentType: symbol; 3 | readonly SymbolConstructorName: symbol; 4 | readonly SymbolGaia: symbol; 5 | readonly SymbolReplaceUranus: symbol; 6 | readonly SymbolDefaultTypesCollection: symbol; 7 | readonly SymbolConfig: symbol; 8 | readonly SymbolUsed: symbol; 9 | readonly MNEMONICA: string; 10 | readonly MNEMOSYNE: string; 11 | readonly GAIA: string; 12 | readonly URANUS: string; 13 | readonly odp: (o: any, p: PropertyKey, attributes: PropertyDescriptor & ThisType) => any; 14 | readonly defaultOptions: Record; 15 | readonly defaultOptionsKeys: string[]; 16 | TYPE_TITLE_PREFIX: string; 17 | ErrorMessages: { 18 | BASE_ERROR_MESSAGE: string; 19 | TYPENAME_MUST_BE_A_STRING: string; 20 | HANDLER_MUST_BE_A_FUNCTION: string; 21 | WRONG_TYPE_DEFINITION: string; 22 | WRONG_INSTANCE_INVOCATION: string; 23 | WRONG_MODIFICATION_PATTERN: string; 24 | ALREADY_DECLARED: string; 25 | WRONG_ARGUMENTS_USED: string; 26 | WRONG_HOOK_TYPE: string; 27 | MISSING_HOOK_CALLBACK: string; 28 | MISSING_CALLBACK_ARGUMENT: string; 29 | FLOW_CHECKER_REDEFINITION: string; 30 | OPTIONS_ERROR: string; 31 | WRONG_STACK_CLEANER: string; 32 | PROTOTYPE_USED_TWICE: string; 33 | }; 34 | }; 35 | -------------------------------------------------------------------------------- /build/constants/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.constants = void 0; 4 | const MNEMONICA = 'Mnemonica'; 5 | const MNEMOSYNE = 'Mnemosyne'; 6 | const GAIA = 'Gaia'; 7 | const URANUS = 'Uranus'; 8 | const SymbolDefaultTypesCollection = Symbol(`default ${MNEMONICA} types collection`); 9 | const SymbolParentType = Symbol('Parent of this SubType Collection'); 10 | const SymbolConstructorName = Symbol('Defined Constructor Name'); 11 | const SymbolGaia = Symbol('Defined Gaia Constructor'); 12 | const SymbolReplaceUranus = Symbol('Defined Method Name to Replace Gaia'); 13 | const SymbolConfig = Symbol('Mnemonica Config Data'); 14 | const SymbolUsed = Symbol('.prototype used twice'); 15 | const TYPE_TITLE_PREFIX = 'modificator of : '; 16 | const ErrorMessages = { 17 | BASE_ERROR_MESSAGE: 'UNPREDICTABLE BEHAVIOUR', 18 | TYPENAME_MUST_BE_A_STRING: 'typename must be a string', 19 | HANDLER_MUST_BE_A_FUNCTION: 'handler must be a function', 20 | WRONG_TYPE_DEFINITION: 'wrong type definition', 21 | WRONG_INSTANCE_INVOCATION: 'wrong instance invocation', 22 | WRONG_MODIFICATION_PATTERN: 'wrong modification pattern', 23 | ALREADY_DECLARED: 'this type has already been declared', 24 | WRONG_ARGUMENTS_USED: 'wrong arguments : should use proper invocation', 25 | WRONG_HOOK_TYPE: 'this hook type does not exist', 26 | MISSING_HOOK_CALLBACK: 'hook definition requires callback', 27 | MISSING_CALLBACK_ARGUMENT: 'callback is required argument', 28 | FLOW_CHECKER_REDEFINITION: 'attempt to re-define flow checker callback', 29 | OPTIONS_ERROR: 'options must be an object or a string', 30 | WRONG_STACK_CLEANER: 'wrong stack cleaner instanceof', 31 | PROTOTYPE_USED_TWICE: '.prototype used twice', 32 | }; 33 | const createInstanceModificator_1 = require("../api/types/createInstanceModificator"); 34 | const defaultOptions = { 35 | get ModificationConstructor() { 36 | return createInstanceModificator_1.default; 37 | }, 38 | get strictChain() { 39 | return true; 40 | }, 41 | get blockErrors() { 42 | return true; 43 | }, 44 | get submitStack() { 45 | return false; 46 | }, 47 | get awaitReturn() { 48 | return true; 49 | }, 50 | }; 51 | exports.constants = { 52 | get 'SymbolParentType'() { 53 | return SymbolParentType; 54 | }, 55 | get 'SymbolConstructorName'() { 56 | return SymbolConstructorName; 57 | }, 58 | get 'SymbolGaia'() { 59 | return SymbolGaia; 60 | }, 61 | get 'SymbolReplaceUranus'() { 62 | return SymbolReplaceUranus; 63 | }, 64 | get 'SymbolDefaultTypesCollection'() { 65 | return SymbolDefaultTypesCollection; 66 | }, 67 | get 'SymbolConfig'() { 68 | return SymbolConfig; 69 | }, 70 | get 'SymbolUsed'() { 71 | return SymbolUsed; 72 | }, 73 | get 'MNEMONICA'() { 74 | return MNEMONICA; 75 | }, 76 | get 'MNEMOSYNE'() { 77 | return MNEMOSYNE; 78 | }, 79 | get 'GAIA'() { 80 | return GAIA; 81 | }, 82 | get 'URANUS'() { 83 | return URANUS; 84 | }, 85 | get 'odp'() { 86 | return (o, p, attributes) => { 87 | return Object.defineProperty(o, p, attributes); 88 | }; 89 | }, 90 | get 'defaultOptions'() { 91 | return defaultOptions; 92 | }, 93 | get 'defaultOptionsKeys'() { 94 | return Object.keys(defaultOptions); 95 | }, 96 | TYPE_TITLE_PREFIX, 97 | ErrorMessages, 98 | }; 99 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /build/constants/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/constants/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAGb,MAAM,SAAS,GAAG,WAAW,CAAC;AAK9B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CAAC;IACb,CAAC;IAKD,IAAI,WAAW;QACd,OAAO,KAAK,CAAC;IACd,CAAC;IAKD,IAAI,WAAW;QACd,OAAO,IAAI,CAAC;IACb,CAAC;CAE0B,CAAC;AAEhB,QAAA,SAAS,GAAG;IAExB,IAAI,kBAAkB;QACrB,OAAO,gBAAgB,CAAC;IACzB,CAAC;IAED,IAAI,uBAAuB;QAC1B,OAAO,qBAAqB,CAAC;IAC9B,CAAC;IAED,IAAI,YAAY;QACf,OAAO,UAAU,CAAC;IACnB,CAAC;IAED,IAAI,qBAAqB;QACxB,OAAO,mBAAmB,CAAC;IAC5B,CAAC;IAED,IAAI,8BAA8B;QACjC,OAAO,4BAA4B,CAAC;IACrC,CAAC;IAED,IAAI,cAAc;QACjB,OAAO,YAAY,CAAC;IACrB,CAAC;IAED,IAAI,YAAY;QACf,OAAO,UAAU,CAAC;IACnB,CAAC;IAGD,IAAI,WAAW;QACd,OAAO,SAAS,CAAC;IAClB,CAAC;IACD,IAAI,WAAW;QACd,OAAO,SAAS,CAAC;IAClB,CAAC;IACD,IAAI,MAAM;QACT,OAAO,IAAI,CAAC;IACb,CAAC;IACD,IAAI,QAAQ;QACX,OAAO,MAAM,CAAC;IACf,CAAC;IACD,IAAI,KAAK;QACR,OAAO,CAAE,CAAM,EAAE,CAAc,EAAE,UAA8C,EAAQ,EAAE;YACxF,OAAO,MAAM,CAAC,cAAc,CAAE,CAAC,EAAE,CAAC,EAAE,UAAU,CAAE,CAAC;QAClD,CAAC,CAAC;IACH,CAAC;IAED,IAAI,gBAAgB;QACnB,OAAO,cAAc,CAAC;IACvB,CAAC;IAED,IAAI,oBAAoB;QACvB,OAAO,MAAM,CAAC,IAAI,CAAE,cAAc,CAAE,CAAC;IACtC,CAAC;IAED,iBAAiB;IAEjB,aAAa;CAEb,CAAC"} -------------------------------------------------------------------------------- /build/descriptors/errors/index.d.ts: -------------------------------------------------------------------------------- 1 | export declare const ErrorsTypes: { 2 | [index: string]: any; 3 | }; 4 | -------------------------------------------------------------------------------- /build/descriptors/errors/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.ErrorsTypes = void 0; 4 | const constants_1 = require("../../constants"); 5 | const errors_1 = require("../../api/errors"); 6 | const { ErrorMessages, } = constants_1.constants; 7 | exports.ErrorsTypes = { 8 | BASE_MNEMONICA_ERROR: errors_1.BASE_MNEMONICA_ERROR 9 | }; 10 | Object.entries(ErrorMessages).forEach(entry => { 11 | const [ErrorConstructorName, message] = entry; 12 | const ErrorConstructor = (0, errors_1.constructError)(ErrorConstructorName, message); 13 | exports.ErrorsTypes[ErrorConstructorName] = ErrorConstructor; 14 | }); 15 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /build/descriptors/errors/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/descriptors/errors/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAEb,+CAA4C;AAC5C,6CAAwE;AAExE,MAAM,EACL,aAAa,GACb,GAAG,qBAAS,CAAC;AAED,QAAA,WAAW,GAA+B;IACtD,oBAAoB,EAApB,6BAAoB;CACpB,CAAC;AAEF,MAAM,CAAC,OAAO,CAAE,aAAa,CAAE,CAAC,OAAO,CAAE,KAAK,CAAC,EAAE;IAChD,MAAM,CAAE,oBAAoB,EAAE,OAAO,CAAE,GAAG,KAAK,CAAC;IAEhD,MAAM,gBAAgB,GAAsB,IAAA,uBAAc,EAAE,oBAAoB,EAAE,OAAO,CAAE,CAAC;IAC5F,mBAAW,CAAE,oBAAoB,CAAE,GAAG,gBAAgB,CAAC;AACxD,CAAC,CAAE,CAAC"} -------------------------------------------------------------------------------- /build/descriptors/index.d.ts: -------------------------------------------------------------------------------- 1 | export declare const descriptors: { 2 | ErrorsTypes: { 3 | [index: string]: any; 4 | }; 5 | createTypesCollection: (config?: {}) => any; 6 | defaultTypes: any; 7 | }; 8 | -------------------------------------------------------------------------------- /build/descriptors/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.descriptors = void 0; 4 | const errors_1 = require("./errors"); 5 | const types_1 = require("./types"); 6 | exports.descriptors = Object.assign(Object.assign({}, types_1.types), { ErrorsTypes: errors_1.ErrorsTypes }); 7 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /build/descriptors/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/descriptors/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAEb,qCAAuC;AACvC,mCAEiB;AAGJ,QAAA,WAAW,mCAEpB,aAAK,KAER,WAAW,EAAX,oBAAW,IAEV"} -------------------------------------------------------------------------------- /build/descriptors/types/index.d.ts: -------------------------------------------------------------------------------- 1 | export declare const types: { 2 | readonly createTypesCollection: (config?: {}) => any; 3 | readonly defaultTypes: any; 4 | }; 5 | -------------------------------------------------------------------------------- /build/descriptors/types/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.types = void 0; 4 | const constants_1 = require("../../constants"); 5 | const { odp, SymbolConstructorName, SymbolDefaultTypesCollection, SymbolConfig, defaultOptions, defaultOptionsKeys, MNEMONICA, MNEMOSYNE, } = constants_1.constants; 6 | const types_1 = require("../../api/types"); 7 | const hooksAPI = require("../../api/hooks"); 8 | const { registerHook, invokeHook, registerFlowChecker, } = hooksAPI; 9 | const typesCollections = new Map(); 10 | const TypesCollection = function (_config) { 11 | const self = this; 12 | const subtypes = new Map(); 13 | const config = defaultOptionsKeys.reduce((o, key) => { 14 | const value = _config[key]; 15 | const option = defaultOptions[key]; 16 | const t_conf = typeof value; 17 | const t_opts = typeof option; 18 | if (t_conf === t_opts) { 19 | o[key] = value; 20 | } 21 | else { 22 | o[key] = option; 23 | } 24 | return o; 25 | }, {}); 26 | odp(this, SymbolConfig, { 27 | get() { 28 | return config; 29 | } 30 | }); 31 | odp(this, Symbol.hasInstance, { 32 | get() { 33 | return (instance) => { 34 | return instance[SymbolConstructorName] === MNEMONICA; 35 | }; 36 | } 37 | }); 38 | odp(this, 'subtypes', { 39 | get() { 40 | return subtypes; 41 | } 42 | }); 43 | odp(subtypes, MNEMOSYNE, { 44 | get() { 45 | return typesCollections.get(self); 46 | } 47 | }); 48 | odp(this, MNEMOSYNE, { 49 | get() { 50 | return typesCollections.get(self); 51 | } 52 | }); 53 | const hooks = Object.create(null); 54 | odp(this, 'hooks', { 55 | get() { 56 | return hooks; 57 | } 58 | }); 59 | }; 60 | odp(TypesCollection.prototype, MNEMONICA, { 61 | get() { 62 | return typesCollections.get(this); 63 | } 64 | }); 65 | odp(TypesCollection.prototype, 'define', { 66 | get() { 67 | const { subtypes } = this; 68 | return function (...args) { 69 | return types_1.define.call(this, subtypes, ...args); 70 | }; 71 | }, 72 | enumerable: true 73 | }); 74 | odp(TypesCollection.prototype, 'lookup', { 75 | get() { 76 | return function (...args) { 77 | return types_1.lookup.call(this.subtypes, ...args); 78 | }.bind(this); 79 | }, 80 | enumerable: true 81 | }); 82 | odp(TypesCollection.prototype, 'registerHook', { 83 | get() { 84 | const self = this; 85 | return function (hookName, hookCallback) { 86 | return registerHook.call(self, hookName, hookCallback); 87 | }.bind(this); 88 | }, 89 | enumerable: true 90 | }); 91 | odp(TypesCollection.prototype, 'invokeHook', { 92 | get() { 93 | return function (hookName, hookCallback) { 94 | const self = this; 95 | return invokeHook.call(typesCollections.get(self), hookName, hookCallback); 96 | }.bind(this); 97 | } 98 | }); 99 | odp(TypesCollection.prototype, 'registerFlowChecker', { 100 | get() { 101 | return function (flowCheckerCallback) { 102 | const self = this; 103 | return registerFlowChecker.call(typesCollections.get(self), flowCheckerCallback); 104 | }.bind(this); 105 | } 106 | }); 107 | const typesCollectionProxyHandler = { 108 | get(target, prop) { 109 | if (target.subtypes.has(prop)) { 110 | return target.subtypes.get(prop); 111 | } 112 | return Reflect.get(target, prop); 113 | }, 114 | set(target, TypeName, Constructor) { 115 | return target.define(TypeName, Constructor); 116 | }, 117 | getOwnPropertyDescriptor(target, prop) { 118 | return target.subtypes.has(prop) ? { 119 | configurable: true, 120 | enumerable: true, 121 | writable: false, 122 | value: target.subtypes.get(prop) 123 | } : undefined; 124 | } 125 | }; 126 | const createTypesCollection = (config = {}) => { 127 | const typesCollection = new TypesCollection(config); 128 | const typesCollectionProxy = new Proxy(typesCollection, typesCollectionProxyHandler); 129 | typesCollections.set(typesCollection, typesCollectionProxy); 130 | return typesCollectionProxy; 131 | }; 132 | const DEFAULT_TYPES = createTypesCollection(); 133 | odp(DEFAULT_TYPES, SymbolDefaultTypesCollection, { 134 | get() { 135 | return true; 136 | } 137 | }); 138 | exports.types = { 139 | get createTypesCollection() { 140 | return function (config = {}) { 141 | return createTypesCollection(config); 142 | }; 143 | }, 144 | get defaultTypes() { 145 | return DEFAULT_TYPES; 146 | } 147 | }; 148 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /build/descriptors/types/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/descriptors/types/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAMb,+CAA4C;AAC5C,MAAM,EACL,GAAG,EACH,qBAAqB,EACrB,4BAA4B,EAC5B,YAAY,EACZ,cAAc,EACd,kBAAkB,EAClB,SAAS,EACT,SAAS,GACT,GAAG,qBAAS,CAAC;AAGd,2CAAiD;AAEjD,4CAA4C;AAE5C,MAAM,EACL,YAAY,EACZ,UAAU,EACV,mBAAmB,GACnB,GAAG,QAAQ,CAAC;AAEb,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAAE,CAAC;AAEnC,MAAM,eAAe,GAAG,UAAW,OAAgC;IAGlE,MAAM,IAAI,GAAG,IAAI,CAAC;IAElB,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAE,CAAC;IAG3B,MAAM,MAAM,GAAG,kBAAkB,CA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AO,KAAK;YACpB,KAAK,EAAU,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAE,IAAI,CAAE;SAC1C,CAAC,CAAC,CAAC,SAAS,CAAC;IACf,CAAC;CACD,CAAC;AAEF,MAAM,qBAAqB,GAAG,CAAE,MAAM,GAAG,EAAE,EAAG,EAAE;IAE/C,MAAM,eAAe,GAAG,IAAI,eAAe,CAAE,MAAM,CAAE,CAAC;IACtD,MAAM,oBAAoB,GAAG,IAAI,KAAK,CAAE,eAAe,EAAE,2BAA2B,CAAE,CAAC;IAEvF,gBAAgB,CAAC,GAAG,CAAE,eAAe,EAAE,oBAAoB,CAAE,CAAC;IAE9D,OAAO,oBAAoB,CAAC;AAE7B,CAAC,CAAC;AAEF,MAAM,aAAa,GAAG,qBAAqB,EAAE,CAAC;AAC9C,GAAG,CAAE,aAAa,EAAE,4BAA4B,EAAE;IACjD,GAAG;QACF,OAAO,IAAI,CAAC;IACb,CAAC;CACD,CAAE,CAAC;AAES,QAAA,KAAK,GAAG;IACpB,IAAI,qBAAqB;QACxB,OAAO,UAAW,MAAM,GAAG,EAAE;YAC5B,OAAO,qBAAqB,CAAE,MAAM,CAAE,CAAC;QACxC,CAAC,CAAC;IACH,CAAC;IACD,IAAI,YAAY;QACf,OAAO,aAAa,CAAC;IACtB,CAAC;CAED,CAAC"} -------------------------------------------------------------------------------- /build/index.d.ts: -------------------------------------------------------------------------------- 1 | import { TypeLookup, IDEF, hook, hooksTypes, constructorOptions, Proto, SN, IDefinitorInstance } from './types'; 2 | export type { IDEF, ConstructorFunction } from './types'; 3 | export declare const defaultTypes: any; 4 | export declare const define: , S extends SN & N, R extends IDefinitorInstance>(this: unknown, TypeName?: string, constructHandler?: IDEF, proto?: P, config?: constructorOptions) => R; 5 | export declare const lookup: TypeLookup; 6 | export declare const apply: >(entity: E, Constructor: IDEF, args?: unknown[]) => { [key in keyof S]: S[key]; }; 7 | export declare const call: >(entity: E, Constructor: IDEF, ...args: unknown[]) => { [key in keyof S]: S[key]; }; 8 | export declare const bind: >(entity: E, Constructor: IDEF) => (...args: unknown[]) => { [key in keyof S]: S[key]; }; 9 | export declare const decorate: (parentClass?: unknown, proto?: object, config?: constructorOptions) => (cstr: T, s: ClassDecoratorContext) => T; 12 | export declare const registerHook: (Constructor: IDEF, hookType: hooksTypes, cb: hook) => void; 13 | export declare const mnemonica: { 14 | [index: string]: unknown; 15 | }; 16 | export declare const SymbolParentType: unknown, SymbolConstructorName: unknown, SymbolGaia: unknown, SymbolReplaceUranus: unknown, SymbolDefaultTypesCollection: unknown, SymbolConfig: unknown, MNEMONICA: unknown, MNEMOSYNE: unknown, GAIA: unknown, URANUS: unknown, TYPE_TITLE_PREFIX: unknown, ErrorMessages: unknown, createTypesCollection: unknown; 17 | export declare const defaultCollection: any; 18 | export declare const errors: { 19 | [index: string]: any; 20 | }; 21 | export { utils } from './utils'; 22 | export { defineStackCleaner } from './utils'; 23 | -------------------------------------------------------------------------------- /build/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.defineStackCleaner = exports.utils = exports.errors = exports.defaultCollection = exports.createTypesCollection = exports.ErrorMessages = exports.TYPE_TITLE_PREFIX = exports.URANUS = exports.GAIA = exports.MNEMOSYNE = exports.MNEMONICA = exports.SymbolConfig = exports.SymbolDefaultTypesCollection = exports.SymbolReplaceUranus = exports.SymbolGaia = exports.SymbolConstructorName = exports.SymbolParentType = exports.mnemonica = exports.registerHook = exports.decorate = exports.bind = exports.call = exports.apply = exports.lookup = exports.define = exports.defaultTypes = void 0; 4 | const constants_1 = require("./constants"); 5 | const { odp } = constants_1.constants; 6 | const errorsApi = require("./api/errors"); 7 | const descriptors_1 = require("./descriptors"); 8 | exports.defaultTypes = descriptors_1.descriptors.defaultTypes; 9 | function checkThis(pointer) { 10 | return pointer === exports.mnemonica || pointer === exports; 11 | } 12 | const define = function (TypeName, constructHandler, proto, config) { 13 | const types = checkThis(this) ? exports.defaultTypes : this || exports.defaultTypes; 14 | return types.define(TypeName, constructHandler, proto, config); 15 | }; 16 | exports.define = define; 17 | exports.lookup = function (TypeNestedPath) { 18 | const types = checkThis(this) ? exports.defaultTypes : this || exports.defaultTypes; 19 | return types.lookup(TypeNestedPath); 20 | }; 21 | const apply = function (entity, Constructor, args = []) { 22 | const result = new entity[Constructor.TypeName](...args); 23 | return result; 24 | }; 25 | exports.apply = apply; 26 | const call = function (entity, Constructor, ...args) { 27 | const result = new entity[Constructor.TypeName](...args); 28 | return result; 29 | }; 30 | exports.call = call; 31 | const bind = function (entity, Constructor) { 32 | return (...args) => { 33 | const result = new entity[Constructor.TypeName](...args); 34 | return result; 35 | }; 36 | }; 37 | exports.bind = bind; 38 | const decorate = function (parentClass = undefined, proto, config) { 39 | const decorator = function (cstr, s) { 40 | if (parentClass === undefined) { 41 | return (0, exports.define)(s.name, cstr, proto, config); 42 | } 43 | return parentClass.define(s.name, cstr, proto, config); 44 | }; 45 | return decorator; 46 | }; 47 | exports.decorate = decorate; 48 | const registerHook = function (Constructor, hookType, cb) { 49 | Constructor.registerHook(hookType, cb); 50 | }; 51 | exports.registerHook = registerHook; 52 | exports.mnemonica = Object.entries(Object.assign(Object.assign(Object.assign({ define: exports.define, 53 | lookup: exports.lookup, 54 | apply: exports.apply, 55 | call: exports.call, 56 | bind: exports.bind, 57 | decorate: exports.decorate, 58 | registerHook: exports.registerHook }, descriptors_1.descriptors), errorsApi), constants_1.constants)).reduce((acc, entry) => { 59 | const [name, code] = entry; 60 | odp(acc, name, { 61 | get() { 62 | return code; 63 | }, 64 | enumerable: true 65 | }); 66 | return acc; 67 | }, {}); 68 | exports.SymbolParentType = exports.mnemonica.SymbolParentType, exports.SymbolConstructorName = exports.mnemonica.SymbolConstructorName, exports.SymbolGaia = exports.mnemonica.SymbolGaia, exports.SymbolReplaceUranus = exports.mnemonica.SymbolReplaceUranus, exports.SymbolDefaultTypesCollection = exports.mnemonica.SymbolDefaultTypesCollection, exports.SymbolConfig = exports.mnemonica.SymbolConfig, exports.MNEMONICA = exports.mnemonica.MNEMONICA, exports.MNEMOSYNE = exports.mnemonica.MNEMOSYNE, exports.GAIA = exports.mnemonica.GAIA, exports.URANUS = exports.mnemonica.URANUS, exports.TYPE_TITLE_PREFIX = exports.mnemonica.TYPE_TITLE_PREFIX, exports.ErrorMessages = exports.mnemonica.ErrorMessages, exports.createTypesCollection = exports.mnemonica.createTypesCollection; 69 | exports.defaultCollection = exports.defaultTypes.subtypes; 70 | exports.errors = descriptors_1.descriptors.ErrorsTypes; 71 | var utils_1 = require("./utils"); 72 | Object.defineProperty(exports, "utils", { enumerable: true, get: function () { return utils_1.utils; } }); 73 | var utils_2 = require("./utils"); 74 | Object.defineProperty(exports, "defineStackCleaner", { enumerable: true, get: function () { return utils_2.defineStackCleaner; } }); 75 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /build/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,CAAC;;;AAcb,2CAAwC;AACxC,MAAM,EAAE,GAAG,EAAE,GAAG,qBAAS,CAAC;AAE1B,0CAA0C;AAC1C,+CAA4C;AAG3C,oBAAY,GACT,yBAAW,cAAC;AAEhB,SAAS,SAAS,CAAG,OAAoD;IACxE,OAAO,OAAO,KAAK,iBAAS,IAAI,OAAO,KAAK,OAAO,CAAC;AACrD,CAAC;AAEM,MAAM,MAAM,GAAG,UAarB,QAAiB,EACjB,gBAA0B,EAC1B,KAAS,EACT,MAA2B;IAE3B,MAAM,KAAK,GAAG,SAAS,CAAE,IAAI,CAAE,CAAC,CAAC,CAAC,oBAAY,CAAC,CAAC,CAAC,IAAI,IAAI,oBAAY,CAAC;IACtE,OAAO,KAAK,CAAC,MAAM,CAAE,QAAQ,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,CAAE,CAAC;AAClE,CAAC,CAAC;AApBW,QAAA,MAAM,UAoBjB;AAEW,QAAA,MAA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,qBAAa,GAGV,iBAAS,gBAFZ,6BAAqB,GAElB,iBAAS,uBAAC;AAGD,QAAA,iBAAiB,GAAG,oBAAY,CAAC,QAAQ,CAAC;AAC1C,QAAA,MAAM,GAAG,yBAAW,CAAC,WAAW,CAAC;AAE9C,iCAAgC;AAAvB,8FAAA,KAAK,OAAA;AACd,iCAA6C;AAApC,2GAAA,kBAAkB,OAAA"} -------------------------------------------------------------------------------- /build/types/index.d.ts: -------------------------------------------------------------------------------- 1 | export type IDEF = { 2 | new (): T; 3 | } | { 4 | (this: T, ...args: any[]): void; 5 | }; 6 | export interface ConstructorFunction { 7 | new (...args: unknown[]): ConstructorInstance; 8 | (this: ConstructorInstance, ...args: unknown[]): ConstructorInstance; 9 | prototype: ConstructorInstance; 10 | } 11 | export type TypeLookup = (this: Map, TypeNestedPath: string) => TypeClass; 12 | export type TypeClass = { 13 | new (...args: unknown[]): unknown; 14 | define: TypeAbsorber; 15 | lookup: TypeLookup; 16 | registerHook: (type: 'preCreation' | 'postCreation' | 'creationError', hookCb: CallableFunction) => unknown; 17 | }; 18 | export type TypeAbsorber = (this: unknown, TypeName: string, constructHandler: CallableFunction, proto?: object, config?: object) => TypeClass; 19 | export type ITypeAbsorber = (this: unknown, TypeName: string, constructHandler: IDEF, proto?: object, config?: object) => ITypeClass; 20 | export interface ITypeClass { 21 | new (...args: unknown[]): T; 22 | (this: T, ...args: unknown[]): T; 23 | define: ITypeAbsorber; 24 | lookup: TypeLookup; 25 | registerHook: (type: 'preCreation' | 'postCreation' | 'creationError', hookCb: CallableFunction) => unknown; 26 | } 27 | export type hooksTypes = 'preCreation' | 'postCreation' | 'creationError'; 28 | export type hooksOpts = { 29 | TypeName: string; 30 | args: unknown[]; 31 | existentInstance: object; 32 | inheritedInstance: object; 33 | }; 34 | export type hook = { 35 | (opts: hooksOpts): void; 36 | }; 37 | export type constructorOptions = { 38 | ModificationConstructor?: CallableFunction; 39 | strictChain?: boolean; 40 | blockErrors?: boolean; 41 | submitStack?: boolean; 42 | awaitReturn?: boolean; 43 | }; 44 | export type Proto = Pick> & T; 45 | export type SN = Record unknown>; 46 | export interface IDefinitorInstance { 47 | new (...arg: unknown[]): { 48 | [key in keyof S]: S[key]; 49 | }; 50 | define: IDefinitor; 51 | registerHook: (hookType: hooksTypes, cb: hook) => void; 52 | } 53 | export interface IDefinitor

{ 54 | >, S extends SN & M>(this: unknown, TypeName: SubTypeName, constructHandler: IDEF, proto?: PP, config?: constructorOptions): IDefinitorInstance; 55 | } 56 | export type TypeDescriptorInstance = { 57 | define: CallableFunction; 58 | lookup: CallableFunction; 59 | subtypes: object; 60 | }; 61 | -------------------------------------------------------------------------------- /build/types/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /build/types/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC"} -------------------------------------------------------------------------------- /build/utils/collectConstructors.d.ts: -------------------------------------------------------------------------------- 1 | export declare const collectConstructors: (self: object, asSequence?: boolean) => {}; 2 | -------------------------------------------------------------------------------- /build/utils/collectConstructors.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.collectConstructors = void 0; 4 | const constants_1 = require("../constants"); 5 | const { MNEMOSYNE, MNEMONICA, GAIA, } = constants_1.constants; 6 | const getAdditor = (constructors) => { 7 | return Array.isArray(constructors) ? 8 | (name) => { 9 | constructors.push(name); 10 | } : (name) => { 11 | constructors[name] = true; 12 | }; 13 | }; 14 | const getAccumulator = (asSequence) => { 15 | return asSequence ? [] : {}; 16 | }; 17 | const collectConstructors = (self, asSequence = false) => { 18 | const constructors = getAccumulator(asSequence); 19 | const addToSequence = getAdditor(constructors); 20 | if (typeof self === 'object') { 21 | if (self === null) { 22 | return constructors; 23 | } 24 | } 25 | else { 26 | return constructors; 27 | } 28 | let proto = Reflect.getPrototypeOf(self); 29 | let mnemonicaReached = false; 30 | while (proto) { 31 | if (!proto.constructor) { 32 | addToSequence(proto); 33 | break; 34 | } 35 | const constructorName = proto.constructor.name; 36 | if (constructorName === GAIA) { 37 | self = proto; 38 | proto = Reflect.getPrototypeOf(self); 39 | continue; 40 | } 41 | if (constructorName === MNEMONICA) { 42 | if (!mnemonicaReached) { 43 | addToSequence(constructorName); 44 | addToSequence(MNEMOSYNE); 45 | mnemonicaReached = true; 46 | } 47 | } 48 | else if (constructorName === 'Object') { 49 | addToSequence(constructorName); 50 | break; 51 | } 52 | else { 53 | addToSequence(constructorName); 54 | } 55 | self = proto; 56 | proto = Reflect.getPrototypeOf(self); 57 | } 58 | return constructors; 59 | }; 60 | exports.collectConstructors = collectConstructors; 61 | //# sourceMappingURL=collectConstructors.js.map -------------------------------------------------------------------------------- /build/utils/collectConstructors.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"collectConstructors.js","sourceRoot":"","sources":["../../src/utils/collectConstructors.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAEb,4CAAyC;AAEzC,MAAM,EACL,SAAS,EACT,SAAS,EACT,IAAI,GACJ,GAAG,qBAAS,CAAC;AAEd,MAAM,UAAU,GAAG,CAAE,YAAuD,EAAG,EAAE;IAChF,OAAO,KAAK,CAAC,OAAO,CAAE,YAAY,CAAE,CAAC,CAAC;QACrC,CAAE,IAAY,EAAG,EAAE;YAClB,YAAY,CAAC,IAAI,CAAE,IAAI,CAAE,CAAC;QAC3B,CAAC,CAAC,CAAC,CAAC,CAAE,IAAY,EAAG,EAAE;QACtB,YAAY,CAAE,IAAI,CAAE,GAAG,IAAI,CAAC;IAC7B,CAAC,CAAC;AAEJ,CAAC,CAAC;AAEF,MAAM,cAAc,GAAG,CAAE,UAAmB,EAAG,EAAE;IAChD,OAAO,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EA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QACD,IAAI,GAAG,KAAK,CAAC;QACb,KAAK,GAAG,OAAO,CAAC,cAAc,CAAE,IAAI,CAAE,CAAC;IACxC,CAAC;IACD,OAAO,YAAY,CAAC;AACrB,CAAC,CAAC;AA3CW,QAAA,mBAAmB,uBA2C9B"} -------------------------------------------------------------------------------- /build/utils/defineStackCleaner.d.ts: -------------------------------------------------------------------------------- 1 | export declare const defineStackCleaner: (regexp: RegExp) => void; 2 | -------------------------------------------------------------------------------- /build/utils/defineStackCleaner.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.defineStackCleaner = void 0; 4 | const errors_1 = require("../descriptors/errors"); 5 | const errors_2 = require("../api/errors"); 6 | const { WRONG_STACK_CLEANER } = errors_1.ErrorsTypes; 7 | const defineStackCleaner = (regexp) => { 8 | if (!(regexp instanceof RegExp)) { 9 | throw new WRONG_STACK_CLEANER; 10 | } 11 | errors_2.stackCleaners.push(regexp); 12 | }; 13 | exports.defineStackCleaner = defineStackCleaner; 14 | //# sourceMappingURL=defineStackCleaner.js.map -------------------------------------------------------------------------------- /build/utils/defineStackCleaner.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"defineStackCleaner.js","sourceRoot":"","sources":["../../src/utils/defineStackCleaner.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAEb,kDAAoD;AACpD,0CAA8C;AAE9C,MAAM,EACL,mBAAmB,EACnB,GAAG,oBAAW,CAAC;AAET,MAAM,kBAAkB,GAAG,CAAC,MAAa,EAAE,EAAE;IACnD,IAAK,CAAC,CAAE,MAAM,YAAY,MAAM,CAAE,EAAG,CAAC;QACrC,MAAM,IAAI,mBAAmB,CAAC;IAC/B,CAAC;IACD,sBAAa,CAAC,IAAI,CAAE,MAAM,CAAE,CAAC;AAC9B,CAAC,CAAC;AALW,QAAA,kBAAkB,sBAK7B"} -------------------------------------------------------------------------------- /build/utils/extract.d.ts: -------------------------------------------------------------------------------- 1 | export declare const extract: (instance: any) => { 2 | [index: string]: any; 3 | }; 4 | -------------------------------------------------------------------------------- /build/utils/extract.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.extract = void 0; 4 | const errors_1 = require("../descriptors/errors"); 5 | const { WRONG_INSTANCE_INVOCATION } = errors_1.ErrorsTypes; 6 | const hop_1 = require("./hop"); 7 | const extract = (instance) => { 8 | if (instance !== Object(instance)) { 9 | throw new WRONG_INSTANCE_INVOCATION; 10 | } 11 | const extracted = {}; 12 | for (const name in instance) { 13 | if (name === 'constructor' && !(0, hop_1.hop)(instance, name)) { 14 | continue; 15 | } 16 | extracted[name] = instance[name]; 17 | } 18 | return extracted; 19 | }; 20 | exports.extract = extract; 21 | //# sourceMappingURL=extract.js.map -------------------------------------------------------------------------------- /build/utils/extract.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"extract.js","sourceRoot":"","sources":["../../src/utils/extract.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAEb,kDAAoD;AACpD,MAAM,EACL,yBAAyB,EACzB,GAAG,oBAAW,CAAC;AAEhB,+BAA4B;AAErB,MAAM,OAAO,GAAG,CAAE,QAAa,EAAG,EAAE;IAG1C,IAAK,QAAQ,KAAK,MAAM,CAAE,QAAQ,CAAE,EAAG,CAAC;QACvC,MAAM,IAAI,yBAAyB,CAAC;IACrC,CAAC;IAED,MAAM,SAAS,GAA+B,EAAE,CAAC;IAEjD,KAAM,MAAM,IAAI,IAAI,QAAQ,EAAG,CAAC;QAC/B,IAAK,IAAI,KAAK,aAAa,IAAI,CAAC,IAAA,SAAG,EAAE,QAAQ,EAAE,IAAI,CAAE,EAAG,CAAC;YACxD,SAAS;QACV,CAAC;QAKD,SAAS,CAAE,IAAI,CAAE,GAAG,QAAQ,CAAE,IAAI,CAAE,CAAC;IACtC,CAAC;IAED,OAAO,SAAS,CAAC;AAElB,CAAC,CAAC;AAtBW,QAAA,OAAO,WAsBlB"} -------------------------------------------------------------------------------- /build/utils/hop.d.ts: -------------------------------------------------------------------------------- 1 | export declare const hop: (o: object, p: string | symbol) => boolean; 2 | -------------------------------------------------------------------------------- /build/utils/hop.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.hop = void 0; 4 | const hop = (o, p) => Object.prototype.hasOwnProperty.call(o, p); 5 | exports.hop = hop; 6 | //# sourceMappingURL=hop.js.map -------------------------------------------------------------------------------- /build/utils/hop.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"hop.js","sourceRoot":"","sources":["../../src/utils/hop.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAEN,MAAM,GAAG,GAAG,CAAC,CAAS,EAAE,CAAgB,EAAE,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAAlF,QAAA,GAAG,OAA+E"} -------------------------------------------------------------------------------- /build/utils/index.d.ts: -------------------------------------------------------------------------------- 1 | export declare const utils: { 2 | [index: string]: any; 3 | }; 4 | export { defineStackCleaner } from './defineStackCleaner'; 5 | -------------------------------------------------------------------------------- /build/utils/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.defineStackCleaner = exports.utils = void 0; 4 | const collectConstructors_1 = require("./collectConstructors"); 5 | const extract_1 = require("./extract"); 6 | const parent_1 = require("./parent"); 7 | const pick_1 = require("./pick"); 8 | const toJSON_1 = require("./toJSON"); 9 | const parse_1 = require("./parse"); 10 | const merge_1 = require("./merge"); 11 | const utilsUnWrapped = { 12 | extract: extract_1.extract, 13 | pick: pick_1.pick, 14 | parent: parent_1.parent, 15 | toJSON: toJSON_1.toJSON, 16 | parse: parse_1.parse, 17 | merge: merge_1.merge, 18 | get collectConstructors() { 19 | return collectConstructors_1.collectConstructors; 20 | }, 21 | }; 22 | const wrapThis = (method) => { 23 | return function (instance, ...args) { 24 | return method(instance !== undefined ? instance : this, ...args); 25 | }; 26 | }; 27 | exports.utils = Object.assign({}, Object.entries(utilsUnWrapped) 28 | .reduce((methods, util) => { 29 | const [name, fn] = util; 30 | methods[name] = wrapThis(fn); 31 | return methods; 32 | }, {})); 33 | var defineStackCleaner_1 = require("./defineStackCleaner"); 34 | Object.defineProperty(exports, "defineStackCleaner", { enumerable: true, get: function () { return defineStackCleaner_1.defineStackCleaner; } }); 35 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /build/utils/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAEb,+DAA4D;AAC5D,uCAAoC;AACpC,qCAAkC;AAClC,iCAA8B;AAC9B,qCAAkC;AAClC,mCAAgC;AAChC,mCAAgC;AAEhC,MAAM,cAAc,GAAG;IAEtB,OAAO,EAAP,iBAAO;IACP,IAAI,EAAJ,WAAI;IAEJ,MAAM,EAAN,eAAM;IAEN,MAAM,EAAN,eAAM;IAEN,KAAK,EAAL,aAAK;IACL,KAAK,EAAL,aAAK;IAEL,IAAI,mBAAmB;QACtB,OAAO,yCAAmB,CAAC;IAC5B,CAAC;CAED,CAAC;AAEF,MAAM,QAAQ,GAAG,CAAE,MAAwB,EAAG,EAAE;IAC/C,OAAO,UAAsB,QAAa,EAAE,GAAG,IAAW;QACzD,OAAO,MAAM,CAAE,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,EAAE,GAAG,IAAI,CAAE,CAAC;IACpE,CAAC,CAAC;AACH,CAAC,CAAC;AAEW,QAAA,KAAK,qBAEd,MAAM,CAAC,OAAO,CAAE,cAAc,CAAE;KACjC,MAAM,CAAE,CAAE,OAAmC,EAAE,IAAI,EAAG,EAAE;IACxD,MAAM,CAAE,IAAI,EAAE,EAAE,CAAE,GAAG,IAAI,CAAC;IAC1B,OAAO,CAAE,IAAI,CAAE,GAAG,QAAQ,CAAE,EAAE,CAAE,CAAC;IACjC,OAAO,OAAO,CAAC;AAChB,CAAC,EAAE,EAAE,CAAE,EAEP;AAEF,2DAA0D;AAAjD,wHAAA,kBAAkB,OAAA"} -------------------------------------------------------------------------------- /build/utils/merge.d.ts: -------------------------------------------------------------------------------- 1 | export declare const merge: (a: any, b: any, ...args: any[]) => any; 2 | -------------------------------------------------------------------------------- /build/utils/merge.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.merge = void 0; 4 | const errors_1 = require("../descriptors/errors"); 5 | const { WRONG_ARGUMENTS_USED } = errors_1.ErrorsTypes; 6 | const merge = (a, b, ...args) => { 7 | if (a !== Object(a)) { 8 | throw new WRONG_ARGUMENTS_USED('A should be an object'); 9 | } 10 | if (b !== Object(b)) { 11 | throw new WRONG_ARGUMENTS_USED('B should be an object'); 12 | } 13 | if (typeof a.fork !== 'function') { 14 | throw new WRONG_ARGUMENTS_USED('A should have A.fork()'); 15 | } 16 | const aa = a.fork.call(b, ...args); 17 | return aa; 18 | }; 19 | exports.merge = merge; 20 | //# sourceMappingURL=merge.js.map -------------------------------------------------------------------------------- /build/utils/merge.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"merge.js","sourceRoot":"","sources":["../../src/utils/merge.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAEb,kDAAoD;AACpD,MAAM,EACL,oBAAoB,EACpB,GAAG,oBAAW,CAAC;AAET,MAAM,KAAK,GAAG,CAAE,CAAM,EAAE,CAAM,EAAE,GAAG,IAAW,EAAG,EAAE;IAGzD,IAAK,CAAC,KAAK,MAAM,CAAE,CAAC,CAAE,EAAG,CAAC;QACzB,MAAM,IAAI,oBAAoB,CAAE,uBAAuB,CAAE,CAAC;IAC3D,CAAC;IAGD,IAAK,CAAC,KAAK,MAAM,CAAE,CAAC,CAAE,EAAG,CAAC;QACzB,MAAM,IAAI,oBAAoB,CAAE,uBAAuB,CAAE,CAAC;IAC3D,CAAC;IAED,IAAK,OAAO,CAAC,CAAC,IAAI,KAAK,UAAU,EAAG,CAAC;QACpC,MAAM,IAAI,oBAAoB,CAAE,wBAAwB,CAAE,CAAC;IAC5D,CAAC;IAED,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAE,CAAC,EAAE,GAAG,IAAI,CAAE,CAAC;IACrC,OAAO,EAAE,CAAC;AAEX,CAAC,CAAC;AAnBW,QAAA,KAAK,SAmBhB"} -------------------------------------------------------------------------------- /build/utils/parent.d.ts: -------------------------------------------------------------------------------- 1 | export declare const parent: (instance: any, path: string) => any; 2 | -------------------------------------------------------------------------------- /build/utils/parent.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.parent = void 0; 4 | const errors_1 = require("../descriptors/errors"); 5 | const { WRONG_INSTANCE_INVOCATION } = errors_1.ErrorsTypes; 6 | const parent = (instance, path) => { 7 | if (instance !== Object(instance)) { 8 | throw new WRONG_INSTANCE_INVOCATION; 9 | } 10 | const { __parent__: p } = instance; 11 | if (!p) { 12 | return; 13 | } 14 | if (!path) { 15 | return p; 16 | } 17 | const { constructor: { name } } = p; 18 | return name === path ? 19 | p : (0, exports.parent)(p, path); 20 | }; 21 | exports.parent = parent; 22 | //# sourceMappingURL=parent.js.map -------------------------------------------------------------------------------- /build/utils/parent.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"parent.js","sourceRoot":"","sources":["../../src/utils/parent.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAEb,kDAAoD;AACpD,MAAM,EACL,yBAAyB,EACzB,GAAG,oBAAW,CAAC;AAKT,MAAM,MAAM,GAAG,CAAE,QAAa,EAAE,IAAY,EAAQ,EAAE;IAG5D,IAAK,QAAQ,KAAK,MAAM,CAAE,QAAQ,CAAE,EAAG,CAAC;QACvC,MAAM,IAAI,yBAAyB,CAAC;IACrC,CAAC;IAED,MAAM,EACL,UAAU,EAAE,CAAC,EACb,GAAG,QAAQ,CAAC;IAEb,IAAK,CAAC,CAAC,EAAG,CAAC;QACV,OAAO;IACR,CAAC;IAED,IAAK,CAAC,IAAI,EAAG,CAAC;QACb,OAAO,CAAC,CAAC;IACV,CAAC;IAED,MAAM,EACL,WAAW,EAAE,EACZ,IAAI,EACJ,EACD,GAAG,CAAC,CAAC;IAIN,OAAO,IAAI,KAAK,IAAI,CAAC,CAAC;QACrB,CAAC,CAAC,CAAC,CAAC,IAAA,cAAM,EAAE,CAAC,EAAE,IAAI,CAAE,CAAC;AAExB,CAAC,CAAC;AA9BW,QAAA,MAAM,UA8BjB"} -------------------------------------------------------------------------------- /build/utils/parse.d.ts: -------------------------------------------------------------------------------- 1 | export declare const parse: (self: any) => any; 2 | -------------------------------------------------------------------------------- /build/utils/parse.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.parse = void 0; 4 | const errors_1 = require("../descriptors/errors"); 5 | const { WRONG_MODIFICATION_PATTERN, WRONG_ARGUMENTS_USED } = errors_1.ErrorsTypes; 6 | const constants_1 = require("../constants"); 7 | const { SymbolGaia } = constants_1.constants; 8 | const extract_1 = require("./extract"); 9 | const hop_1 = require("./hop"); 10 | const parse = (self) => { 11 | if (!self || !self.constructor) { 12 | throw new WRONG_MODIFICATION_PATTERN; 13 | } 14 | const proto = Reflect.getPrototypeOf(self); 15 | if (self.constructor.name.toString() !== proto.constructor.name.toString()) { 16 | throw new WRONG_ARGUMENTS_USED(`have to use "instance" itself: '${self.constructor.name}' vs '${proto.constructor.name}'`); 17 | } 18 | const protoProto = Reflect.getPrototypeOf(proto); 19 | if (protoProto && proto.constructor.name.toString() !== protoProto.constructor.name.toString()) { 20 | throw new WRONG_ARGUMENTS_USED(`have to use "instance" itself: '${proto.constructor.name}' vs '${protoProto.constructor.name}'`); 21 | } 22 | const { name } = proto.constructor; 23 | const props = (0, extract_1.extract)(Object.assign({}, self)); 24 | delete props.constructor; 25 | const joint = (0, extract_1.extract)(Object.assign({}, proto)); 26 | delete joint.constructor; 27 | let parent; 28 | let gaia; 29 | if ((0, hop_1.hop)(protoProto, SymbolGaia)) { 30 | parent = protoProto; 31 | gaia = self[SymbolGaia]; 32 | } 33 | else { 34 | parent = (0, exports.parse)(Reflect.getPrototypeOf(protoProto)); 35 | gaia = parent.gaia; 36 | } 37 | return { 38 | name, 39 | props, 40 | self, 41 | proto, 42 | joint, 43 | parent, 44 | gaia 45 | }; 46 | }; 47 | exports.parse = parse; 48 | //# sourceMappingURL=parse.js.map -------------------------------------------------------------------------------- /build/utils/parse.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"parse.js","sourceRoot":"","sources":["../../src/utils/parse.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAEb,kDAAoD;AACpD,MAAM,EACL,0BAA0B,EAC1B,oBAAoB,EACpB,GAAG,oBAAW,CAAC;AAEhB,4CAAyC;AACzC,MAAM,EACL,UAAU,EACV,GAAG,qBAAS,CAAC;AAEd,uCAAoC;AAEpC,+BAA4B;AAErB,MAAM,KAAK,GAAG,CAAE,IAAS,EAAQ,EAAE;IAEzC,IAAK,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,WAAW,EAAG,CAAC;QAClC,MAAM,IAAI,0BAA0B,CAAC;IACtC,CAAC;IAED,MAAM,KAAK,GAAG,OAAO,CAAC,cAAc,CAAE,IAAI,CAAY,CAAC;IAEvD,IAAK,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAG,CAAC;QAC9E,MAAM,IAAI,oBAAoB,CAAE,mCAAmC,IAAI,CAAC,WAAW,CAAC,IAAI,SAAS,KAAK,CAAC,WAAW,CAAC,IAAI,GAAG,CAAE,CAAC;IAC9H,CAAC;IAED,MAAM,UAAU,GAAQ,OAAO,CAAC,cAAc,CAAE,KAAK,CAAE,CAAC;IACxD,IAAK,UAAU,IAAI,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAG,CAAC;QAClG,MAAM,IAAI,oBAAoB,CAAE,mCAAmC,KAAK,CAAC,WAAW,CAAC,IAAI,SAAS,UAAU,CAAC,WAAW,CAAC,IAAI,GAAG,CAAE,CAAC;IACpI,CAAC;IAKD,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC,WAAW,CAAC;IAEnC,MAAM,KAAK,GAAQ,IAAA,iBAAO,oBAAO,IAAI,EAAI,CAAC;IAE1C,OAAO,KAAK,CAAC,WAAW,CAAC;IAEzB,MAAM,KAAK,GAAQ,IAAA,iBAAO,EAAE,MAAM,CAAC,MAAM,CAAE,EAAE,EAAE,KAAK,CAAE,CAAE,CAAC;IACzD,OAAO,KAAK,CAAC,WAAW,CAAC;IAEzB,IAAI,MAAM,CAAC;IACX,IAAI,IAAI,CAAC;IACT,IAAK,IAAA,SAAG,EAAE,UAAU,EAAE,UAAU,CAAE,EAAG,CAAC;QACrC,MAAM,GAAG,UAAU,CAAC;QAEpB,IAAI,GAAG,IAAI,CAAE,UAAU,CAAE,CAAC;IAC3B,CAAC;SAAM,CAAC;QACP,MAAM,GAAG,IAAA,aAAK,EAAE,OAAO,CAAC,cAAc,CAAE,UAAU,CAAE,CAAE,CAAC;QAEvD,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;IACpB,CAAC;IAED,OAAO;QAEN,IAAI;QAEJ,KAAK;QAGL,IAAI;QACJ,KAAK;QAEL,KAAK;QAEL,MAAM;QACN,IAAI;KAEJ,CAAC;AACH,CAAC,CAAC;AAzDW,QAAA,KAAK,SAyDhB"} -------------------------------------------------------------------------------- /build/utils/pick.d.ts: -------------------------------------------------------------------------------- 1 | export declare const pick: (instance: any, ...args: string[]) => { 2 | [index: string]: any; 3 | }; 4 | -------------------------------------------------------------------------------- /build/utils/pick.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.pick = void 0; 4 | const errors_1 = require("../descriptors/errors"); 5 | const { WRONG_INSTANCE_INVOCATION } = errors_1.ErrorsTypes; 6 | const pick = (instance, ...args) => { 7 | if (instance !== Object(instance)) { 8 | throw new WRONG_INSTANCE_INVOCATION; 9 | } 10 | const props = args.reduce((arr, el) => { 11 | if (Array.isArray(el)) { 12 | arr.push(...el); 13 | } 14 | else { 15 | arr.push(el); 16 | } 17 | return arr; 18 | }, []); 19 | const picked = props.reduce((obj, name) => { 20 | obj[name] = instance[name]; 21 | return obj; 22 | }, {}); 23 | return picked; 24 | }; 25 | exports.pick = pick; 26 | //# sourceMappingURL=pick.js.map -------------------------------------------------------------------------------- /build/utils/pick.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"pick.js","sourceRoot":"","sources":["../../src/utils/pick.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAEb,kDAAoD;AACpD,MAAM,EACL,yBAAyB,EACzB,GAAG,oBAAW,CAAC;AAET,MAAM,IAAI,GAAG,CAAE,QAAa,EAAE,GAAG,IAAc,EAAG,EAAE;IAG1D,IAAK,QAAQ,KAAK,MAAM,CAAE,QAAQ,CAAE,EAAG,CAAC;QACvC,MAAM,IAAI,yBAAyB,CAAC;IACrC,CAAC;IAED,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAE,CAAE,GAAa,EAAE,EAAqB,EAAG,EAAE;QACrE,IAAK,KAAK,CAAC,OAAO,CAAE,EAAE,CAAE,EAAG,CAAC;YAC3B,GAAG,CAAC,IAAI,CAAE,GAAG,EAAE,CAAE,CAAC;QACnB,CAAC;aAAM,CAAC;YACP,GAAG,CAAC,IAAI,CAAE,EAAE,CAAE,CAAC;QAChB,CAAC;QACD,OAAO,GAAG,CAAC;IACZ,CAAC,EAAE,EAAE,CAAE,CAAC;IAER,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAE,CAAE,GAA+B,EAAE,IAAY,EAAG,EAAE;QAChF,GAAG,CAAE,IAAI,CAAE,GAAG,QAAQ,CAAE,IAAI,CAAE,CAAC;QAC/B,OAAO,GAAG,CAAC;IACZ,CAAC,EAAE,EAAE,CAAE,CAAC;IAER,OAAO,MAAM,CAAC;AAEf,CAAC,CAAC;AAvBW,QAAA,IAAI,QAuBf"} -------------------------------------------------------------------------------- /build/utils/toJSON.d.ts: -------------------------------------------------------------------------------- 1 | export declare const toJSON: (instance: object) => string; 2 | -------------------------------------------------------------------------------- /build/utils/toJSON.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.toJSON = void 0; 4 | const extract_1 = require("./extract"); 5 | const toJSON = (instance) => { 6 | const extracted = (0, extract_1.extract)(instance); 7 | return Object.entries(extracted).reduce((o, entry) => { 8 | const [name, _value] = entry; 9 | if ([null, undefined].includes(_value)) { 10 | return o; 11 | } 12 | let value; 13 | try { 14 | value = JSON.stringify(_value); 15 | } 16 | catch (error) { 17 | const description = 'This value type is not supported by JSON.stringify'; 18 | const { stack, message } = error; 19 | value = JSON.stringify({ 20 | description, 21 | stack, 22 | message 23 | }); 24 | } 25 | o += `"${name}":${value},`; 26 | return o; 27 | }, '{') 28 | .replace(/,$/, '}'); 29 | }; 30 | exports.toJSON = toJSON; 31 | //# sourceMappingURL=toJSON.js.map -------------------------------------------------------------------------------- /build/utils/toJSON.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"toJSON.js","sourceRoot":"","sources":["../../src/utils/toJSON.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAEb,uCAAoC;AAC7B,MAAM,MAAM,GAAG,CAAE,QAAgB,EAAG,EAAE;IAE5C,MAAM,SAAS,GAAG,IAAA,iBAAO,EAAE,QAAQ,CAAE,CAAC;IACtC,OAAO,MAAM,CAAC,OAAO,CAAE,SAAS,CAAE,CAAC,MAAM,CAAE,CAAE,CAAS,EAAE,KAAsB,EAAG,EAAE;QAElF,MAAM,CAAE,IAAI,EAAE,MAAM,CAAE,GAAG,KAAK,CAAC;QAC/B,IAAK,CAAE,IAAI,EAAE,SAAS,CAAE,CAAC,QAAQ,CAAE,MAAM,CAAE,EAAG,CAAC;YAC9C,OAAO,CAAC,CAAC;QACV,CAAC;QAED,IAAI,KAAK,CAAC;QAEV,IAAI,CAAC;YACJ,KAAK,GAAG,IAAI,CAAC,SAAS,CAAE,MAAM,CAAE,CAAC;QAClC,CAAC;QAAC,OAAQ,KAAkB,EAAE,CAAC;YAC9B,MAAM,WAAW,GAAG,oDAAoD,CAAC;YACzE,MAAM,EACL,KAAK,EACL,OAAO,EACP,GAAG,KAAK,CAAC;YAEV,KAAK,GAAG,IAAI,CAAC,SAAS,CAAE;gBACvB,WAAW;gBACX,KAAK;gBACL,OAAO;aACP,CAAE,CAAC;QACL,CAAC;QAED,CAAC,IAAI,IAAI,IAAI,KAAK,KAAK,GAAG,CAAC;QAC3B,OAAO,CAAC,CAAC;IAEV,CAAC,EAAE,GAAG,CAAE;SACN,OAAO,CAAE,IAAI,EAAE,GAAG,CAAE,CAAC;AAExB,CAAC,CAAC;AAlCW,QAAA,MAAM,UAkCjB"} -------------------------------------------------------------------------------- /examples/AsyncNewTest.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const sss = async function () { 4 | this.m = 1; 5 | }; 6 | 7 | console.log(Object.hasOwnProperty.call(sss, 'prototype')); 8 | try { 9 | new sss; 10 | } catch (error) { 11 | console.error(error); 12 | } 13 | -------------------------------------------------------------------------------- /examples/ClassReName.js: -------------------------------------------------------------------------------- 1 | const name = 'ClassName'; 2 | 3 | const pointer = class { 4 | constructor () { 5 | this.name = this.constructor.name; 6 | } 7 | }; 8 | 9 | console.log( ( new pointer ).name ); 10 | 11 | 12 | const reNamer = {}; 13 | 14 | reNamer[ name ] = pointer; 15 | Object.defineProperty( reNamer[ name ].prototype.constructor, 'name', { 16 | get () { 17 | return name; 18 | } 19 | } ); 20 | 21 | console.log( ( new reNamer[ name ] ).name ); 22 | 23 | console.log( ( new pointer ).name ); 24 | -------------------------------------------------------------------------------- /examples/v8bug.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | // though Error.prototype.stack is non standard 5 | // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/stack 6 | 7 | const myErrorObject = new Error('my error'); 8 | myErrorObject.prop = 123; 9 | const hop = (o, p) => Object.prototype.hasOwnProperty.call(o, p); 10 | 11 | // nodejs v20 & v22 it works properly 12 | console.log(hop(myErrorObject, 'stack')); 13 | // and for Firefox this property above just does not exists at all 14 | // hop(Object.getPrototypeOf(myErrorObject), 'stack'); 15 | 16 | 17 | const myIntermediateObject = {}; 18 | 19 | Object.setPrototypeOf(myIntermediateObject, myErrorObject); 20 | 21 | console.log(myIntermediateObject instanceof Error); 22 | 23 | myIntermediateObject.stack = myErrorObject.stack; 24 | // it doesn't matter which value you assign there, 25 | // for example uncomment the next line 26 | // myIntermediateObject.stack = 'myErrorObject.stack'; 27 | myIntermediateObject.prop = 123; 28 | 29 | // this works properly for node.js v20, but not for v22 30 | console.log(':', hop(myIntermediateObject, 'stack')); 31 | console.log(':', hop(myIntermediateObject, 'prop')); 32 | 33 | const myCorrectedObject = {}; 34 | Object.setPrototypeOf(myCorrectedObject, myErrorObject); 35 | console.log(myCorrectedObject instanceof Error); 36 | 37 | Object.defineProperty(myCorrectedObject, 'stack', { 38 | get () { 39 | return myErrorObject.stack; 40 | } 41 | }); 42 | 43 | // nodejs v20 & v22 it works properly 44 | console.log(hop(myCorrectedObject, 'stack')); 45 | 46 | 47 | 48 | // so for objects with Error in prototoype chain 49 | // it optimizes .stack property 50 | 51 | // general behaviour works correctly for both 52 | const base = { 53 | stack : 'str', 54 | prop : 123 55 | }; 56 | 57 | const sup = {}; 58 | 59 | Object.setPrototypeOf(sup, base); 60 | 61 | sup.stack = 'str'; 62 | sup.prop = 123; 63 | console.log(hop(sup, 'stack')); 64 | console.log(hop(sup, 'prop')); 65 | -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | preset : 'ts-jest', 3 | testEnvironment : 'node', 4 | testMatch : ['**/test-jest/**/*.ts'], 5 | transform : { 6 | '\\./test-jest/*.ts$': ['ts-jest', { tsconfig : './tsconfig.jest.json' }] 7 | }, 8 | coverageDirectory : './coveragejest' 9 | }; -------------------------------------------------------------------------------- /module/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "env" : { 3 | "browser" : true, 4 | "node" : true, 5 | "es6" : true 6 | }, 7 | "parserOptions": { 8 | "sourceType": "module" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /module/index.js: -------------------------------------------------------------------------------- 1 | 2 | import mnemonica from '../build/index.js'; 3 | 4 | export default mnemonica; 5 | 6 | export const { 7 | errors, 8 | ErrorMessages, 9 | 10 | // constants: strings 11 | MNEMONICA, 12 | MNEMOSYNE, 13 | GAIA, 14 | URANUS, 15 | 16 | TYPE_TITLE_PREFIX, 17 | 18 | // constants: symbols 19 | SymbolConstructorName, 20 | SymbolSubtypeCollection, 21 | SymbolGaia, 22 | 23 | // namespaces 24 | namespaces, 25 | defaultNamespace, 26 | createNamespace, 27 | SymbolDefaultNamespace, 28 | 29 | // types collections 30 | defaultTypes, 31 | createTypesCollection, 32 | 33 | defineStackCleaner, 34 | 35 | utils, 36 | 37 | // main 38 | define, 39 | lookup 40 | 41 | } = mnemonica; 42 | -------------------------------------------------------------------------------- /module/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mnemonica", 3 | "type": "module", 4 | "main": "index.js", 5 | "exports": { 6 | "default": "index.js" 7 | } 8 | } 9 | 10 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mnemonica", 3 | "version": "0.9.992", 4 | "description": "abstract technique that aids information retention : instance inheritance system", 5 | "type": "commonjs", 6 | "main": "./build/index.js", 7 | "exports": { 8 | ".": "./build/index.js", 9 | "./module": { 10 | "import": "./module/index.js", 11 | "browser": "./module/index.js", 12 | "require": "./build/index.js", 13 | "default": "./build/index.js" 14 | } 15 | }, 16 | "files": [ 17 | "README.md", 18 | "LICENSE", 19 | "module", 20 | "build" 21 | ], 22 | "directories": { 23 | "build": "build/", 24 | "module": "module/" 25 | }, 26 | "contributors": [ 27 | "laplandin ", 28 | "petrgrishin ", 29 | "Goodluckhf " 30 | ], 31 | "scripts": { 32 | "build": "rm -rf ./build && npx tsc --pretty && npm run lint && npm run lint:src && npm run lint:test", 33 | "example": "npm run build && node ./test/example.js", 34 | "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", 35 | "lint": "npx eslint --fix", 36 | "lint:src": "npx eslint --fix ./src", 37 | "lint:test": "npx eslint --fix ./test", 38 | "test": "mocha --allow-uncaught test/index.js", 39 | "test:cov": "npm run build && nyc --reporter=text-summary --reporter=lcov mocha --allow-uncaught --ui bdd --reporter spec ./test/index.js", 40 | "test:debug": "npx tsc --pretty --sourceMap && npx mocha --allow-uncaught --reporter spec --inspect-brk test/index", 41 | "test:jest": "npx jest", 42 | "test:jest:cov": "npx jest --collectCoverage", 43 | "test:jest:debug": "npx --node-arg=--inspect-brk jest", 44 | "test:mjs": "npm run build && node --experimental-modules ./test/test.mjs", 45 | "watch": "npx tsc --pretty -w", 46 | "prepare": "husky" 47 | }, 48 | "repository": { 49 | "type": "git", 50 | "url": "git+https://github.com/wentout/mnemonica.git" 51 | }, 52 | "keywords": [ 53 | "ETL", 54 | "DFD", 55 | "inheritance", 56 | "mnemonica" 57 | ], 58 | "author": "went.out@gmail.com", 59 | "license": "MIT", 60 | "bugs": { 61 | "url": "https://github.com/wentout/mnemonica/issues" 62 | }, 63 | "homepage": "https://github.com/wentout/mnemonica#readme", 64 | "devDependencies": { 65 | "@types/jest": "^29.5.14", 66 | "@types/node": "^18.19.75", 67 | "@typescript-eslint/eslint-plugin": "^5.62.0", 68 | "@typescript-eslint/parser": "^5.62.0", 69 | "chai": "^4.5.0", 70 | "eslint": "^8.57.1", 71 | "eslint-plugin-import": "^2.31.0", 72 | "eslint-plugin-mocha": "^10.5.0", 73 | "eslint-plugin-no-arrow-this": "^1.2.0", 74 | "husky": "^9.1.7", 75 | "jest": "^29.7.0", 76 | "json5": "^2.2.3", 77 | "lint-staged": "^15.4.3", 78 | "mocha": "^10.8.2", 79 | "mocha-lcov-reporter": "^1.3.0", 80 | "nyc": "^15.1.0", 81 | "ts-jest": "^29.2.5", 82 | "typescript": "^5.7.3" 83 | }, 84 | "engines": { 85 | "node": ">=16 <24" 86 | }, 87 | "husky": { 88 | "hooks": { 89 | "pre-commit": "lint-staged" 90 | } 91 | }, 92 | "lint-staged": { 93 | "*.js": "eslint --fix" 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /src/api/errors/exceptionConstructor.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import { constants } from '../../constants'; 4 | const { odp } = constants; 5 | 6 | import { ErrorsTypes } from '../../descriptors/errors'; 7 | const { 8 | WRONG_ARGUMENTS_USED, 9 | WRONG_INSTANCE_INVOCATION 10 | } = ErrorsTypes; 11 | 12 | import { cleanupStack, getStack } from '../errors'; 13 | 14 | import { utils } from '../../utils'; 15 | const { 16 | parse 17 | } = utils; 18 | 19 | import TypesUtils from '../utils'; 20 | 21 | const { 22 | makeFakeModificatorType 23 | } = TypesUtils; 24 | 25 | import { makeInstanceModificator } from '../types/InstanceModificator'; 26 | 27 | const checkThrowArgs = ( instance: any, target: any, error: Error, args: any[] ) => { 28 | 29 | let wrongThrow; 30 | 31 | /* unreacheble, cus instance bound inside of Mnemosyne 32 | if (instance !== Object(instance)) { 33 | wrongThrow = new WRONG_ARGUMENTS_USED('"this" must be an object'); 34 | } 35 | if (instance.constructor[SymbolConstructorName] !== instance.constructor.name) { 36 | wrongThrow = new WRONG_ARGUMENTS_USED('"this" must be an object'); 37 | } 38 | */ 39 | 40 | if ( !target ) { 41 | throw new WRONG_INSTANCE_INVOCATION( 'exception should be made with new keyword' ); 42 | } 43 | 44 | if ( !( error instanceof Error ) ) { 45 | wrongThrow = new WRONG_ARGUMENTS_USED( 'error must be instanceof Error' ); 46 | } 47 | 48 | if ( !( wrongThrow instanceof Error ) ) { 49 | return; 50 | } 51 | 52 | odp( wrongThrow, 'instance', { 53 | get () { 54 | return instance; 55 | } 56 | } ); 57 | 58 | odp( wrongThrow, 'error', { 59 | get () { 60 | return error; 61 | } 62 | } ); 63 | 64 | odp( wrongThrow, 'args', { 65 | get () { 66 | return args; 67 | } 68 | } ); 69 | 70 | throw wrongThrow; 71 | 72 | }; 73 | 74 | const exceptionConsctructHandler = function ( this: any, opts: { [ index: string ]: any } ) { 75 | 76 | const { 77 | instance, 78 | TypeName, 79 | typeStack, 80 | args, 81 | error 82 | } = opts; 83 | 84 | 85 | // eslint-disable-next-line @typescript-eslint/no-this-alias 86 | const exception = this; 87 | 88 | odp( exception, 'args', { 89 | get () { 90 | return args; 91 | } 92 | } ); 93 | 94 | odp( exception, 'originalError', { 95 | get () { 96 | return error; 97 | } 98 | } ); 99 | 100 | odp( exception, 'instance', { 101 | get () { 102 | return instance; 103 | } 104 | } ); 105 | 106 | odp( exception, 'extract', { 107 | get () { 108 | return () => { 109 | return instance.extract(); 110 | }; 111 | } 112 | } ); 113 | 114 | odp( exception, 'parse', { 115 | get () { 116 | return () => { 117 | return parse( instance ); 118 | }; 119 | } 120 | } ); 121 | 122 | // real error stack 123 | const errorStack = exception.stack.split( '\n' ); 124 | 125 | const stack: string[] = []; 126 | 127 | const title = `\n<-- lifecycle of [ ${TypeName} ] traced -->`; 128 | 129 | getStack.call( exception, title, [], prepareException ); 130 | 131 | stack.push( ...exception.stack ); 132 | 133 | stack.push( '<-- with the following error -->' ); 134 | 135 | errorStack.forEach( ( line: string ) => { 136 | if ( !stack.includes( line ) ) { 137 | stack.push( line ); 138 | } 139 | } ); 140 | 141 | stack.push( '\n<-- of constructor definitions stack -->' ); 142 | stack.push( ...typeStack ); 143 | 144 | const exceptionStack = cleanupStack( stack ).join( '\n' ); 145 | 146 | odp( exception, 'stack', { 147 | get () { 148 | return exceptionStack; 149 | } 150 | }); 151 | 152 | return exception; 153 | 154 | 155 | }; 156 | 157 | const prepareException = function ( this: any, target: any, error: Error, ...args: any[] ) { 158 | 159 | // eslint-disable-next-line @typescript-eslint/no-this-alias 160 | const instance = this; 161 | 162 | checkThrowArgs( instance, target, error, args ); 163 | 164 | const { 165 | __type__, 166 | __creator__ 167 | } = instance; 168 | 169 | 170 | const { 171 | stack: typeStack, 172 | TypeName 173 | } = __type__; 174 | 175 | /* short way, makes hooks calls, will not use 176 | 177 | const type = Object.create(__type__); 178 | type.config.blockErrors = false; 179 | 180 | let errored = new InstanceCreator(type, error, args); 181 | */ 182 | 183 | const ExceptionCreator = Object.create( __creator__ ); 184 | ExceptionCreator.config = Object.assign( {}, __creator__.config ); 185 | ExceptionCreator.config.blockErrors = false; 186 | 187 | ExceptionCreator.existentInstance = error; 188 | // eslint-disable-next-line no-shadow 189 | ExceptionCreator.ModificatorType = makeFakeModificatorType( TypeName, function ( this: unknown ) { 190 | return exceptionConsctructHandler.call( this, { 191 | instance, 192 | TypeName, 193 | typeStack, 194 | args, 195 | error 196 | } ); 197 | } ); 198 | 199 | ExceptionCreator.InstanceModificator = makeInstanceModificator( ExceptionCreator ); 200 | 201 | return new ExceptionCreator.InstanceModificator(); 202 | }; 203 | 204 | export default prepareException; 205 | -------------------------------------------------------------------------------- /src/api/errors/index.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import { constants } from '../../constants'; 4 | 5 | const { 6 | odp, 7 | SymbolConstructorName, 8 | MNEMONICA, 9 | ErrorMessages, 10 | } = constants; 11 | 12 | const { 13 | BASE_ERROR_MESSAGE 14 | } = ErrorMessages; 15 | 16 | export const stackCleaners: RegExp[] = []; 17 | 18 | export const cleanupStack = ( stack: string[] ) => { 19 | const cleaned: string[] = stack.reduce( ( arr: string[], line: string ) => { 20 | stackCleaners.forEach( cleanerRegExp => { 21 | if ( !cleanerRegExp.test( line ) ) { 22 | arr.push( line ); 23 | } 24 | } ); 25 | return arr; 26 | }, [] ); 27 | return cleaned.length ? cleaned : stack; 28 | }; 29 | 30 | export const getStack = function ( this: any, title: string, stackAddition: string[], tillFunction?: CallableFunction ) { 31 | 32 | if ( Error.captureStackTrace ) { 33 | Error.captureStackTrace( this, tillFunction || getStack ); 34 | } else { 35 | this.stack = ( new Error() ).stack; 36 | } 37 | 38 | this.stack = this.stack.split( '\n' ).slice( 1 ); 39 | this.stack = cleanupStack( this.stack ); 40 | 41 | this.stack.unshift( title ); 42 | if ( Array.isArray( stackAddition ) && stackAddition.length ) { 43 | this.stack.push( ...stackAddition ); 44 | } 45 | this.stack.push( '\n' ); 46 | 47 | return this.stack; 48 | 49 | }; 50 | 51 | export class BASE_MNEMONICA_ERROR extends Error { 52 | 53 | constructor ( message = BASE_ERROR_MESSAGE, additionalStack: string[] ) { 54 | 55 | super( message ); 56 | const BaseStack: any = this.stack; 57 | odp( this, 'BaseStack', { 58 | get () { 59 | return BaseStack; 60 | } 61 | } ); 62 | 63 | const stack = cleanupStack( BaseStack.split( '\n' ) ); 64 | 65 | if ( additionalStack ) { 66 | stack.unshift( ...additionalStack ); 67 | } 68 | 69 | this.stack = stack.join( '\n' ); 70 | 71 | } 72 | 73 | static get [ SymbolConstructorName ] () { 74 | return new String( `base of : ${MNEMONICA} : errors` ); 75 | } 76 | 77 | } 78 | 79 | Object.defineProperty( BASE_MNEMONICA_ERROR.prototype.constructor, 'name', { 80 | get () { 81 | return new String( 'BASE_MNEMONICA_ERROR' ); 82 | } 83 | } ); 84 | 85 | 86 | export const constructError = ( name: string, message: string ) => { 87 | const NamedErrorConstructor = class extends BASE_MNEMONICA_ERROR { 88 | constructor ( addition: string, stack: string[] ) { 89 | const saying = addition ? `${message} : ${addition}` : `${message}`; 90 | super( saying, stack ); 91 | } 92 | }; 93 | 94 | const reNamer = {} as { 95 | [ key: string ]: { 96 | prototype: { 97 | constructor: CallableFunction 98 | } 99 | }, 100 | }; 101 | reNamer[ name ] = NamedErrorConstructor; 102 | Object.defineProperty( reNamer[ name ].prototype.constructor, 'name', { 103 | get () { 104 | return new String( name ); 105 | } 106 | } ); 107 | return reNamer[ name ]; 108 | }; 109 | -------------------------------------------------------------------------------- /src/api/errors/throwModificationError.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import { constants } from '../../constants'; 4 | const { 5 | odp, 6 | SymbolReplaceUranus, 7 | // SymbolConstructorName 8 | } = constants; 9 | 10 | import { ErrorsTypes } from '../../descriptors/errors'; 11 | const { 12 | BASE_MNEMONICA_ERROR 13 | } = ErrorsTypes; 14 | 15 | import { cleanupStack, getStack } from './'; 16 | 17 | import TypesUtils from '../utils'; 18 | const { 19 | makeFakeModificatorType 20 | } = TypesUtils; 21 | 22 | import { utils } from '../../utils'; 23 | const { 24 | parse 25 | } = utils; 26 | 27 | import { makeInstanceModificator } from '../types/InstanceModificator'; 28 | 29 | export const throwModificationError = function ( this: any, error: any ) { 30 | 31 | // InstanceCreator 32 | // eslint-disable-next-line @typescript-eslint/no-this-alias 33 | const self = this; 34 | 35 | const { 36 | TypeName, 37 | type: { 38 | stack: typeStack 39 | }, 40 | args 41 | } = self; 42 | 43 | // if ( error[ SymbolConstructorName ] ) { 44 | // debugger; 45 | // } 46 | 47 | const exceptionReason = error.exceptionReason || error; 48 | 49 | if ( error.exceptionReason !== undefined ) { 50 | 51 | error.reasons.push( error.exceptionReason ); 52 | error.surplus.push( error ); 53 | 54 | throw error; 55 | 56 | } 57 | 58 | odp( error, 'exceptionReason', { 59 | get () { 60 | return exceptionReason; 61 | }, 62 | enumerable : true 63 | } ); 64 | 65 | const reasons: any[ typeof exceptionReason ] = [ exceptionReason ]; 66 | 67 | odp( error, 'reasons', { 68 | get () { 69 | return reasons; 70 | }, 71 | enumerable : true 72 | } ); 73 | const surplus: any[ typeof exceptionReason ] = []; 74 | odp( error, 'surplus', { 75 | get () { 76 | return surplus; 77 | }, 78 | enumerable : true 79 | } ); 80 | 81 | self.ModificatorType = makeFakeModificatorType( TypeName ); 82 | 83 | self.InstanceModificator = makeInstanceModificator( self ); 84 | 85 | // Constructor Invocation Itself 86 | const erroredInstance = new self.InstanceModificator(); 87 | 88 | erroredInstance[ SymbolReplaceUranus ]( error ); 89 | 90 | const stack: string[] = []; 91 | 92 | if ( error instanceof BASE_MNEMONICA_ERROR ) { 93 | 94 | stack.push( error.stack ); 95 | 96 | } else { 97 | 98 | const title = `\n<-- creation of [ ${TypeName} ] traced -->`; 99 | 100 | getStack.call( erroredInstance, title, [], throwModificationError ); 101 | 102 | stack.push( ...erroredInstance.stack ); 103 | 104 | const errorStack = error.stack.split( '\n' ); 105 | 106 | stack.push( '<-- with the following error -->' ); 107 | 108 | errorStack.forEach( ( line: string ) => { 109 | if ( !stack.includes( line ) ) { 110 | stack.push( line ); 111 | } 112 | } ); 113 | 114 | stack.push( '\n<-- of constructor definitions stack -->' ); 115 | stack.push( ...typeStack ); 116 | 117 | } 118 | 119 | const erroredInstanceStack = cleanupStack( stack ).join( '\n' ); 120 | 121 | // starting from Node.js v22 we should define this property through odp 122 | // that was unnecessary for v20, though seems new v8 optimized compiler 123 | // is gathering value from deep chain and while comparing it with 124 | // assignment operator, then it will not create this property 125 | // so we need direct property declaration here ... 126 | odp( erroredInstance, 'stack', { 127 | get () { 128 | return erroredInstanceStack; 129 | } 130 | } ); 131 | 132 | self.inheritedInstance = erroredInstance; 133 | 134 | // if hooks had some interception: start 135 | const results = self.invokePostHooks(); 136 | const { 137 | type, 138 | collection, 139 | } = results; 140 | 141 | if ( type.has( true ) || collection.has( true ) ) { 142 | return; 143 | } 144 | // if hooks had some interception: stop 145 | 146 | odp( erroredInstance, 'args', { 147 | get () { 148 | return args; 149 | } 150 | } ); 151 | 152 | odp( erroredInstance, 'originalError', { 153 | get () { 154 | return error; 155 | } 156 | } ); 157 | 158 | odp( erroredInstance, 'instance', { 159 | get () { 160 | return erroredInstance; 161 | } 162 | } ); 163 | 164 | odp( erroredInstance, 'extract', { 165 | get () { 166 | return () => { 167 | return erroredInstance.__self__.extract(); 168 | }; 169 | } 170 | } ); 171 | 172 | odp( erroredInstance, 'parse', { 173 | get () { 174 | return () => { 175 | return parse( erroredInstance ); 176 | }; 177 | } 178 | } ); 179 | 180 | throw erroredInstance; 181 | 182 | }; 183 | -------------------------------------------------------------------------------- /src/api/hooks/flowCheckers.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import { ErrorsTypes } from '../../descriptors/errors'; 4 | const { 5 | MISSING_CALLBACK_ARGUMENT, 6 | FLOW_CHECKER_REDEFINITION, 7 | } = ErrorsTypes; 8 | 9 | export const flowCheckers = new WeakMap(); 10 | export const registerFlowChecker = function (this: any, cb: () => unknown ) { 11 | 12 | if ( typeof cb !== 'function' ) { 13 | throw new MISSING_CALLBACK_ARGUMENT; 14 | } 15 | 16 | if ( flowCheckers.has( this ) ) { 17 | throw new FLOW_CHECKER_REDEFINITION; 18 | } 19 | 20 | flowCheckers.set( this, cb ); 21 | 22 | }; 23 | -------------------------------------------------------------------------------- /src/api/hooks/index.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | export { invokeHook } from './invokeHook'; 4 | export { registerHook } from './registerHook'; 5 | export { registerFlowChecker } from './flowCheckers'; 6 | 7 | -------------------------------------------------------------------------------- /src/api/hooks/invokeHook.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import { constants } from '../../constants'; 4 | const { 5 | MNEMONICA, 6 | } = constants; 7 | 8 | import { flowCheckers } from './flowCheckers'; 9 | 10 | import { hop } from '../../utils/hop'; 11 | 12 | export const invokeHook = function ( this: any, hookType: string, opts: { [ index: string ]: any } ) { 13 | 14 | const { 15 | type, 16 | existentInstance, 17 | inheritedInstance, 18 | args, 19 | // InstanceModificator, 20 | creator 21 | } = opts; 22 | 23 | const invocationResults = new Set(); 24 | 25 | // eslint-disable-next-line @typescript-eslint/no-this-alias 26 | const self = this; 27 | 28 | if ( hop( self.hooks, hookType ) ) { 29 | 30 | // "this" referes to 31 | // type, if called from types 32 | 33 | const { 34 | TypeName, 35 | // parentType, 36 | } = type; 37 | 38 | const hookArgs = { 39 | type, 40 | TypeName, 41 | existentInstance : existentInstance.constructor.name === MNEMONICA ? 42 | null : existentInstance, 43 | args, 44 | }; 45 | 46 | if ( typeof inheritedInstance === 'object' ) { 47 | Object.assign( hookArgs, { 48 | inheritedInstance, 49 | throwModificationError ( error: Error ) { 50 | creator.throwModificationError( error ); 51 | } 52 | } ); 53 | } 54 | 55 | // eslint-disable-next-line no-shadow 56 | this.hooks[ hookType ].forEach( ( hook: ( this: unknown, hookParams: typeof hookArgs ) => void ) => { 57 | const result = hook.call( self, hookArgs ); 58 | invocationResults.add( result ); 59 | } ); 60 | 61 | const flowChecker = flowCheckers.get( this ); 62 | if ( typeof flowChecker === 'function' ) { 63 | flowChecker 64 | .call( this, Object.assign( {}, { 65 | invocationResults, 66 | hookType, 67 | }, hookArgs ) ); 68 | } 69 | 70 | } 71 | 72 | return invocationResults; 73 | 74 | }; 75 | -------------------------------------------------------------------------------- /src/api/hooks/registerHook.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import { ErrorsTypes } from '../../descriptors/errors'; 4 | const { 5 | WRONG_HOOK_TYPE, 6 | MISSING_HOOK_CALLBACK, 7 | } = ErrorsTypes; 8 | 9 | const hooksTypes = [ 10 | 'preCreation', 11 | 'postCreation', 12 | 'creationError', 13 | ]; 14 | 15 | export const registerHook = function ( this: any, hookType: string, cb: CallableFunction ) { 16 | 17 | if ( !hooksTypes.includes( hookType ) ) { 18 | throw new WRONG_HOOK_TYPE; 19 | } 20 | 21 | if ( typeof cb !== 'function' ) { 22 | throw new MISSING_HOOK_CALLBACK; 23 | } 24 | 25 | if ( !this.hooks[ hookType ] ) { 26 | this.hooks[ hookType ] = new Set( [ cb ] ); 27 | } else { 28 | this.hooks[ hookType ].add( cb ); 29 | } 30 | 31 | }; 32 | -------------------------------------------------------------------------------- /src/api/index.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | // TODO : 4 | 5 | // events 6 | // handlers 7 | // helpers 8 | // loaders 9 | // transforms 10 | 11 | import { 12 | invokeHook, 13 | registerHook, 14 | registerFlowChecker, 15 | } from './hooks'; 16 | import { 17 | define, 18 | lookup, 19 | } from './types'; 20 | 21 | export * as errors from './errors'; 22 | 23 | export const hooks = { 24 | invokeHook, 25 | registerHook, 26 | registerFlowChecker, 27 | }; 28 | 29 | export const types = { 30 | define, 31 | lookup, 32 | }; 33 | -------------------------------------------------------------------------------- /src/api/types/InstanceModificator.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import { addProps } from './addProps'; 4 | 5 | export const makeInstanceModificator = ( self: any ) => { 6 | 7 | const { 8 | ModificationConstructor, 9 | existentInstance, 10 | ModificatorType, 11 | proto, 12 | } = self; 13 | 14 | const result = ModificationConstructor.call( 15 | existentInstance, 16 | ModificatorType, 17 | Object.assign( {}, proto ), 18 | ( __proto_proto__: any ) => { 19 | self.__proto_proto__ = __proto_proto__; 20 | addProps.call( self ); 21 | } 22 | ); 23 | 24 | return result; 25 | }; 26 | -------------------------------------------------------------------------------- /src/api/types/addProps.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import { constants } from '../../constants'; 4 | 5 | const { 6 | odp, 7 | } = constants; 8 | 9 | export const addProps = function ( this: any ): any { 10 | 11 | // eslint-disable-next-line @typescript-eslint/no-this-alias 12 | const self = this; 13 | 14 | const { 15 | type, 16 | existentInstance, 17 | args, 18 | config: { 19 | submitStack 20 | }, 21 | __proto_proto__: proto 22 | } = self; 23 | 24 | const { 25 | collection, 26 | subtypes, 27 | } = type; 28 | 29 | odp( proto, '__proto_proto__', { 30 | get () { 31 | return proto; 32 | } 33 | } ); 34 | 35 | odp( proto, '__args__', { 36 | get () { 37 | return args; 38 | } 39 | } ); 40 | 41 | odp( proto, '__collection__', { 42 | get () { 43 | return collection; 44 | } 45 | } ); 46 | 47 | odp( proto, '__subtypes__', { 48 | get () { 49 | return subtypes; 50 | } 51 | } ); 52 | 53 | odp( proto, '__type__', { 54 | get () { 55 | return type; 56 | } 57 | } ); 58 | 59 | odp( proto, '__parent__', { 60 | get () { 61 | return existentInstance; 62 | } 63 | } ); 64 | 65 | if ( submitStack ) { 66 | const { stack } = this; 67 | odp( proto, '__stack__', { 68 | get () { 69 | return stack.join( '\n' ); 70 | } 71 | } ); 72 | } 73 | 74 | odp( proto, '__creator__', { 75 | get () { 76 | return self; 77 | } 78 | } ); 79 | 80 | const timestamp = Date.now(); 81 | odp( proto, '__timestamp__', { 82 | get () { 83 | return timestamp; 84 | } 85 | } ); 86 | 87 | }; 88 | module.exports = { 89 | addProps 90 | }; 91 | -------------------------------------------------------------------------------- /src/api/types/createInstanceModificator.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | export default function ( obey: CallableFunction ) { 4 | 5 | const CreateInstanceModificator = function ( 6 | this: object, 7 | ModificatorType: CallableFunction, 8 | ModificatorTypePrototype: { [ index: string ]: unknown }, 9 | addProps: CallableFunction 10 | ) { 11 | 12 | // eslint-disable-next-line @typescript-eslint/no-this-alias 13 | const existentInstance = this; 14 | 15 | // const TripleSchemeClosure = function () { 16 | // const Mnemosyne = this; 17 | 18 | const Mnemosyne = {}; 19 | Reflect.setPrototypeOf( Mnemosyne, existentInstance ); 20 | addProps( Mnemosyne ); 21 | 22 | // about to setup constructor property for new instance 23 | // Object.defineProperty(inherited, 'constructor', { 24 | Object.defineProperty( Mnemosyne, 'constructor', { 25 | get () { 26 | return ModificatorType; 27 | }, 28 | enumerable : false 29 | } ); 30 | 31 | // modification itself 32 | // so now we have to copy all constructor props 33 | Object.entries( ModificatorTypePrototype ).forEach( ( entry ) => { 34 | const [ name, value ] = entry; 35 | if ( 36 | name !== 'constructor' 37 | // && 38 | // name !== SymbolConstructorName 39 | ) { 40 | ( ModificatorType.prototype[ name ] = value ); 41 | } 42 | } ); 43 | // 1. next line is done 4 our console.log will print proper type 44 | // and it should be explicit declaration, or it wouldn't see 45 | ModificatorType.prototype.constructor = ModificatorType; 46 | // therfore the following lines are commented 47 | // Object.defineProperty(ModificatorType.prototype, 'constructor', { 48 | // get () { 49 | // return ModificatorType; 50 | // } 51 | // }); 52 | 53 | // and set the prototype inherited 54 | Reflect.setPrototypeOf( ModificatorType.prototype, Mnemosyne ); 55 | // Reflect.setPrototypeOf(ModificatorType.prototype, inherited); 56 | 57 | obey( existentInstance, ModificatorType ); 58 | 59 | return ModificatorType; 60 | 61 | // }; 62 | // TripleSchemeClosure.prototype = existentInstance; 63 | // return new TripleSchemeClosure(); 64 | 65 | }; 66 | 67 | return CreateInstanceModificator; 68 | 69 | } 70 | -------------------------------------------------------------------------------- /src/api/types/obeyConstructor.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import { constants } from '../../constants'; 4 | const { 5 | SymbolUsed 6 | } = constants; 7 | 8 | import { ErrorsTypes } from '../../descriptors/errors'; 9 | const { 10 | PROTOTYPE_USED_TWICE, 11 | } = ErrorsTypes; 12 | 13 | export const obey = ( existentInstance: any, ModificatorType: any ) => { 14 | let protoConstructor: any = ModificatorType; 15 | while ( protoConstructor instanceof Function ) { 16 | if ( Object.prototype.hasOwnProperty.call( protoConstructor, SymbolUsed ) && protoConstructor[ SymbolUsed ]) { 17 | const error = new PROTOTYPE_USED_TWICE( `${protoConstructor.name}.prototype > ${ModificatorType.name}` ); 18 | throw error; 19 | } 20 | const sample = Reflect.getPrototypeOf( protoConstructor ); 21 | if ( sample instanceof Function ) { 22 | protoConstructor = sample; 23 | } else { 24 | Object.defineProperty( protoConstructor, SymbolUsed, { 25 | get () { 26 | return true; 27 | } 28 | } ); 29 | break; 30 | } 31 | } 32 | Reflect.setPrototypeOf( protoConstructor, existentInstance.constructor ); 33 | }; 34 | -------------------------------------------------------------------------------- /src/constants/index.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | // names 4 | const MNEMONICA = 'Mnemonica'; 5 | 6 | // O Great Mnemosyne! Please! 7 | // Save us from Oblivion... 8 | // https://en.wikipedia.org/wiki/Mnemosyne 9 | const MNEMOSYNE = 'Mnemosyne'; 10 | 11 | // Gaia - Wikipedia 12 | // https://en.wikipedia.org/wiki/Gaia 13 | const GAIA = 'Gaia'; 14 | const URANUS = 'Uranus'; 15 | 16 | // symbols 17 | const SymbolDefaultTypesCollection = Symbol( `default ${MNEMONICA} types collection` ); 18 | const SymbolParentType = Symbol( 'Parent of this SubType Collection' ); 19 | const SymbolConstructorName = Symbol( 'Defined Constructor Name' ); 20 | 21 | // SymbolGaia means we are reached prototype chain root 22 | const SymbolGaia = Symbol( 'Defined Gaia Constructor' ); 23 | const SymbolReplaceUranus = Symbol( 'Defined Method Name to Replace Gaia' ); 24 | 25 | const SymbolConfig = Symbol( 'Mnemonica Config Data' ); 26 | const SymbolUsed = Symbol( '.prototype used twice' ); 27 | 28 | // etc... 29 | const TYPE_TITLE_PREFIX = 'modificator of : '; 30 | 31 | // errors 32 | const ErrorMessages = { 33 | 34 | BASE_ERROR_MESSAGE : 'UNPREDICTABLE BEHAVIOUR', 35 | TYPENAME_MUST_BE_A_STRING : 'typename must be a string', 36 | HANDLER_MUST_BE_A_FUNCTION : 'handler must be a function', 37 | WRONG_TYPE_DEFINITION : 'wrong type definition', 38 | WRONG_INSTANCE_INVOCATION : 'wrong instance invocation', 39 | WRONG_MODIFICATION_PATTERN : 'wrong modification pattern', 40 | ALREADY_DECLARED : 'this type has already been declared', 41 | // EXISTENT_PROPERTY_REDEFINITION : 'attempt to re-define type constructor', 42 | WRONG_ARGUMENTS_USED : 'wrong arguments : should use proper invocation', 43 | WRONG_HOOK_TYPE : 'this hook type does not exist', 44 | MISSING_HOOK_CALLBACK : 'hook definition requires callback', 45 | MISSING_CALLBACK_ARGUMENT : 'callback is required argument', 46 | FLOW_CHECKER_REDEFINITION : 'attempt to re-define flow checker callback', 47 | OPTIONS_ERROR : 'options must be an object or a string', 48 | WRONG_STACK_CLEANER : 'wrong stack cleaner instanceof', 49 | PROTOTYPE_USED_TWICE : '.prototype used twice', 50 | 51 | }; 52 | 53 | import ModificationConstructor from '../api/types/createInstanceModificator'; 54 | 55 | const defaultOptions = { 56 | 57 | get ModificationConstructor () { 58 | return ModificationConstructor; 59 | }, 60 | 61 | // shall or not we use strict checking 62 | // for creation sub-instances Only from current type 63 | // or we might use up-nested sub-instances from chain 64 | get strictChain () { 65 | return true; 66 | }, 67 | 68 | // should we use forced errors checking 69 | // to make all inherited types errored 70 | // if there is an error somewhere in chain 71 | // disallow instance construction 72 | // if there is an error in prototype chain 73 | get blockErrors () { 74 | return true; 75 | }, 76 | 77 | // if it is necessary to collect stack 78 | // as a __stack__ prototype property 79 | // during the process of instance creation 80 | get submitStack () { 81 | return false; 82 | }, 83 | 84 | // await new Constructor() 85 | // must return value 86 | // optional ./issues/106 87 | get awaitReturn () { 88 | return true; 89 | }, 90 | 91 | } as Record; 92 | 93 | export const constants = { 94 | 95 | get 'SymbolParentType' () { 96 | return SymbolParentType; 97 | }, 98 | 99 | get 'SymbolConstructorName' () { 100 | return SymbolConstructorName; 101 | }, 102 | 103 | get 'SymbolGaia' () { 104 | return SymbolGaia; 105 | }, 106 | 107 | get 'SymbolReplaceUranus' () { 108 | return SymbolReplaceUranus; 109 | }, 110 | 111 | get 'SymbolDefaultTypesCollection' () { 112 | return SymbolDefaultTypesCollection; 113 | }, 114 | 115 | get 'SymbolConfig' () { 116 | return SymbolConfig; 117 | }, 118 | 119 | get 'SymbolUsed' () { 120 | return SymbolUsed; 121 | }, 122 | 123 | // constants 124 | get 'MNEMONICA' () { 125 | return MNEMONICA; 126 | }, 127 | get 'MNEMOSYNE' () { 128 | return MNEMOSYNE; 129 | }, 130 | get 'GAIA' () { 131 | return GAIA; 132 | }, 133 | get 'URANUS' () { 134 | return URANUS; 135 | }, 136 | get 'odp' () { 137 | return ( o: any, p: PropertyKey, attributes: PropertyDescriptor & ThisType ): any => { 138 | return Object.defineProperty( o, p, attributes ); 139 | }; 140 | }, 141 | 142 | get 'defaultOptions' () { 143 | return defaultOptions; 144 | }, 145 | 146 | get 'defaultOptionsKeys' () { 147 | return Object.keys( defaultOptions ); 148 | }, 149 | 150 | TYPE_TITLE_PREFIX, 151 | 152 | ErrorMessages, 153 | 154 | }; 155 | -------------------------------------------------------------------------------- /src/descriptors/errors/index.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import { constants } from '../../constants'; 4 | import { BASE_MNEMONICA_ERROR, constructError } from '../../api/errors'; 5 | 6 | const { 7 | ErrorMessages, 8 | } = constants; 9 | 10 | export const ErrorsTypes: { [ index: string ]: any } = { 11 | BASE_MNEMONICA_ERROR 12 | }; 13 | 14 | Object.entries( ErrorMessages ).forEach( entry => { 15 | const [ ErrorConstructorName, message ] = entry; 16 | // eslint-disable-next-line no-shadow, @typescript-eslint/no-explicit-any 17 | const ErrorConstructor: InstanceType = constructError( ErrorConstructorName, message ); 18 | ErrorsTypes[ ErrorConstructorName ] = ErrorConstructor; 19 | } ); 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/descriptors/index.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import { ErrorsTypes } from './errors'; 4 | import { 5 | types 6 | } from './types'; 7 | 8 | 9 | export const descriptors = { 10 | 11 | ...types, 12 | 13 | ErrorsTypes 14 | 15 | }; 16 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable @typescript-eslint/ban-ts-comment, indent, new-cap, space-before-function-paren */ 2 | 'use strict'; 3 | 4 | import { 5 | TypeLookup, 6 | IDEF, 7 | hook, 8 | hooksTypes, 9 | constructorOptions, 10 | Proto, 11 | SN, 12 | IDefinitorInstance 13 | } from './types'; 14 | export type { IDEF, ConstructorFunction } from './types'; 15 | 16 | import { constants } from './constants'; 17 | const { odp } = constants; 18 | 19 | import * as errorsApi from './api/errors'; 20 | import { descriptors } from './descriptors'; 21 | 22 | export const { 23 | defaultTypes, 24 | } = descriptors; 25 | 26 | function checkThis ( pointer: typeof mnemonica | typeof exports | unknown ): boolean { 27 | return pointer === mnemonica || pointer === exports; 28 | } 29 | 30 | export const define = function < 31 | T, 32 | // K extends IDEF, 33 | // H extends ThisType>, 34 | P extends object, 35 | N extends Proto, 36 | // so S it just basically allows nested constructors 37 | // and gives extracted props from constructHandler & proto 38 | // then it goes to new() keyword of define output 39 | S extends SN & N, 40 | R extends IDefinitorInstance 41 | > ( 42 | this: unknown, 43 | TypeName?: string, 44 | constructHandler?: IDEF, 45 | proto?: P, 46 | config?: constructorOptions, 47 | ): R { 48 | const types = checkThis( this ) ? defaultTypes : this || defaultTypes; 49 | return types.define( TypeName, constructHandler, proto, config ); 50 | }; 51 | 52 | export const lookup = function ( TypeNestedPath ) { 53 | const types = checkThis( this ) ? defaultTypes : this || defaultTypes; 54 | return types.lookup( TypeNestedPath ); 55 | } as TypeLookup; 56 | 57 | export const apply = function > ( entity: E, Constructor: IDEF, args: unknown[] = [] ): { 58 | [ key in keyof S ]: S[ key ] 59 | } { 60 | // @ts-ignore 61 | const result = new entity[ Constructor.TypeName ]( ...args ); 62 | return result; 63 | }; 64 | 65 | export const call = function > ( entity: E, Constructor: IDEF, ...args: unknown[] ): { 66 | [ key in keyof S ]: S[ key ] 67 | } { 68 | // @ts-ignore 69 | const result = new entity[ Constructor.TypeName ]( ...args ); 70 | return result; 71 | }; 72 | 73 | export const bind = function > ( entity: E, Constructor: IDEF ): ( ...args: unknown[] ) => { 74 | [ key in keyof S ]: S[ key ] 75 | } { 76 | return ( ...args ) => { 77 | // @ts-ignore 78 | const result = new entity[ Constructor.TypeName ]( ...args ); 79 | return result; 80 | }; 81 | }; 82 | 83 | export const decorate = function ( parentClass: unknown = undefined, proto?: object, config?: constructorOptions ) { 84 | const decorator = function ( cstr: T, s: ClassDecoratorContext ): T { 85 | if ( parentClass === undefined ) { 86 | return define( s.name, cstr, proto, config ) as unknown as T ; 87 | } 88 | // @ts-ignore 89 | return parentClass.define( s.name, cstr, proto, config ) as unknown as T; 90 | }; 91 | return decorator; 92 | }; 93 | 94 | export const registerHook = function ( Constructor: IDEF, hookType: hooksTypes, cb: hook ): void { 95 | // @ts-ignore 96 | Constructor.registerHook( hookType, cb ); 97 | }; 98 | 99 | export const mnemonica = Object.entries( { 100 | 101 | define, 102 | lookup, 103 | apply, 104 | call, 105 | bind, 106 | decorate, 107 | registerHook, 108 | 109 | ...descriptors, 110 | 111 | ...errorsApi, 112 | ...constants, 113 | 114 | } ).reduce( ( acc: { [ index: string ]: unknown }, entry: [ string, unknown ] ) => { 115 | const [ name, code ] = entry; 116 | odp( acc, name, { 117 | get () { 118 | return code; 119 | }, 120 | enumerable : true 121 | } ); 122 | return acc; 123 | }, {} ); 124 | 125 | export const { 126 | 127 | SymbolParentType, 128 | SymbolConstructorName, 129 | SymbolGaia, 130 | SymbolReplaceUranus, 131 | SymbolDefaultTypesCollection, 132 | SymbolConfig, 133 | MNEMONICA, 134 | MNEMOSYNE, 135 | GAIA, 136 | URANUS, 137 | TYPE_TITLE_PREFIX, 138 | ErrorMessages, 139 | createTypesCollection, 140 | 141 | } = mnemonica; 142 | 143 | 144 | export const defaultCollection = defaultTypes.subtypes; 145 | export const errors = descriptors.ErrorsTypes; 146 | 147 | export { utils } from './utils'; 148 | export { defineStackCleaner } from './utils'; 149 | /* eslint-enable @typescript-eslint/ban-ts-comment, indent, new-cap, space-before-function-paren */ 150 | -------------------------------------------------------------------------------- /src/types/index.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | /* eslint no-unused-vars: "off" */ 3 | 4 | // type RN = Record 5 | 6 | // type narrowable = string | number | boolean | symbol | object | undefined | void | null | []; 7 | // export type IDEF = { new(): T } | { (this: T): void }; 8 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 9 | export type IDEF = { new(): T } | { ( this: T, ...args: any[] ): void }; 10 | 11 | export interface ConstructorFunction { 12 | new( ...args: unknown[] ): ConstructorInstance; 13 | ( this: ConstructorInstance, ...args: unknown[] ): ConstructorInstance; 14 | prototype: ConstructorInstance; 15 | } 16 | 17 | export type TypeLookup = ( this: Map, TypeNestedPath: string ) => TypeClass; 18 | // export type TypeLookup = ( this: Map, TypeNestedPath: string ) => TypeClass; 19 | 20 | export type TypeClass = { 21 | new( ...args: unknown[] ): unknown; 22 | define: TypeAbsorber; 23 | lookup: TypeLookup; 24 | registerHook: ( type: 'preCreation' | 'postCreation' | 'creationError', hookCb: CallableFunction ) => unknown; 25 | }; 26 | 27 | export type TypeAbsorber = ( 28 | this: unknown, 29 | TypeName: string, 30 | // constructHandler: NewableFunction, 31 | constructHandler: CallableFunction, 32 | proto?: object, 33 | config?: object 34 | ) => TypeClass; 35 | 36 | // export type ITypeAbsorber = ( 37 | export type ITypeAbsorber = ( 38 | this: unknown, 39 | TypeName: string, 40 | constructHandler: IDEF, 41 | proto?: object, 42 | config?: object 43 | ) => ITypeClass; 44 | 45 | // export interface ITypeClass { 46 | export interface ITypeClass { 47 | // construct 48 | new( ...args: unknown[] ): T; 49 | // define, lookup, registerHook 50 | ( this: T, ...args: unknown[] ): T; 51 | // props 52 | define: ITypeAbsorber, 53 | // define: typeof define, 54 | lookup: TypeLookup, 55 | registerHook: ( type: 'preCreation' | 'postCreation' | 'creationError', hookCb: CallableFunction ) => unknown; 56 | } 57 | 58 | export type hooksTypes = 'preCreation' | 'postCreation' | 'creationError' 59 | export type hooksOpts = { 60 | TypeName: string, 61 | args: unknown[], 62 | existentInstance: object, 63 | inheritedInstance: object, 64 | } 65 | export type hook = { 66 | ( opts: hooksOpts ): void 67 | } 68 | 69 | export type constructorOptions = { 70 | 71 | // explicit declaration we wish use 72 | // an old style based constructors 73 | // e.g. with prototype described with: 74 | // createInstanceModificator200XthWay 75 | // or more general with: createInstanceModificator 76 | ModificationConstructor?: CallableFunction, 77 | 78 | // shall or not we use strict checking 79 | // for creation sub-instances Only from current type 80 | // or we might use up-nested sub-instances from chain 81 | strictChain?: boolean, 82 | 83 | // should we use forced errors checking 84 | // to make all inherited types errored 85 | // if there is an error somewhere in chain 86 | // disallow instance construction 87 | // if there is an error in prototype chain 88 | blockErrors?: boolean, 89 | 90 | // if it is necessary to collect stack 91 | // as a __stack__ prototype property 92 | // during the process of instance creation 93 | submitStack?: boolean, 94 | 95 | // await new Constructor() 96 | // must return value 97 | // optional ./issues/106 98 | awaitReturn?: boolean, 99 | 100 | }; 101 | 102 | 103 | export type Proto = Pick> & T; 104 | 105 | // type Narrowable = 106 | // string | number | boolean | symbol | object | undefined | void | null | []; 107 | // type RN = Record 108 | export type SN = Record unknown> 109 | 110 | export interface IDefinitorInstance { 111 | new( ...arg: unknown[] ): { 112 | [ key in keyof S ]: S[ key ] 113 | } 114 | define: IDefinitor 115 | registerHook: ( hookType: hooksTypes, cb: hook ) => void 116 | } 117 | 118 | export interface IDefinitor

{ 119 | >, S extends SN & M> ( 120 | this: unknown, 121 | TypeName: SubTypeName, 122 | constructHandler: IDEF, 123 | proto?: PP, 124 | config?: constructorOptions, 125 | ): IDefinitorInstance 126 | } 127 | 128 | export type TypeDescriptorInstance = { 129 | define: CallableFunction; 130 | lookup: CallableFunction; 131 | subtypes: object; 132 | }; 133 | -------------------------------------------------------------------------------- /src/utils/collectConstructors.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import { constants } from '../constants'; 4 | 5 | const { 6 | MNEMOSYNE, 7 | MNEMONICA, 8 | GAIA, 9 | } = constants; 10 | 11 | const getAdditor = ( constructors: string[] | { [ index: string ]: boolean } ) => { 12 | return Array.isArray( constructors ) ? 13 | ( name: string ) => { 14 | constructors.push( name ); 15 | } : ( name: string ) => { 16 | constructors[ name ] = true; 17 | }; 18 | 19 | }; 20 | 21 | const getAccumulator = ( asSequence: boolean ) => { 22 | return asSequence ? [] : {}; 23 | }; 24 | 25 | export const collectConstructors = ( self: object, asSequence = false ) => { 26 | 27 | const constructors = getAccumulator( asSequence ); 28 | const addToSequence = getAdditor( constructors ); 29 | 30 | if ( typeof self === 'object' ) { 31 | if ( self === null ) { 32 | return constructors; 33 | } 34 | } else { 35 | return constructors; 36 | } 37 | 38 | let proto: any = Reflect.getPrototypeOf( self ); 39 | let mnemonicaReached = false; 40 | while ( proto ) { 41 | if (!proto.constructor) { 42 | // this is Object.create(null) 43 | addToSequence( proto ); 44 | break; 45 | } 46 | const constructorName = proto.constructor.name; 47 | if ( constructorName === GAIA ) { 48 | self = proto; 49 | proto = Reflect.getPrototypeOf( self ); 50 | continue; 51 | } 52 | if ( constructorName === MNEMONICA ) { 53 | if ( !mnemonicaReached ) { 54 | addToSequence( constructorName ); 55 | addToSequence( MNEMOSYNE ); 56 | mnemonicaReached = true; 57 | } 58 | } else if ( constructorName === 'Object' ) { 59 | addToSequence( constructorName ); 60 | break; 61 | } else { 62 | addToSequence( constructorName ); 63 | } 64 | self = proto; 65 | proto = Reflect.getPrototypeOf( self ); 66 | } 67 | return constructors; 68 | }; 69 | -------------------------------------------------------------------------------- /src/utils/defineStackCleaner.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import { ErrorsTypes } from '../descriptors/errors'; 4 | import { stackCleaners } from '../api/errors'; 5 | 6 | const { 7 | WRONG_STACK_CLEANER 8 | } = ErrorsTypes; 9 | 10 | export const defineStackCleaner = (regexp:RegExp) => { 11 | if ( !( regexp instanceof RegExp ) ) { 12 | throw new WRONG_STACK_CLEANER; 13 | } 14 | stackCleaners.push( regexp ); 15 | }; 16 | -------------------------------------------------------------------------------- /src/utils/extract.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import { ErrorsTypes } from '../descriptors/errors'; 4 | const { 5 | WRONG_INSTANCE_INVOCATION 6 | } = ErrorsTypes; 7 | 8 | import { hop } from './hop'; 9 | 10 | export const extract = ( instance: any ) => { 11 | 12 | // at this situation this check is enough 13 | if ( instance !== Object( instance ) ) { 14 | throw new WRONG_INSTANCE_INVOCATION; 15 | } 16 | 17 | const extracted: { [ index: string ]: any } = {}; 18 | 19 | for ( const name in instance ) { 20 | if ( name === 'constructor' && !hop( instance, name ) ) { 21 | continue; 22 | } 23 | // if (name === 'timestamp') { 24 | // continue; 25 | // } 26 | 27 | extracted[ name ] = instance[ name ]; 28 | } 29 | 30 | return extracted; 31 | 32 | }; 33 | -------------------------------------------------------------------------------- /src/utils/hop.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | export const hop = (o: object, p: string|symbol) => Object.prototype.hasOwnProperty.call(o, p); 4 | -------------------------------------------------------------------------------- /src/utils/index.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import { collectConstructors } from './collectConstructors'; 4 | import { extract } from './extract'; 5 | import { parent } from './parent'; 6 | import { pick } from './pick'; 7 | import { toJSON } from './toJSON'; 8 | import { parse } from './parse'; 9 | import { merge } from './merge'; 10 | 11 | const utilsUnWrapped = { 12 | 13 | extract, 14 | pick, 15 | 16 | parent, 17 | 18 | toJSON, 19 | 20 | parse, 21 | merge, 22 | 23 | get collectConstructors () { 24 | return collectConstructors; 25 | }, 26 | 27 | }; 28 | 29 | const wrapThis = ( method: CallableFunction ) => { 30 | return function ( this: any, instance: any, ...args: any[] ) { 31 | return method( instance !== undefined ? instance : this, ...args ); 32 | }; 33 | }; 34 | 35 | export const utils: { [ index: string ]: any } = { 36 | 37 | ...Object.entries( utilsUnWrapped ) 38 | .reduce( ( methods: { [ index: string ]: any }, util ) => { 39 | const [ name, fn ] = util; 40 | methods[ name ] = wrapThis( fn ); 41 | return methods; 42 | }, {} ), 43 | 44 | }; 45 | 46 | export { defineStackCleaner } from './defineStackCleaner'; 47 | -------------------------------------------------------------------------------- /src/utils/merge.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import { ErrorsTypes } from '../descriptors/errors'; 4 | const { 5 | WRONG_ARGUMENTS_USED 6 | } = ErrorsTypes; 7 | 8 | export const merge = ( a: any, b: any, ...args: any[] ) => { 9 | 10 | // at this situation this check is enough 11 | if ( a !== Object( a ) ) { 12 | throw new WRONG_ARGUMENTS_USED( 'A should be an object' ); 13 | } 14 | 15 | // at this situation this check is enough 16 | if ( b !== Object( b ) ) { 17 | throw new WRONG_ARGUMENTS_USED( 'B should be an object' ); 18 | } 19 | 20 | if ( typeof a.fork !== 'function' ) { 21 | throw new WRONG_ARGUMENTS_USED( 'A should have A.fork()' ); 22 | } 23 | 24 | const aa = a.fork.call( b, ...args ); 25 | return aa; 26 | 27 | }; 28 | -------------------------------------------------------------------------------- /src/utils/parent.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import { ErrorsTypes } from '../descriptors/errors'; 4 | const { 5 | WRONG_INSTANCE_INVOCATION 6 | } = ErrorsTypes; 7 | 8 | // seek for firts parent instance 9 | // of instance prototype chain 10 | // with constructors of path 11 | export const parent = ( instance: any, path: string ): any => { 12 | 13 | // at this situation this check is enough 14 | if ( instance !== Object( instance ) ) { 15 | throw new WRONG_INSTANCE_INVOCATION; 16 | } 17 | 18 | const { 19 | __parent__: p 20 | } = instance; 21 | 22 | if ( !p ) { 23 | return; 24 | } 25 | 26 | if ( !path ) { 27 | return p; 28 | } 29 | 30 | const { 31 | constructor: { 32 | name 33 | } 34 | } = p; 35 | 36 | // seek throuh parent instances 37 | // about the fist constructor with this name 38 | return name === path ? 39 | p : parent( p, path ); 40 | 41 | }; 42 | -------------------------------------------------------------------------------- /src/utils/parse.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import { ErrorsTypes } from '../descriptors/errors'; 4 | const { 5 | WRONG_MODIFICATION_PATTERN, 6 | WRONG_ARGUMENTS_USED 7 | } = ErrorsTypes; 8 | 9 | import { constants } from '../constants'; 10 | const { 11 | SymbolGaia 12 | } = constants; 13 | 14 | import { extract } from './extract'; 15 | 16 | import { hop } from './hop'; 17 | 18 | export const parse = ( self: any ): any => { 19 | 20 | if ( !self || !self.constructor ) { 21 | throw new WRONG_MODIFICATION_PATTERN; 22 | } 23 | 24 | const proto = Reflect.getPrototypeOf( self ) as object; 25 | 26 | if ( self.constructor.name.toString() !== proto.constructor.name.toString() ) { 27 | throw new WRONG_ARGUMENTS_USED( `have to use "instance" itself: '${self.constructor.name}' vs '${proto.constructor.name}'` ); 28 | } 29 | 30 | const protoProto: any = Reflect.getPrototypeOf( proto ); 31 | if ( protoProto && proto.constructor.name.toString() !== protoProto.constructor.name.toString() ) { 32 | throw new WRONG_ARGUMENTS_USED( `have to use "instance" itself: '${proto.constructor.name}' vs '${protoProto.constructor.name}'` ); 33 | } 34 | 35 | // const args = self[SymbolConstructorName] ? 36 | // self[SymbolConstructorName].args : []; 37 | 38 | const { name } = proto.constructor; 39 | 40 | const props: any = extract( { ...self } ); 41 | // props.constructor = undefined; 42 | delete props.constructor; 43 | 44 | const joint: any = extract( Object.assign( {}, proto ) ); 45 | delete joint.constructor; 46 | 47 | let parent; 48 | let gaia; 49 | if ( hop( protoProto, SymbolGaia ) ) { 50 | parent = protoProto; 51 | // SymbolGaia means we are reached prototype chain root 52 | gaia = self[ SymbolGaia ]; 53 | } else { 54 | parent = parse( Reflect.getPrototypeOf( protoProto ) ); 55 | // eslint-disable-next-line prefer-destructuring 56 | gaia = parent.gaia; 57 | } 58 | 59 | return { 60 | 61 | name, 62 | 63 | props, 64 | // the line below copy symbols also 65 | 66 | self, 67 | proto, 68 | 69 | joint, 70 | // args, 71 | parent, 72 | gaia 73 | 74 | }; 75 | }; 76 | -------------------------------------------------------------------------------- /src/utils/pick.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import { ErrorsTypes } from '../descriptors/errors'; 4 | const { 5 | WRONG_INSTANCE_INVOCATION 6 | } = ErrorsTypes; 7 | 8 | export const pick = ( instance: any, ...args: string[] ) => { 9 | 10 | // at this situation this check is enough 11 | if ( instance !== Object( instance ) ) { 12 | throw new WRONG_INSTANCE_INVOCATION; 13 | } 14 | 15 | const props = args.reduce( ( arr: string[], el: string | string[] ) => { 16 | if ( Array.isArray( el ) ) { 17 | arr.push( ...el ); 18 | } else { 19 | arr.push( el ); 20 | } 21 | return arr; 22 | }, [] ); 23 | 24 | const picked = props.reduce( ( obj: { [ index: string ]: any }, name: string ) => { 25 | obj[ name ] = instance[ name ]; 26 | return obj; 27 | }, {} ); 28 | 29 | return picked; 30 | 31 | }; 32 | -------------------------------------------------------------------------------- /src/utils/toJSON.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import { extract } from './extract'; 4 | export const toJSON = ( instance: object ) => { 5 | 6 | const extracted = extract( instance ); 7 | return Object.entries( extracted ).reduce( ( o: string, entry: [ string, any ] ) => { 8 | 9 | const [ name, _value ] = entry; 10 | if ( [ null, undefined ].includes( _value ) ) { 11 | return o; 12 | } 13 | 14 | let value; 15 | 16 | try { 17 | value = JSON.stringify( _value ); 18 | } catch ( error: any | Error) { 19 | const description = 'This value type is not supported by JSON.stringify'; 20 | const { 21 | stack, 22 | message 23 | } = error; 24 | 25 | value = JSON.stringify( { 26 | description, 27 | stack, 28 | message 29 | } ); 30 | } 31 | 32 | o += `"${name}":${value},`; 33 | return o; 34 | 35 | }, '{' ) 36 | .replace( /,$/, '}' ); 37 | 38 | }; 39 | -------------------------------------------------------------------------------- /test-ts/test-decorate.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) { 3 | function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; } 4 | var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value"; 5 | var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null; 6 | var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {}); 7 | var _, done = false; 8 | for (var i = decorators.length - 1; i >= 0; i--) { 9 | var context = {}; 10 | for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p]; 11 | for (var p in contextIn.access) context.access[p] = contextIn.access[p]; 12 | context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); }; 13 | var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context); 14 | if (kind === "accessor") { 15 | if (result === void 0) continue; 16 | if (result === null || typeof result !== "object") throw new TypeError("Object expected"); 17 | if (_ = accept(result.get)) descriptor.get = _; 18 | if (_ = accept(result.set)) descriptor.set = _; 19 | if (_ = accept(result.init)) initializers.unshift(_); 20 | } 21 | else if (_ = accept(result)) { 22 | if (kind === "field") initializers.unshift(_); 23 | else descriptor[key] = _; 24 | } 25 | } 26 | if (target) Object.defineProperty(target, contextIn.name, descriptor); 27 | done = true; 28 | }; 29 | var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) { 30 | var useValue = arguments.length > 2; 31 | for (var i = 0; i < initializers.length; i++) { 32 | value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg); 33 | } 34 | return useValue ? value : void 0; 35 | }; 36 | var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) { 37 | if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : ""; 38 | return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name }); 39 | }; 40 | Object.defineProperty(exports, "__esModule", { value: true }); 41 | var __1 = require(".."); 42 | debugger; 43 | // eslint-disable-next-line @typescript-eslint/ban-types, @typescript-eslint/no-unused-vars 44 | // function defined (cstr: IDEF, s: unknown) { 45 | function defined(cstr, s) { 46 | debugger; 47 | var TypeDef = (0, __1.define)(s.name, cstr); 48 | Object.setPrototypeOf(cstr.prototype, new TypeDef); 49 | } 50 | var MyClass = function () { 51 | var _classDecorators = [defined]; 52 | var _classDescriptor; 53 | var _classExtraInitializers = []; 54 | var _classThis; 55 | var MyClass = _classThis = /** @class */ (function () { 56 | function MyClass_1() { 57 | debugger; 58 | this.z = 123; 59 | } 60 | return MyClass_1; 61 | }()); 62 | __setFunctionName(_classThis, "MyClass"); 63 | (function () { 64 | var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0; 65 | __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers); 66 | MyClass = _classThis = _classDescriptor.value; 67 | if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata }); 68 | __runInitializers(_classThis, _classExtraInitializers); 69 | })(); 70 | return MyClass = _classThis; 71 | }(); 72 | var myInstance = new MyClass; 73 | console.log(myInstance.z); 74 | var myInstance1 = new MyClass; 75 | console.log(myInstance1.z); 76 | debugger; 77 | -------------------------------------------------------------------------------- /test-ts/test-decorate.ts: -------------------------------------------------------------------------------- 1 | import { define, IDEF } from '..'; 2 | 3 | debugger; 4 | 5 | // eslint-disable-next-line @typescript-eslint/ban-types, @typescript-eslint/no-unused-vars 6 | // function defined (cstr: IDEF, s: ClassDecoratorContext) { 7 | function defined (cstr: T, s: ClassDecoratorContext) { 8 | debugger; 9 | const TypeDef = define(s.name, cstr); 10 | Object.setPrototypeOf(cstr.prototype, new TypeDef); 11 | } 12 | 13 | @defined 14 | class MyClass { 15 | z: number; 16 | constructor () { 17 | debugger; 18 | this.z = 123; 19 | } 20 | } 21 | 22 | const myInstance = new MyClass; 23 | console.log(myInstance.z); 24 | const myInstance1 = new MyClass; 25 | console.log(myInstance1.z); 26 | debugger; 27 | -------------------------------------------------------------------------------- /test-ts/test-example.ts: -------------------------------------------------------------------------------- 1 | import { define } from '..'; 2 | 3 | const FirstType = define( 'SomeType', function (this: { 4 | first: 'FirstType', 5 | }) { 6 | this.first = 'FirstType'; 7 | }); 8 | 9 | const SecondType = FirstType.define( 'SecondType', function ( this: { 10 | first: undefined, 11 | second: string, 12 | }) { 13 | this.first = undefined; 14 | this.second = 'SecondType'; 15 | }); 16 | 17 | const first = new FirstType(); 18 | 19 | type TSecondInstance = 20 | InstanceType; 21 | 22 | const second = new first.SecondType() as TSecondInstance; 23 | 24 | // { first: undefined, second: "SecondType" } 25 | console.log(second); 26 | 27 | 28 | -------------------------------------------------------------------------------- /test-ts/test-no-types.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import { define, apply, bind, call } from '..'; 4 | 5 | const SomeType = define( 'SomeType', function (this: { 6 | one: string, 7 | check: number, 8 | q: number 9 | }, gather: string, check: number ) { 10 | this.one = gather; 11 | this.check = check; 12 | this.q = 123; 13 | }, { 14 | l : 12345 15 | }); 16 | SomeType.registerHook('preCreation', () => { console.log('SomeType'); }); 17 | 18 | const SomeSubType = SomeType.define( 'SomeSubType', function ( this: { 19 | one: undefined, 20 | two: string, 21 | q: number, 22 | fn: () => object 23 | }) { 24 | this.one = undefined; 25 | this.two = 'SomeSubType'; 26 | this.q = 123; 27 | }, { 28 | k : 123 29 | }); 30 | 31 | const first = new SomeType('SomeArg'); 32 | SomeSubType.registerHook('preCreation', () => { console.log('SomeSubType'); }); 33 | 34 | const x = first.one; 35 | first.one = 123; // hinting is correct ! 36 | first.q = 'one'; // hinting is correct ! 37 | first.l = '111'; // hinting is correct ! 38 | first.x = 543; // hinting is NOT VERY correct ! 39 | 40 | const FinalType = SomeSubType.define( 'FinalType', class { 41 | one: string; 42 | q: number; 43 | three: string; 44 | constructor () { 45 | this.one = 'final one'; 46 | this.three = 'FinalType'; 47 | this.q = 123; 48 | } 49 | }); 50 | 51 | type SomeSubTypeInstance = InstanceType; 52 | const second = new first.SomeSubType() as SomeSubTypeInstance; 53 | const y = second.one; 54 | second.check = 123; // hinting is correct ! 55 | second.two = 'two'; 56 | second.y = 'no way'; // hinting is correct ! 57 | second.k = 'no way'; // hinting is correct ! 58 | 59 | type FinalTypeInstance = InstanceType; 60 | const final = new second.FinalType() as FinalTypeInstance; 61 | // const final = new FinalType(); 62 | final.one = 'must one'; 63 | final.two = 'must two'; 64 | final.three = 'must two'; 65 | final.check = 'there is mumber'; // hinting is correct ! 66 | final.z = 'no way'; // hinting is correct ! 67 | 68 | const z = final.one; 69 | 70 | // tslint:disable-next-line: no-console 71 | console.log('\nNo Typings: \n'); 72 | 73 | // tslint:disable-next-line: no-console 74 | console.log( 'first: ', first ); 75 | // tslint:disable-next-line: no-console 76 | console.log( 'second: ', second ); 77 | // tslint:disable-next-line: no-console 78 | console.log( 'final: ', final ); 79 | // tslint:disable-next-line: no-console 80 | console.log( '{ x, y, z }: ', { x, y, z } ); 81 | 82 | 83 | const aSub = apply(first, SomeSubType); 84 | console.log(aSub); 85 | const bSub = bind(first, SomeSubType)(); 86 | console.log(bSub); 87 | const cSub = call(first, SomeSubType); 88 | console.log(cSub); 89 | 90 | 91 | -------------------------------------------------------------------------------- /test/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | "env": { 3 | "node": true, 4 | "es6": true, 5 | 'mocha': true, 6 | }, 7 | "extends": "eslint:recommended", 8 | "parserOptions": { 9 | "ecmaVersion": 2018 10 | }, 11 | "plugins" : [ 12 | "mocha" 13 | ], 14 | "rules": { 15 | "linebreak-style": [ 16 | "error", 17 | "unix" 18 | ], 19 | "quotes": [ 20 | "error", 21 | "single" 22 | ], 23 | "semi": [ 24 | "error", 25 | "always" 26 | ], 27 | "no-unused-vars": "warn", 28 | "no-console": "off", 29 | "no-debugger": "off", 30 | "new-cap": "off" 31 | } 32 | }; 33 | -------------------------------------------------------------------------------- /test/bindProtoMethods.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const odp = ( obj, prop, attributes ) => { 4 | try { 5 | return Object.defineProperty( obj, prop, attributes ); 6 | } catch ( error ) { 7 | debugger; 8 | console.error( error ); 9 | } 10 | }; 11 | 12 | const { boundMethodErrorHandler } = require( './boundMethodErrorHandler' ); 13 | 14 | const bindMethod = function ( hookData, instance, methodName, MethodItself ) { 15 | const from = hookData; 16 | 17 | odp( instance, methodName, { 18 | get () { 19 | // eslint-disable-next-line @typescript-eslint/no-this-alias 20 | // eslint-disable-next-line no-shadow, @typescript-eslint/no-explicit-any 21 | return function ( ...args ) { 22 | // || instance; 23 | const applyTo = this !== undefined ? this : from; 24 | const exceptionReason = { 25 | method : MethodItself, 26 | methodName, 27 | this : this, 28 | from, 29 | instance, 30 | applyTo, 31 | asNew : false, 32 | args, 33 | }; 34 | 35 | try { 36 | let answer; 37 | if ( new.target ) { 38 | exceptionReason.asNew = true; 39 | answer = new MethodItself( ...args ); 40 | } else { 41 | answer = MethodItself.call( applyTo, ...args ); 42 | } 43 | 44 | if ( answer instanceof Promise ) { 45 | answer = answer.catch( ( error ) => { 46 | odp( exceptionReason, 'error', { 47 | value : error, 48 | enumerable : true 49 | } ); 50 | throw boundMethodErrorHandler( exceptionReason ); 51 | } ); 52 | } 53 | 54 | return answer; 55 | } catch ( error ) { 56 | odp( exceptionReason, 'error', { 57 | value : error, 58 | enumerable : true 59 | } ); 60 | 61 | throw boundMethodErrorHandler( exceptionReason ); 62 | } 63 | }; 64 | }, 65 | enumerable : true 66 | } ); 67 | }; 68 | 69 | const bindProtoMethods = function ( hookData ) { 70 | const { 71 | inheritedInstance, 72 | // existentInstance, 73 | } = hookData; 74 | const { proto } = inheritedInstance.__type__; 75 | const protoPointer = Reflect.getPrototypeOf( inheritedInstance ); 76 | Object.entries( protoPointer ).forEach( ( entry ) => { 77 | const [ mayBeMethodName, MayBeMethodFunction ] = entry; 78 | if ( mayBeMethodName === 'constructor' ) { 79 | return; 80 | } 81 | if ( MayBeMethodFunction instanceof Function && proto[ mayBeMethodName ] instanceof Function ) { 82 | // if (!hop(inheritedInstance, mayBeMethodName)) { 83 | bindMethod( hookData, protoPointer, mayBeMethodName, MayBeMethodFunction ); 84 | // } 85 | } 86 | } ); 87 | // Object.entries( existentInstance ).forEach( ( entry: [ string, any ] ) => { 88 | // const [ name, MayBeMethodFunction ] = entry; 89 | // if ( MayBeMethodFunction instanceof Function ) { 90 | // bindMethod( inheritedInstance, name, MayBeMethodFunction ); 91 | // } 92 | // } ); 93 | }; 94 | 95 | 96 | Object.assign( module.exports, { 97 | bindMethod, 98 | bindProtoMethods 99 | } ); 100 | -------------------------------------------------------------------------------- /test/boundMethodErrorHandler.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const odp = ( o, p, attributes ) => { 4 | return Object.defineProperty( o, p, attributes ); 5 | }; 6 | 7 | module.exports.boundMethodErrorHandler = ( exceptionReason ) => { 8 | 9 | const { 10 | applyTo, 11 | args, 12 | method, 13 | asNew, 14 | error 15 | } = exceptionReason; 16 | 17 | const reThrown = error.exceptionReason !== undefined; 18 | if ( reThrown ) { 19 | error.reasons.push( exceptionReason ); 20 | error.surplus.push( error ); 21 | return error; 22 | } else { 23 | odp( error, 'exceptionReason', { 24 | get () { 25 | return exceptionReason; 26 | }, 27 | enumerable : true 28 | } ); 29 | const reasons = [ exceptionReason ]; 30 | odp( error, 'reasons', { 31 | get () { 32 | return reasons; 33 | }, 34 | enumerable : true 35 | } ); 36 | const surplus = []; 37 | odp( error, 'surplus', { 38 | get () { 39 | return surplus; 40 | }, 41 | enumerable : true 42 | } ); 43 | } 44 | 45 | // if ( typeof applyTo === 'object' && applyTo.exception instanceof Function ) { 46 | if ( applyTo && applyTo.exception instanceof Function ) { 47 | let preparedException = error; 48 | try { 49 | // eslint-disable-next-line new-cap 50 | preparedException = new applyTo.exception( error, { 51 | args, 52 | exceptionReasonMethod : method, 53 | exceptionReasonObject : applyTo, 54 | reasonsIsNew : asNew 55 | } ); 56 | } catch ( additionalError ) { 57 | error.surplus.push( additionalError ); 58 | return error; 59 | } 60 | if ( preparedException instanceof Error ) { 61 | return preparedException; 62 | } 63 | } 64 | 65 | return error; 66 | 67 | }; 68 | -------------------------------------------------------------------------------- /test/createInstanceModificator200XthWay.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = function ( obey, defaultBehaviour ) { 4 | 5 | const CreateInstanceModificatorAncient200XthWay = function ( 6 | ModificatorType, 7 | ModificatorTypePrototype, 8 | addProps 9 | ) { 10 | 11 | // eslint-disable-next-line @typescript-eslint/no-this-alias 12 | const existentInstance = this; 13 | 14 | try { 15 | // const PreTripleSchemeClosure = function () { 16 | const TripleSchemeClosure = function () { 17 | 18 | // eslint-disable-next-line @typescript-eslint/no-this-alias 19 | const Mnemosyne = this; 20 | addProps( Mnemosyne ); 21 | 22 | // about to setup constructor property for new instance 23 | 24 | const Inherico = function () { 25 | 26 | // eslint-disable-next-line @typescript-eslint/no-this-alias 27 | const moreInherited = this; 28 | // so now we have to copy all the inherited props 29 | // to "this", leaving them untouched in future 30 | // Object.entries(ModificatorTypePrototype).forEach((entry) => { 31 | // const [name, value] = entry; 32 | // moreInherited[name] = value; 33 | // }); 34 | 35 | // give modification itself 36 | ModificatorType.prototype = moreInherited; 37 | 38 | 39 | Object.assign( ModificatorType.prototype, ModificatorTypePrototype ); 40 | 41 | // 2. Object.defineProperty below is done 42 | // to make "constructor" property non enumerable 43 | // cause we did it enumerable at "1." below 44 | Object.defineProperty( ModificatorType.prototype, 'constructor', { 45 | get () { 46 | return ModificatorType; 47 | }, 48 | enumerable : false 49 | } ); 50 | 51 | obey( existentInstance, ModificatorType ); 52 | 53 | return ModificatorType; 54 | 55 | }; 56 | 57 | // here "this" refers to an existent instance 58 | Inherico.prototype = Mnemosyne; 59 | // 1. next line is done 4 our console.log will print proper type 60 | // and it should be explicit declaration, or it wouldn't see 61 | Inherico.prototype.constructor = ModificatorType; 62 | // therfore the following lines are commented 63 | // Object.defineProperty(Inherico.prototype, 'constructor', { 64 | // get () { 65 | // return ModificatorType; 66 | // }, 67 | // }); 68 | 69 | return new Inherico(); 70 | }; 71 | 72 | // TripleSchemeClosure.prototype = this; 73 | TripleSchemeClosure.prototype = existentInstance; 74 | return new TripleSchemeClosure(); 75 | 76 | // }; 77 | // PreTripleSchemeClosure.prototype = existentInstance; 78 | // return new PreTripleSchemeClosure(); 79 | } catch ( error ) { 80 | 81 | try { 82 | if ( !existentInstance.goneToFallback ) { 83 | Object.defineProperty( existentInstance, 'goneToFallback', { 84 | get () { 85 | return error; 86 | } 87 | } ); 88 | } 89 | } catch ( err ) { 90 | debugger; 91 | console.error( err ); 92 | process.exit( 1 ); 93 | } 94 | 95 | 96 | return defaultBehaviour( obey ) 97 | .call( 98 | existentInstance, 99 | ModificatorType, 100 | ModificatorTypePrototype, 101 | addProps 102 | ); 103 | } 104 | }; 105 | 106 | return CreateInstanceModificatorAncient200XthWay; 107 | 108 | }; 109 | -------------------------------------------------------------------------------- /test/decorate.ts: -------------------------------------------------------------------------------- 1 | import { decorate, apply, ConstructorFunction } from '..'; 2 | 3 | @decorate( undefined, {}, { strictChain : false } ) 4 | class MyDecoratedClass { 5 | field: number; 6 | constructor () { 7 | this.field = 123; 8 | } 9 | } 10 | 11 | @decorate( MyDecoratedClass ) 12 | class MyDecoratedSubClass { 13 | sub_field: number; 14 | constructor () { 15 | this.sub_field = 321; 16 | } 17 | } 18 | 19 | export const myDecoratedInstance = new MyDecoratedClass; 20 | export const myDecoratedSubInstance = apply( myDecoratedInstance, MyDecoratedSubClass ); 21 | 22 | const MyFn = function () { 23 | this.sub_sub_field = 123; 24 | } as ConstructorFunction<{sub_sub_field: number}>; 25 | 26 | @decorate( MyDecoratedSubClass ) 27 | class MyDecoratedSubSubClass extends MyFn { 28 | sub_sub_field: number; 29 | constructor () { 30 | super(); 31 | this.sub_sub_field = 321; 32 | } 33 | } 34 | 35 | export const myDecoratedSubSubInstance = apply( myDecoratedSubInstance, MyDecoratedSubSubClass ); 36 | 37 | // eslint-disable-next-line @typescript-eslint/ban-ts-comment 38 | // @ts-ignore 39 | const MyOtherFn = MyDecoratedClass.define('MyOtherFn', function () { 40 | this.prop = 321; 41 | debugger; 42 | }); 43 | 44 | export const myOtherInstance = apply( myDecoratedInstance, MyOtherFn ); 45 | 46 | debugger; 47 | -------------------------------------------------------------------------------- /test/doc.example.js: -------------------------------------------------------------------------------- 1 | const mnemonica = require('..'); 2 | const { define } = mnemonica; 3 | const { 4 | extract, 5 | parse 6 | } = mnemonica.utils; 7 | 8 | const TypeModificationProcedure = function (opts) { 9 | // all this definitions 10 | // just to show the example 11 | // of how it works 12 | const { 13 | some, 14 | data, 15 | // we will re-define 16 | // "inside" property later 17 | // using nested sub-type 18 | inside 19 | } = opts; 20 | this.some = some; 21 | this.data = data; 22 | this.inside = inside; 23 | 24 | }; 25 | 26 | const TypeModificationPrototype = { 27 | description : 'SomeType Constructor' 28 | }; 29 | 30 | const SomeType = define('SomeTypeConstructor', 31 | TypeModificationProcedure, 32 | // prototype definition is NOT obligatory 33 | TypeModificationPrototype); 34 | 35 | const SomeSubType = SomeType.define('SomeSubType', function (opts) { 36 | const { 37 | other, 38 | // again 39 | inside 40 | } = opts; 41 | this.other = other; 42 | // here we will re-define 43 | // our previously defined property 44 | // with the new value 45 | this.inside = inside; 46 | }, { 47 | description : 'SomeSubType Constructor' 48 | }); 49 | 50 | const someTypeInstance = new SomeType({ 51 | some : 'arguments', 52 | data : 'necessary', 53 | inside : 'of SomeType definition' 54 | }); 55 | 56 | const someSubTypeInstance = 57 | // someTypeInstance is an instance 58 | // we did before, through the referenced 59 | // SomeType constructor we made using 60 | // define at the first step 61 | // of this fabulous adventure 62 | someTypeInstance 63 | // we defined SomeSubType 64 | // as a nested constructor 65 | // so we have to use it 66 | // utilising instance 67 | // crafted from it's parent 68 | .SomeSubType({ 69 | other : 'data needed', 70 | // and this is -re-definition 71 | // of "inside" property 72 | // as we promised before 73 | inside : ' of ... etc ...' 74 | }); 75 | 76 | 77 | const parsed = parse(someSubTypeInstance); 78 | console.log(parsed); 79 | 80 | const extracted = someSubTypeInstance.extract(); 81 | console.log(extracted); 82 | 83 | console.log(extract(someTypeInstance)); 84 | 85 | // true 86 | console.log(someTypeInstance instanceof SomeType); 87 | // true 88 | console.log(someSubTypeInstance instanceof SomeType); 89 | // true 90 | console.log(someSubTypeInstance instanceof SomeSubType); 91 | // who there can care... but, yes, it is: true 92 | console.log(someSubTypeInstance instanceof someTypeInstance); 93 | // and also this is true again: 94 | console.log(someSubTypeInstance instanceof someTypeInstance.SomeSubType); 95 | 96 | debugger; 97 | -------------------------------------------------------------------------------- /test/hooks.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const { assert, expect } = require( 'chai' ); 4 | 5 | const { 6 | defaultTypes, 7 | errors 8 | } = require( '..' ); 9 | 10 | const tests = ( opts ) => { 11 | 12 | const { 13 | userTypeHooksInvocations, 14 | typesFlowCheckerInvocations, 15 | typesPreCreationInvocations, 16 | typesPostCreationInvocations, 17 | } = opts; 18 | 19 | 20 | describe( 'Hooks Tests', () => { 21 | it( 'check invocations count', () => { 22 | assert.equal( 8, userTypeHooksInvocations.length ); 23 | // +2 24 | assert.equal( 171, typesFlowCheckerInvocations.length ); 25 | // +1 26 | assert.equal( 93, typesPreCreationInvocations.length ); 27 | // there are two errors on creation 28 | // checked before 29 | // that is why, and with clones 30 | // +1 31 | assert.equal( 156, typesPostCreationInvocations.length ); 32 | } ); 33 | } ); 34 | 35 | describe( 'check invocations of "this"', () => { 36 | userTypeHooksInvocations.forEach( entry => { 37 | const { 38 | self, 39 | opts: { 40 | type 41 | }, 42 | sort, 43 | kind, 44 | } = entry; 45 | it( `'this' for ${kind}-hook of ${sort} should refer to type ${type.TypeName}`, () => { 46 | assert.equal( self, type ); 47 | } ); 48 | } ); 49 | typesPreCreationInvocations.forEach( entry => { 50 | const { 51 | self, 52 | sort, 53 | kind, 54 | } = entry; 55 | it( `'this' for ${kind}-hook of ${sort} should refer to type defaultTypes`, () => { 56 | assert.equal( self, defaultTypes ); 57 | } ); 58 | } ); 59 | typesPostCreationInvocations.forEach( entry => { 60 | const { 61 | self, 62 | sort, 63 | kind, 64 | } = entry; 65 | it( `'this' for ${kind}-hook of ${sort} should refer to type defaultTypes`, () => { 66 | assert.equal( self, defaultTypes ); 67 | } ); 68 | } ); 69 | } ); 70 | 71 | describe( 'hooks environment', () => { 72 | try { 73 | defaultTypes.registerFlowChecker(); 74 | } catch ( error ) { 75 | it( 'Thrown with Missing Callback', () => { 76 | expect( error ).instanceOf( Error ); 77 | expect( error ).instanceOf( errors.MISSING_CALLBACK_ARGUMENT ); 78 | } ); 79 | } 80 | try { 81 | defaultTypes.registerFlowChecker( () => { } ); 82 | } catch ( error ) { 83 | it( 'Thrown with Re-Definition', () => { 84 | expect( error ).instanceOf( Error ); 85 | expect( error ).instanceOf( errors.FLOW_CHECKER_REDEFINITION ); 86 | } ); 87 | } 88 | try { 89 | defaultTypes.registerHook( 'WrongHookType', () => { } ); 90 | } catch ( error ) { 91 | it( 'Thrown with Re-Definition', () => { 92 | expect( error ).instanceOf( Error ); 93 | expect( error ).instanceOf( errors.WRONG_HOOK_TYPE ); 94 | } ); 95 | } 96 | try { 97 | defaultTypes.registerHook( 'postCreation' ); 98 | } catch ( error ) { 99 | it( 'Thrown with Re-Definition', () => { 100 | expect( error ).instanceOf( Error ); 101 | expect( error ).instanceOf( errors.MISSING_HOOK_CALLBACK ); 102 | } ); 103 | } 104 | } ); 105 | 106 | }; 107 | 108 | module.exports = tests; 109 | -------------------------------------------------------------------------------- /test/nested.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const ogp = Object.getPrototypeOf; 4 | 5 | const hop = ( o, p ) => Object.prototype.hasOwnProperty.call( o, p ); 6 | 7 | const { assert, expect } = require( 'chai' ); 8 | 9 | const { 10 | defaultTypes: types, 11 | } = require( '..' ); 12 | 13 | const tests = ( opts ) => { 14 | 15 | const { 16 | user, 17 | userPL1, 18 | userPL2, 19 | pl1Proto, 20 | pl2Proto, 21 | userPL_1_2, 22 | userPL_NoNew, 23 | UserTypeProto, 24 | USER_DATA 25 | } = opts; 26 | 27 | describe( 'nested type with old style check', () => { 28 | it( 'actually do construction', () => { 29 | assert.instanceOf( userPL1, types.UserType.subtypes.get( 'UserTypePL1' ) ); 30 | assert.instanceOf( userPL1, user.UserTypePL1 ); 31 | assert.equal( ogp( ogp( ogp( userPL1 ) ) ), user ); 32 | assert.equal( ogp( ogp( ogp( userPL2 ) ) ), user ); 33 | } ); 34 | it( 'actually do construction with nested methods', () => { 35 | assert.equal( userPL2.getSign(), 'pl_2' ); 36 | } ); 37 | it( '.constructor.name is correct', () => { 38 | assert.equal( userPL1.constructor.name, 'UserTypePL1' ); 39 | } ); 40 | it( '.prototype is correct', () => { 41 | expect( userPL1.constructor.prototype ).to.be.an( 'object' ) 42 | .that.includes( pl1Proto ); 43 | Object.entries( pl1Proto ).forEach( entry => { 44 | const [ key, value ] = entry; 45 | assert.equal( userPL1[ key ], value ); 46 | } ); 47 | } ); 48 | it( 'definition is correct', () => { 49 | const checker = { 50 | user_pl_1_sign : 'pl_1', 51 | }; 52 | Object.entries( checker ).forEach( entry => { 53 | const [ key, value ] = entry; 54 | assert.isTrue( hop( userPL1, key ) ); 55 | assert.equal( userPL1[ key ], value ); 56 | } ); 57 | } ); 58 | } ); 59 | 60 | describe( 'nested .getPrototypeOf(instence.constructor)', () => { 61 | it( 'must follow constructor inheritance for classes', () => { 62 | const protoConstructor = ogp( ogp( userPL2.constructor ) ); 63 | assert.equal( protoConstructor, user.constructor ); 64 | } ); 65 | } ); 66 | 67 | describe( 'nested type with new style check', () => { 68 | it( 'actually do construction', () => { 69 | assert.instanceOf( userPL2, types.UserType.subtypes.get( 'UserTypePL2' ) ); 70 | assert.instanceOf( userPL2, user.UserTypePL2 ); 71 | // assert.notInstanceOf(userPL2, Shaper); 72 | const shouldNot = userPL2 instanceof userPL2.constructor.Shaper; 73 | assert.equal( shouldNot, false ); 74 | } ); 75 | it( '.constructor.name is correct', () => { 76 | assert.equal( userPL2.constructor.name, 'UserTypePL2' ); 77 | } ); 78 | it( 'can construct without "new" keyword', () => { 79 | assert.instanceOf( userPL_NoNew, types.UserType ); 80 | // debugger; 81 | assert.instanceOf( userPL_NoNew, types.UserType.subtypes.get( 'UserTypePL2' ) ); 82 | } ); 83 | it( 'and insanceof stays ok', () => { 84 | assert.instanceOf( userPL_NoNew, user.UserTypePL2 ); 85 | } ); 86 | it( 'and even for sibling type', () => { 87 | assert.instanceOf( userPL_1_2, userPL1.UserTypePL2 ); 88 | } ); 89 | it( 'and for sibling type constructed without "new"', () => { 90 | assert.instanceOf( userPL_NoNew, userPL1.UserTypePL2 ); 91 | } ); 92 | it( '.prototype is correct', () => { 93 | expect( userPL2.constructor.prototype ) 94 | .to.be.an( 'object' ) 95 | .that.includes( pl2Proto ); 96 | } ); 97 | it( 'definitions are correct 4 class instances', () => { 98 | const checker = Object.assign( { 99 | user_pl_2_sign : 'pl_2', 100 | description : UserTypeProto.description 101 | }, USER_DATA, pl2Proto ); 102 | Object.keys( USER_DATA ).forEach( key => { 103 | assert.isFalse( hop( userPL2[ key ], key ) ); 104 | assert.equal( userPL2[ key ], USER_DATA[ key ] ); 105 | } ); 106 | 107 | Object.entries( checker ).forEach( entry => { 108 | const [ key, value ] = entry; 109 | assert.equal( userPL2[ key ], value ); 110 | } ); 111 | } ); 112 | it( 'definitions are correct for general', () => { 113 | const checker = Object.assign( { 114 | user_pl_1_sign : 'pl_1', 115 | description : UserTypeProto.description 116 | }, USER_DATA, pl1Proto ); 117 | Object.keys( USER_DATA ).forEach( key => { 118 | assert.isFalse( hop( userPL1[ key ], key ) ); 119 | } ); 120 | Object.entries( checker ).forEach( entry => { 121 | const [ key, value ] = entry; 122 | assert.equal( userPL1[ key ], value ); 123 | } ); 124 | } ); 125 | } ); 126 | }; 127 | 128 | module.exports = tests; 129 | -------------------------------------------------------------------------------- /test/parse.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const { assert, expect } = require( 'chai' ); 4 | 5 | const { 6 | SymbolConstructorName, 7 | MNEMONICA, 8 | utils: { 9 | parse 10 | }, 11 | errors, 12 | } = require( '..' ); 13 | 14 | const tests = ( opts ) => { 15 | 16 | const { 17 | user, 18 | userPL1, 19 | userPL2, 20 | userTC, 21 | evenMore, 22 | EmptyType, 23 | } = opts; 24 | 25 | describe( 'parse tests', () => { 26 | 27 | const samples = require( './parseSamples' ); 28 | 29 | try { 30 | parse( null ); 31 | } catch ( error ) { 32 | it( 'expect wrong parse invocation throw', () => { 33 | expect( error ).to.be.an 34 | .instanceof( errors 35 | .WRONG_MODIFICATION_PATTERN ); 36 | expect( error ).to.be.an 37 | .instanceof( Error ); 38 | } ); 39 | } 40 | 41 | try { 42 | parse( Object.getPrototypeOf( user ) ); 43 | } catch ( error ) { 44 | it( 'expect wrong parse invocation throw', () => { 45 | expect( error ).to.be.an 46 | .instanceof( errors 47 | .WRONG_ARGUMENTS_USED ); 48 | expect( error ).to.be.an 49 | .instanceof( Error ); 50 | } ); 51 | } 52 | try { 53 | parse( Object.getPrototypeOf( Object.getPrototypeOf( userPL1 ) ) ); 54 | } catch ( error ) { 55 | it( 'expect wrong parse invocation throw', () => { 56 | expect( error ).to.be.an 57 | .instanceof( errors 58 | .WRONG_ARGUMENTS_USED ); 59 | expect( error ).to.be.an 60 | .instanceof( Error ); 61 | } ); 62 | } 63 | 64 | const parsedUser = parse( user ); 65 | const parsedUserTC = parse( userTC ); 66 | const results = { 67 | parsedUser, 68 | parsedUserPL1 : parse( userPL1 ), 69 | parsedUserPL2 : parse( userPL2 ), 70 | 71 | parsedUserTC, 72 | parsedEvenMore : parse( evenMore ), 73 | }; 74 | 75 | it( 'expect proper first instance in chain constructor', () => { 76 | assert.equal( parsedUser.self[ SymbolConstructorName ], MNEMONICA ); 77 | assert.equal( parsedUser.parent.self[ SymbolConstructorName ], MNEMONICA ); 78 | assert.equal( parsedUserTC.self[ SymbolConstructorName ], MNEMONICA ); 79 | assert.equal( parsedUserTC.parent.self[ SymbolConstructorName ], MNEMONICA ); 80 | } ); 81 | 82 | it( 'should be ok with broken constructor chain', () => { 83 | 84 | const oneElseEmpty = new EmptyType(); 85 | const oneElseEmptyProto = Object.getPrototypeOf( Object.getPrototypeOf( Object.getPrototypeOf( oneElseEmpty ) ) ); 86 | 87 | expect( () => { 88 | oneElseEmptyProto[ SymbolConstructorName ] = undefined; 89 | } ).to.throw; 90 | expect( () => { 91 | delete oneElseEmptyProto[ SymbolConstructorName ]; 92 | } ).to.throw; 93 | } ); 94 | 95 | let count = 0; 96 | const compare = ( result, sample ) => { 97 | Object.entries( result ).forEach( entry => { 98 | const [ name, value ] = entry; 99 | const sampleValue = sample[ name ]; 100 | 101 | if ( name === 'parent' ) { 102 | return compare( value, sampleValue ); 103 | } 104 | 105 | if ( name === 'self' ) { 106 | it( `parse results should have same "self" with samples for ${name}`, () => { 107 | count++; 108 | assert.deepOwnInclude( value, sampleValue ); 109 | assert.deepOwnInclude( sampleValue, value ); 110 | } ); 111 | return; 112 | } 113 | if ( name === 'proto' ) { 114 | it( `parse results should have same "proto" with samples for ${name}`, () => { 115 | count++; 116 | // assert.deepInclude(value, sampleValue); 117 | assert.deepInclude( sampleValue, value ); 118 | } ); 119 | return; 120 | } 121 | 122 | it( `parse results should have same props with samples for "${name}"`, () => { 123 | count++; 124 | assert.deepEqual( value, sampleValue ); 125 | } ); 126 | } ); 127 | }; 128 | 129 | Object.keys( results ).forEach( key => { 130 | compare( samples[ key ], results[ key ] ); 131 | } ); 132 | 133 | it( 'should have exactly 60 amount of generated results~sample parse tests', () => { 134 | assert.equal( count, 60 ); 135 | } ); 136 | 137 | } ); 138 | 139 | }; 140 | 141 | module.exports = tests; 142 | -------------------------------------------------------------------------------- /test/perf.js: -------------------------------------------------------------------------------- 1 | 'use srict'; 2 | // setInterval(()=>{}, 1000); 3 | 4 | 5 | const { 6 | define, 7 | lookup 8 | } = require('..'); 9 | 10 | 11 | const HowMany = 1000; 12 | 13 | var start = process.hrtime.bigint(); 14 | // var start = Date.now(); 15 | 16 | 17 | var _define = define; 18 | for (let i = 0; i < HowMany; i++) { 19 | const its = _define(`NestedType${i}`, function () { 20 | this[ `nestedProp${i}` ] = `nestedProp${i}`; 21 | }); 22 | _define = its.define.bind(its); 23 | } 24 | 25 | var end = process.hrtime.bigint(); 26 | // var end = Date.now(); 27 | console.log('Diff 1:', end - start); 28 | 29 | 30 | start = process.hrtime.bigint(); 31 | 32 | const NestedType0 = lookup('NestedType0'); 33 | 34 | var instance = new NestedType0(); 35 | for (let i = 1; i < HowMany; i++) { 36 | instance = new instance[ `NestedType${i}` ](); 37 | } 38 | 39 | end = process.hrtime.bigint(); 40 | const diff2 = end - start; 41 | console.log('Diff 2:', diff2); 42 | 43 | 44 | const Creator = function (its) { 45 | const Maker = function () {}; 46 | Maker.prototype = its; 47 | return new Maker; 48 | }; 49 | 50 | start = process.hrtime.bigint(); 51 | 52 | var obj = { 53 | ObjType0 : {}, 54 | nestedProp0 : 'nestedProp0' 55 | }; 56 | var current = obj.ObjType0; 57 | for (let i = 1; i < HowMany; i++) { 58 | current[ `ObjType${i}` ] = new Creator({ 59 | [ `nestedProp${i}` ] : `nestedProp${i}` 60 | }); 61 | obj[ `nestedProp${i}` ] = current[ `ObjType${i}` ][ `nestedProp${i}` ]; 62 | current = current[ `ObjType${i}` ]; 63 | } 64 | 65 | end = process.hrtime.bigint(); 66 | const diff3 = end - start; 67 | console.log('Diff 3:', diff3); 68 | console.log('Diff 2/3:', diff2/diff3); 69 | 70 | 71 | console.log('Access Time'); 72 | 73 | start = process.hrtime.bigint(); 74 | // start = Date.now(); 75 | const propI = instance[ 'nestedProp0' ]; 76 | console.log(propI); 77 | end = process.hrtime.bigint(); 78 | // end = Date.now(); 79 | const diff4 = end - start; 80 | console.log('Diff 4:', diff4); 81 | 82 | 83 | start = process.hrtime.bigint(); 84 | // start = Date.now(); 85 | const propO = obj[ 'nestedProp0' ]; 86 | console.log(propO); 87 | end = process.hrtime.bigint(); 88 | // end = Date.now(); 89 | const diff5 = end - start; 90 | console.log('Diff 5:', diff5); 91 | console.log('Diff 4/5:', diff4/diff5); 92 | 93 | 94 | 95 | 96 | console.log('How Many'); 97 | 98 | const insArr = []; 99 | start = process.hrtime.bigint(); 100 | 101 | for (let i = 1; i < HowMany; i++) { 102 | insArr.push(new NestedType0()); 103 | } 104 | 105 | end = process.hrtime.bigint(); 106 | const diff6 = end - start; 107 | console.log('Diff 6:', diff6); 108 | 109 | 110 | const objArr = []; 111 | start = process.hrtime.bigint(); 112 | 113 | 114 | 115 | for (let i = 1; i < HowMany; i++) { 116 | objArr.push(new Creator(Object.create({ nestedProp0 : 'nestedProp0' }))); 117 | } 118 | 119 | end = process.hrtime.bigint(); 120 | const diff7 = end - start; 121 | console.log('Diff 7:', diff7); 122 | console.log('Diff 6/7:', diff6/diff7); 123 | 124 | 125 | -------------------------------------------------------------------------------- /test/test.mjs: -------------------------------------------------------------------------------- 1 | import { define, lookup } from '../module/index.js'; 2 | console.log('typeof define is function : ', typeof define === 'function'); 3 | console.log('typeof lookup is function :', typeof lookup === 'function'); 4 | -------------------------------------------------------------------------------- /test/throw-type-error.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = function (...args) { 4 | this.args = args; 5 | const a = { 6 | b : 1 7 | }; 8 | a.b.c.unable2set = 2; 9 | }; 10 | -------------------------------------------------------------------------------- /test/uncaughtExceptionTest.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const { assert, expect } = require('chai'); 4 | 5 | const tests = (opts) => { 6 | const { 7 | evenMore, 8 | ThrowTypeError 9 | } = opts; 10 | describe('uncaughtException test', () => { 11 | it('should throw proper error', (passedCb) => { 12 | const throwArgs = { 13 | uncaughtException : true 14 | }; 15 | 16 | setTimeout(() => { 17 | 18 | process.removeAllListeners('uncaughtException'); 19 | 20 | const onUncaughtException = function (error) { 21 | assert.equal( 22 | error.__args__[ 0 ], 23 | throwArgs 24 | ); 25 | expect(error).instanceOf(Error); 26 | expect(error).instanceOf(TypeError); 27 | expect(error).instanceOf(ThrowTypeError); 28 | expect(Object.hasOwnProperty.call(error, 'stack'), true); 29 | // debugger; 30 | console.log(error.stack); 31 | passedCb(); 32 | }; 33 | 34 | process.on('uncaughtException', onUncaughtException); 35 | new evenMore.ThrowTypeError(throwArgs); 36 | 37 | }, 100); 38 | }); 39 | }); 40 | }; 41 | 42 | module.exports = tests; 43 | -------------------------------------------------------------------------------- /tsconfig.jest.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "target": "ES6", 5 | "lib": [ 6 | "ES6", 7 | ], 8 | "strict": true, 9 | "alwaysStrict": true, 10 | "strictFunctionTypes": true, 11 | "diagnostics": true, 12 | "noImplicitThis": true, 13 | "extendedDiagnostics": true, 14 | "noImplicitReturns": true, 15 | "noFallthroughCasesInSwitch": true, 16 | "noUnusedLocals": true, 17 | "noUnusedParameters": true, 18 | "declaration": false, 19 | "sourceMap": true, 20 | "traceResolution": false, 21 | "removeComments": true, 22 | "experimentalDecorators": true, 23 | "forceConsistentCasingInFileNames": true, 24 | "types": [ 25 | "jest", 26 | "node" 27 | ], 28 | }, 29 | "include": [ 30 | "./src/**/*.ts", 31 | "./test-jest/**/*" 32 | ] 33 | } -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "target": "ES6", 5 | "lib": [ 6 | "ES6", 7 | ], 8 | "esModuleInterop": false, 9 | "allowSyntheticDefaultImports": false, 10 | "strict": true, 11 | "strictNullChecks": true, 12 | "alwaysStrict": true, 13 | "strictFunctionTypes": true, 14 | "diagnostics": true, 15 | "noImplicitThis": true, 16 | "extendedDiagnostics": true, 17 | "experimentalDecorators": true, 18 | "noImplicitReturns": true, 19 | "noFallthroughCasesInSwitch": true, 20 | "noUnusedLocals": true, 21 | "noUnusedParameters": true, 22 | "declaration": true, 23 | "sourceMap": true, 24 | "outDir": "build", 25 | "traceResolution": false, 26 | "isolatedModules": true, 27 | "removeComments": true, 28 | "forceConsistentCasingInFileNames": true, 29 | "types": [ 30 | "node" 31 | ] 32 | }, 33 | "include": [ 34 | "./src/**/*.ts", 35 | ], 36 | "exclude": [ 37 | "./build/**/*", 38 | "./lib/**/*", 39 | "./coverage/**/*", 40 | "./module/**/*", 41 | "./test/**/*", 42 | "./test-jest/**/*", 43 | "./test-ts/**/*" 44 | ] 45 | } --------------------------------------------------------------------------------