Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
* Very simple event emitter implementation.
*
* @example
* const ee = EventEmitter()
*
* ee.on('myEvent', (e) => {
* console.log(e.foo);
* })
*
* ee.emit('myEvent', {
* foo: 'bar',
* }) // prints `bar` in the console
*
* @class EventEmitter
*/
const EventEmitter = stampit({
init() {
/**
* Object with registered event listeners. Keys are event names.
*
* @private
* @memberof EventEmitter#
* @name _events
* @type Object
*/
this._events = {};
this._responding = true;
},
methods: {
/**
* Method used to register event listener.
*
* exclude: ["Sprite"],
* },
* });
*
* //matches entities of type 'Ball'
* const q3 = Query({
* criterions: {
* entityType: "Ball",
* },
* });
*
* @class Query
* @param {Object} opts
* @param {Object|Array} opts.criterions query criterions
*/
const Query = stampit({
deepProps: {
_shouldUpdate: false,
},
init(opts) {
let include = [];
let exclude = [];
let includeBitset;
let excludeBitset;
if (isArray(opts.criterions)) {
include = opts.criterions;
} else if (isObject(opts.criterions)) {
if (isNonEmptyString(opts.criterions.entityType)) {
this._matchType = opts.criterions.entityType;
}
import stampit from 'stampit';
import {Meta, Model} from './base';
import {BaseQuerySet, List, Total, StartDate, EndDate, CurrentMonth} from '../querySet';
const HourlyUsageQuerySet = stampit().compose(
BaseQuerySet,
List,
Total,
StartDate,
EndDate,
CurrentMonth
);
const HourlyUsageMeta = Meta({
name: 'hourlyusage',
pluralName: 'hourlyusages',
endpoints: {
'list': {
'methods': ['get'],
'path': '/v1.1/usage/hourly/'
}
});
/**
* OO wrapper around Card.
* @constructor
* @type {Card}
* @property {String} name
* @property {String} address_zip
* @property {String} address_state
* @property {String} address_country
* @property {String} address_line2
* @property {String} address_line1
* @property {String} address_city
*/
const Card = stampit()
.compose(Model)
.setQuerySet(CardQuerySet)
.setMeta(CardMeta);
export default Card;
import stampit from 'stampit';
import { isObject, toLowerFirstCase } from './helpers';
import FastBitset from 'fastbitset';
import FastArray from 'fast-array';
import EventEmitter from './EventEmitter';
/**
* Entity factory.
*
* @class Entity
*/
const Entity = stampit({
init(opts) {
this._modifications = FastArray();
this._used = false;
this.game = opts.game;
this.type = opts.type;
this.id = 0;
this.bitset = new FastBitset();
this.components = this.cs = {};
},
methods: {
/**
* Called when entity is created. Could be overriden (see {@link EntityStore#register}).
*
* @memberof Entity#
*/
* This model is *read only*.
* @constructor
* @type {TriggerTrace}
* @property {Number} id
* @property {String} instanceName
* @property {Number} triggerId
* @property {String} status
* @property {Date} executed_at
* @property {Number} duration
* @property {Object} [result = {}]
* @property {String} result.stderr
* @property {String} result.stdout
* @property {String} [links = {}]
*/
const TriggerTrace = stampit()
.compose(Model)
.setQuerySet(TriggerTraceQuerySet)
.setConstraints(TriggerTraceConstraints)
.setMeta(TriggerTraceMeta);
export default TriggerTrace;
* @property {Object} subscription
* @property {String} hard_limit
* @property {String} soft_limit
* @property {String} company_name
* @property {String} first_name
* @property {String} last_name
* @property {String} address_line1
* @property {String} address_line2
* @property {String} address_city
* @property {String} address_state
* @property {String} address_zip
* @property {String} address_country
* @property {String} tax_number
* @property {String} [failed_invoice = null]
*/
const Profile = stampit()
.compose(Model)
.setQuerySet(ProfileQuerySet)
.setMeta(ProfileMeta);
export default Profile;
* This model is *read only*.
* @constructor
* @type {ScriptEndpointTrace}
* @property {Number} id
* @property {String} instanceName
* @property {String} scriptEndpointName
* @property {String} status
* @property {Date} executed_at
* @property {Number} duration
* @property {Object} [result = {}]
* @property {String} result.stderr
* @property {String} result.stdout
* @property {String} [links = {}]
*/
const ScriptEndpointTrace = stampit()
.compose(Model)
.setMeta(ScriptEndpointTraceMeta)
.setQuerySet(ScriptEndpointTraceQuerySet)
.setConstraints(ScriptEndpointTraceConstraints);
export default ScriptEndpointTrace;
return this.fixed.refs._meta;
}
}
});
/**
* Used as a manager for {@link http://validatejs.org/#constraints|Constraints} object (validation). **Not** meant to be used directly.
* @constructor
* @type {ConstraintsMixin}
* @property {Object} _constraints private attribute which holds constraints object
* @example {@lang javascript}
* var MyStamp = stampit().compose(ConstraintsMixin);
*/
export const ConstraintsMixin = stampit({
methods: {
/**
* Sets constraints used for validation.
* @memberOf ConstraintsMixin
* @instance
* @param {Object} constraints plain JavaScript object
* @returns {ConstraintsMixin}
* @example {@lang javascript}
* var MyStamp = stampit().compose(ConstraintsMixin);
* var newObject = MyStamp().setConstraints({});
*/
import stampit from 'stampit';
import FastArray from 'fast-array';
const Pool = stampit({
init(options) {
this._pool = FastArray();
this._new = options._new;
this._reuse = options._reuse;
},
methods: {
free(obj) {
if (this._free) {
this._free(obj);
}
this._pool.push(obj);
},
allocate(...args) {
let obj;