Skip to content

Commit

Permalink
Merge pull request #133 from wentout/proto
Browse files Browse the repository at this point in the history
npm up
  • Loading branch information
wentout committed Apr 12, 2022
2 parents 69c809f + 5b0e202 commit 188eb8d
Show file tree
Hide file tree
Showing 28 changed files with 21,047 additions and 4,867 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ npm-debug.log
todo.txt
back.*
coverage
coveragejest
.nyc_output
.idea
test/example.js
4 changes: 2 additions & 2 deletions build/api/errors/exceptionConstructor.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const exceptionConsctructHandler = function (opts) {
});
stack.push('\n<-- of constructor definitions stack -->');
stack.push(...typeStack);
exception.stack = errors_2.cleanupStack(stack).join('\n');
exception.stack = (0, errors_2.cleanupStack)(stack).join('\n');
return exception;
};
const prepareException = function (target, error, ...args) {
Expand All @@ -104,7 +104,7 @@ const prepareException = function (target, error, ...args) {
error
});
});
ExceptionCreator.InstanceModificator = InstanceModificator_1.makeInstanceModificator(ExceptionCreator);
ExceptionCreator.InstanceModificator = (0, InstanceModificator_1.makeInstanceModificator)(ExceptionCreator);
return new ExceptionCreator.InstanceModificator();
};
exports.default = prepareException;
4 changes: 2 additions & 2 deletions build/api/errors/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const getStack = function (title, stackAddition, tillFunction) {
this.stack = (new Error()).stack;
}
this.stack = this.stack.split('\n').slice(1);
this.stack = exports.cleanupStack(this.stack);
this.stack = (0, exports.cleanupStack)(this.stack);
this.stack.unshift(title);
if (Array.isArray(stackAddition) && stackAddition.length) {
this.stack.push(...stackAddition);
Expand All @@ -43,7 +43,7 @@ class BASE_MNEMONICA_ERROR extends Error {
return BaseStack;
}
});
const stack = exports.cleanupStack(BaseStack.split('\n'));
const stack = (0, exports.cleanupStack)(BaseStack.split('\n'));
if (additionalStack) {
stack.unshift(...additionalStack);
}
Expand Down
4 changes: 2 additions & 2 deletions build/api/errors/throwModificationError.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const throwModificationError = function (error) {
enumerable : true
});
self.ModificatorType = makeFakeModificatorType(TypeName);
self.InstanceModificator = InstanceModificator_1.makeInstanceModificator(self);
self.InstanceModificator = (0, InstanceModificator_1.makeInstanceModificator)(self);
const erroredInstance = new self.InstanceModificator();
erroredInstance[SymbolReplaceGaia](error);
const stack = [];
Expand All @@ -62,7 +62,7 @@ const throwModificationError = function (error) {
stack.push('\n<-- of constructor definitions stack -->');
stack.push(...typeStack);
}
erroredInstance.stack = _1.cleanupStack(stack).join('\n');
erroredInstance.stack = (0, _1.cleanupStack)(stack).join('\n');
self.inheritedInstance = erroredInstance;
const results = self.invokePostHooks();
const { type, collection, namespace } = results;
Expand Down
2 changes: 1 addition & 1 deletion build/api/hooks/invokeHook.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const invokeHook = function (hookType, opts) {
const { type, existentInstance, inheritedInstance, args, creator } = opts;
const invocationResults = new Set();
const self = this;
if (hop_1.hop(self.hooks, hookType)) {
if ((0, hop_1.hop)(self.hooks, hookType)) {
const { TypeName, } = type;
const hookArgs = {
type,
Expand Down
8 changes: 4 additions & 4 deletions build/api/types/InstanceCreator.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const bindMethod = function (instance, methodName, MethodItself) {
value : error,
enumerable : true
});
throw bindedMethodErrorHandler_1.bindedMethodErrorHandler(exceptionReason);
throw (0, bindedMethodErrorHandler_1.bindedMethodErrorHandler)(exceptionReason);
});
}
return answer;
Expand All @@ -86,7 +86,7 @@ const bindMethod = function (instance, methodName, MethodItself) {
value : error,
enumerable : true
});
throw bindedMethodErrorHandler_1.bindedMethodErrorHandler(exceptionReason);
throw (0, bindedMethodErrorHandler_1.bindedMethodErrorHandler)(exceptionReason);
}
};
},
Expand Down Expand Up @@ -231,11 +231,11 @@ exports.InstanceCreator = function (type, existentInstance, args, chained) {
}
if (blockErrors && existentInstance instanceof Error) {
self.ModificatorType = makeFakeModificatorType(TypeName);
self.InstanceModificator = InstanceModificator_1.makeInstanceModificator(self);
self.InstanceModificator = (0, InstanceModificator_1.makeInstanceModificator)(self);
throw new self.InstanceModificator(...args);
}
self.invokePreHooks();
self.InstanceModificator = InstanceModificator_1.makeInstanceModificator(self);
self.InstanceModificator = (0, InstanceModificator_1.makeInstanceModificator)(self);
if (blockErrors) {
try {
self.inheritedInstance = new self.InstanceModificator(...args);
Expand Down
2 changes: 1 addition & 1 deletion build/api/types/Mnemosyne.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ConstructorFunction } from '../../types';
declare const _default: {
Gaia: ConstructorFunction<{}>;
Mnemosyne: ConstructorFunction<{
[x: string]: (this: any) => any;
[x: symbol]: (() => (this: any, uranus: any) => void) | (() => string);
extract(): (this: any) => {
[index: string]: any;
};
Expand Down
6 changes: 3 additions & 3 deletions build/api/types/Mnemosyne.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ const Gaia = function (Uranus) {
const MnemonicaProtoProps = {
extract () {
return function () {
return extract_1.extract(this);
return (0, extract_1.extract)(this);
};
},
pick () {
return function (...args) {
return pick_1.pick(this, ...args);
return (0, pick_1.pick)(this, ...args);
};
},
parent () {
return function (constructorLookupPath) {
return parent_1.parent(this, constructorLookupPath);
return (0, parent_1.parent)(this, constructorLookupPath);
};
},
clone () {
Expand Down
2 changes: 1 addition & 1 deletion build/api/types/TypeProxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ exports.TypeProxy.prototype.get = function (target, prop) {
if (propDeclaration) {
return propDeclaration;
}
if (hop_1.hop(type, prop)) {
if ((0, hop_1.hop)(type, prop)) {
return propDeclaration;
}
if (type.subtypes.has(prop)) {
Expand Down
2 changes: 1 addition & 1 deletion build/api/types/createInstanceModificator.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function default_1 () {
});
ModificatorType.prototype.constructor = ModificatorType;
Reflect.setPrototypeOf(ModificatorType.prototype, Mnemosyne);
obeyConstructor_1.obey(existentInstance, ModificatorType);
(0, obeyConstructor_1.obey)(existentInstance, ModificatorType);
return ModificatorType;
};
return CreateInstanceModificator;
Expand Down
2 changes: 1 addition & 1 deletion build/api/types/createInstanceModificator200XthWay.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function default_1 () {
},
enumerable : false
});
obeyConstructor_1.obey(existentInstance, ModificatorType);
(0, obeyConstructor_1.obey)(existentInstance, ModificatorType);
return ModificatorType;
};
Inherico.prototype = Mnemosyne;
Expand Down
4 changes: 2 additions & 2 deletions build/api/types/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,10 @@ const defineFromFunction = function (subtypes, TypeName, constructHandler = func
throw new HANDLER_MUST_BE_A_FUNCTION;
}
const asClass = isClass(constructHandler);
const modificatorBody = compileNewModificatorFunctionBody_1.default(TypeName, asClass);
const modificatorBody = (0, compileNewModificatorFunctionBody_1.default)(TypeName, asClass);
const makeConstructHandler = modificatorBody(constructHandler, CreationHandler, SymbolConstructorName);
if (!proto) {
if (hop_1.hop(constructHandler, 'prototype')) {
if ((0, hop_1.hop)(constructHandler, 'prototype')) {
proto = Object.assign({}, constructHandler.prototype);
}
else {
Expand Down
2 changes: 1 addition & 1 deletion build/api/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ const isClass = (fn) => {
return Reflect.getOwnPropertyDescriptor(fn, 'prototype').writable === false;
};
const makeFakeModificatorType = (TypeName, fakeModificator = function () { }) => {
const modificatorBody = compileNewModificatorFunctionBody_1.default(TypeName);
const modificatorBody = (0, compileNewModificatorFunctionBody_1.default)(TypeName);
const modificatorType = modificatorBody(fakeModificator, CreationHandler, SymbolConstructorName);
return modificatorType();
};
Expand Down
2 changes: 1 addition & 1 deletion build/descriptors/errors/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ exports.ErrorsTypes = {
};
Object.entries(ErrorMessages).forEach(entry => {
const [ErrorConstructorName, message] = entry;
const ErrorConstructor = errors_1.constructError(ErrorConstructorName, message);
const ErrorConstructor = (0, errors_1.constructError)(ErrorConstructorName, message);
exports.ErrorsTypes[ErrorConstructorName] = ErrorConstructor;
});
2 changes: 1 addition & 1 deletion build/descriptors/types/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ const typesCollectionProxyHandler = {
};
const createTypesCollection = (namespace = defaultNamespace, association, config = {}) => {
if (!(namespace instanceof Object) ||
!hop_1.hop(namespace, 'name') ||
!(0, hop_1.hop)(namespace, 'name') ||
!namespaces_1.namespaces.namespaces.has(namespace.name)) {
throw new NAMESPACE_DOES_NOT_EXIST;
}
Expand Down
4 changes: 2 additions & 2 deletions build/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ export declare const define: TypeAbsorber;
export declare const tsdefine: <T>(this: any, TypeName: string, constructHandler: IDEF<T>, proto?: object | undefined, config?: object | undefined) => ITypeClass<T>;
export declare const lookup: TypeLookup;
export declare const mnemonica: {
[index: string]: any;
[index: string]: unknown;
};
export declare const SymbolSubtypeCollection: any, SymbolConstructorName: any, SymbolGaia: any, SymbolReplaceGaia: any, SymbolDefaultNamespace: any, SymbolDefaultTypesCollection: any, SymbolConfig: any, MNEMONICA: any, MNEMOSYNE: any, GAIA: any, URANUS: any, TYPE_TITLE_PREFIX: any, ErrorMessages: any, createNamespace: any, namespaces: any, defaultNamespace: any, createTypesCollection: any;
export declare const SymbolSubtypeCollection: unknown, SymbolConstructorName: unknown, SymbolGaia: unknown, SymbolReplaceGaia: unknown, SymbolDefaultNamespace: unknown, SymbolDefaultTypesCollection: unknown, SymbolConfig: unknown, MNEMONICA: unknown, MNEMOSYNE: unknown, GAIA: unknown, URANUS: unknown, TYPE_TITLE_PREFIX: unknown, ErrorMessages: unknown, createNamespace: unknown, namespaces: unknown, defaultNamespace: unknown, createTypesCollection: unknown;
export declare const defaultCollection: any;
export declare const errors: any;
export { utils } from './utils';
Expand Down
2 changes: 1 addition & 1 deletion build/utils/extract.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const extract = (instance) => {
}
const extracted = {};
for (const name in instance) {
if (name === 'constructor' && !hop_1.hop(instance, name)) {
if (name === 'constructor' && !(0, hop_1.hop)(instance, name)) {
continue;
}
extracted[name] = instance[name];
Expand Down
2 changes: 1 addition & 1 deletion build/utils/parent.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ const parent = (instance, path) => {
}
const { constructor: { name } } = p;
return name === path ?
p : exports.parent(p, path);
p : (0, exports.parent)(p, path);
};
exports.parent = parent;
8 changes: 4 additions & 4 deletions build/utils/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@ const parse = (self) => {
throw new WRONG_ARGUMENTS_USED(`have to use "instance" itself: '${proto.constructor.name}' vs '${protoProto.constructor.name}'`);
}
const { name } = proto.constructor;
const props = extract_1.extract(Object.assign({}, self));
const props = (0, extract_1.extract)(Object.assign({}, self));
delete props.constructor;
const joint = extract_1.extract(Object.assign({}, proto));
const joint = (0, extract_1.extract)(Object.assign({}, proto));
delete joint.constructor;
let parent;
let gaia;
if (hop_1.hop(protoProto, SymbolGaia)) {
if ((0, hop_1.hop)(protoProto, SymbolGaia)) {
parent = protoProto;
gaia = self[SymbolGaia];
}
else {
parent = exports.parse(Reflect.getPrototypeOf(protoProto));
parent = (0, exports.parse)(Reflect.getPrototypeOf(protoProto));
gaia = parent.gaia;
}
return {
Expand Down
2 changes: 1 addition & 1 deletion build/utils/toJSON.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Object.defineProperty(exports, '__esModule', { value : true });
exports.toJSON = void 0;
const extract_1 = require('./extract');
const toJSON = (instance) => {
const extracted = extract_1.extract(instance);
const extracted = (0, extract_1.extract)(instance);
return Object.entries(extracted).reduce((o, entry) => {
const [name, _value] = entry;
if ([null, undefined].includes(_value)) {
Expand Down
11 changes: 11 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
preset : 'ts-jest',
testEnvironment : 'node',
testMatch : ['**/testjest/**/*.ts'],
globals : {
'ts-jest' : {
tsconfig : './testjest/tsconfig.json'
}
},
coverageDirectory : './coveragejest'
};

0 comments on commit 188eb8d

Please sign in to comment.