<commit_before>'use strict';

var i                = require('es5-ext/lib/Function/i')
  , isFunction       = require('es5-ext/lib/Function/is-function')
  , d                = require('es5-ext/lib/Object/descriptor')
  , serialize        = require('../_internals/serialize')
  , validateFunction = require('../_internals/validate-function')

  , defineProperty = Object.defineProperty
  , defineProperties = Object.defineProperties

  , nameRe = /^[A-Z][0-9a-zA-Z]*$/
  , Base, Plain, Relation, RelTransport, define, abstractLock, getConstructor;

getConstructor = function () {
	return function Self(value) { return Self.construct.apply(Self, arguments); };
};

module.exports = Base = getConstructor();
Plain = require('../_internals/plain');
Plain.create(Base);
Relation = require('../_internals/relation');
define = require('../_internals/define-basic');
RelTransport = require('../_internals/rel-transport');

defineProperties(Base, {
	_id_: d('c', 'Base'),
	create: d('c', function (name, construct, nsProps, objProps) {
		var constructor, error, isAbstract = abstractLock;
		abstractLock = false;

		if (!nameRe.test(name)) throw new Error(name + " is not a valid name");
		if (Base.hasOwnProperty(name)) throw new Error(name + " is already taken");

		// Normalize arguments
		if (!isFunction(construct)) {
			objProps = nsProps;
			nsProps = construct;
			construct = null;
		}

		// Validate
		error = this.combineErrors(
			construct && this._construct.validate(construct),
			nsProps && this.validatePropertiesNew(nsProps),
			!isAbstract && this.validateUndefinedNew(nsProps),
			objProps && this.prototype.validatePropertiesNew(objProps)
		);

		if (error) {
			error.message = "Invalid properties";
			throw error;
		}

		constructor = this.$create(name, construct);
		if (nsProps) constructor.$setProperties(nsProps);
		if (objProps) constructor.prototype.$setProperties(objProps);
		return constructor;
	}),
	$create: d('c', function (name, construct) {
		var constructor = Plain.create.call(this, getConstructor());
		defineProperties(constructor, { _id_: d(name) });
		defineProperties(constructor.prototype, {
			_id_: d(name + '#'),
			ns: d('c', constructor)
		});

		if (construct) constructor._construct.$set(construct);
		defineProperty(Base, name, d('c', constructor));
		return constructor;
	}),
	abstract: d('c', function (name, constructor, nsProps, objProps) {
		abstractLock = true;
		try {
			return this.create.apply(this, arguments);
		} finally {
			abstractLock = false;
		}
	}),
	rel: d('c', function (data) {
		if (data == null) return this;
		return new RelTransport(this, data);
	}),
	required: d.gs('c', function () {
		return new RelTransport(this, { required: true });
	}),
<commit_msg>Construct treated as regular property<commit_after>'use strict';

var i                = require('es5-ext/lib/Function/i')
  , isFunction       = require('es5-ext/lib/Function/is-function')
  , d                = require('es5-ext/lib/Object/descriptor')
  , serialize        = require('../_internals/serialize')
  , validateFunction = require('../_internals/validate-function')

  , defineProperty = Object.defineProperty
  , defineProperties = Object.defineProperties

  , nameRe = /^[A-Z][0-9a-zA-Z]*$/
  , Base, Plain, Relation, RelTransport, define, abstractLock, getConstructor;

getConstructor = function () {
	return function Self(value) { return Self.construct.apply(Self, arguments); };
};

module.exports = Base = getConstructor();
Plain = require('../_internals/plain');
Plain.create(Base);
Relation = require('../_internals/relation');
define = require('../_internals/define-basic');
RelTransport = require('../_internals/rel-transport');

defineProperties(Base, {
	_id_: d('c', 'Base'),
	create: d('c', function (name, construct, nsProps, objProps) {
		var constructor, error, isAbstract = abstractLock;
		abstractLock = false;

		if (!nameRe.test(name)) throw new Error(name + " is not a valid name");
		if (Base.hasOwnProperty(name)) throw new Error(name + " is already taken");

		// Normalize arguments
		if (!isFunction(construct)) {
			objProps = nsProps;
			nsProps = construct;
			construct = null;
		} else if (!nsProps) {
			nsProps = { construct: construct }
		} else {
			nsProps.construct = construct;
		}

		// Validate
		error = this.combineErrors(nsProps && this.validatePropertiesNew(nsProps),
			!isAbstract && this.validateUndefinedNew(nsProps),
			objProps && this.prototype.validatePropertiesNew(objProps));

		if (error) {
			error.message = "Invalid properties";
			throw error;
		}

		constructor = this.$create(name);
		if (nsProps) constructor.$setProperties(nsProps);
		if (objProps) constructor.prototype.$setProperties(objProps);
		return constructor;
	}),
	$create: d('c', function (name) {
		var constructor = Plain.create.call(this, getConstructor());
		defineProperties(constructor, { _id_: d(name) });
		defineProperties(constructor.prototype, {
			_id_: d(name + '#'),
			ns: d('c', constructor)
		});

		defineProperty(Base, name, d('c', constructor));
		return constructor;
	}),
	abstract: d('c', function (name, constructor, nsProps, objProps) {
		abstractLock = true;
		try {
			return this.create.apply(this, arguments);
		} finally {
			abstractLock = false;
		}
	}),
	rel: d('c', function (data) {
		if (data == null) return this;
		return new RelTransport(this, data);
	}),
	required: d.gs('c', function () {
		return new RelTransport(this, { required: true });
	}),

{'fraction_non_alphanumeric': 0.156794425087108, 'fraction_numerical': 0.0018338529249954153, 'mean_word_length': 4.159886471144749, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2710225', 'n_tokens_mistral': 1796, 'n_tokens_neox': 1651, 'n_words': 375}