token-generator = function () { var r; // Recall as new if new isn't provided :) if( Util.isnt.instanceof( NewClass, this ) ) { return ClassUtil.construct( NewClass, arguments ); } // call the constructor if ( Util.is.Function( this.initialize ) ) { r = this.initialize.apply(this, arguments); } // call all constructor hooks this.callInitHooks(); return typeof r != 'undefined' ? r : this; }
n/a
addDestroyHook = function ( fn ) { // (Function) || (String, args...) var args = Array.prototype.slice.call( arguments, 1 ); var destroy = typeof fn === 'function' ? fn : function () { this[fn].apply(this, args); }; this.prototype._destroyHooks = this.prototype._destroyHooks || []; this.prototype._destroyHooks.push(destroy); }
n/a
addInitHook = function (fn) { // (Function) || (String, args...) var args = Array.prototype.slice.call(arguments, 1); var init = typeof fn === 'function' ? fn : function () { this[fn].apply(this, args); }; this.prototype._initHooks = this.prototype._initHooks || []; this.prototype._initHooks.push(init); }
n/a
associate = function ( alias, TargetClass, type ) { var association = this.associations.get( TargetClass ); if ( association ) { return false; } return new Association( this, TargetClass, alias, type ); }
n/a
belongsTo = function ( alias, TargetClass ) { return this.associate( alias, TargetClass, 1 ); }
n/a
construct = function () { return ClassUtil.construct( this, arguments ); }
n/a
deassociate = function ( TargetClass ) { var association = this.associations.get( TargetClass ); if ( ! association ) { return false; } association.unbind(); if( association.targetAssocation ) { association.targetAssociation.unbind(); association.unbindTargetAssociation(); } return true; }
n/a
extend = function ( props ) { var NewClass = origExtend.apply( this, arguments ), proto = NewClass.prototype, parentProto = NewClass.parent.prototype; if( typeof NewClass !== 'function' ) { return NewClass; } // merge options if they exist if ( parentProto.options ) { // Create prototyped options on class's prototype proto.options = ClassUtil.create( parentProto.options ); // Now extend from props if( props.options ) { Util.extend( proto.options, props.options ); } } proto.setOptions = function ( options ) { // If this object doesn't have options directly if ( ! this.hasOwnProperty('options') ) { // We should create it from a parent proto, or just a new object this.options = this.options ? ClassUtil.create( this.options ) : {}; } // Now extend from props Util.extend( this.options, options ); // Return always options object, someone could reuse any var with this // Example: function ( o ) { o = this.setOptions( o ); /* ... */ } return this.options; }; return NewClass; }
...
var Class = require( 'findhit-class' ),
Util = require( 'findhit-util' ),
crypto = require( 'crypto' ),
debug = require( 'debug' )( 'token-generator' );
var TokenGenerator = module.exports = Class.extend({
options: {
/**
* @option salt
* @required
...
hasMany = function ( alias, TargetClass ) { return this.associate( alias, TargetClass, Infinity ); }
n/a
hasOne = function ( alias, TargetClass ) { return this.associate( alias, TargetClass, 1 ); }
n/a
include = function (props) { Util.extend(this.prototype, props); }
n/a
mergeOptions = function ( options ) { return Util.extend( this.prototype.options, options ); }
n/a
mixin = function (props) { Util.extend(this.prototype, props); }
n/a
parent = function () {}
n/a
parent = function () {}
n/a
addDestroyHook = function ( fn ) { // (Function) || (String, args...) var args = Array.prototype.slice.call( arguments, 1 ); var destroy = typeof fn === 'function' ? fn : function () { this[fn].apply(this, args); }; this.prototype._destroyHooks = this.prototype._destroyHooks || []; this.prototype._destroyHooks.push(destroy); }
n/a
addInitHook = function (fn) { // (Function) || (String, args...) var args = Array.prototype.slice.call(arguments, 1); var init = typeof fn === 'function' ? fn : function () { this[fn].apply(this, args); }; this.prototype._initHooks = this.prototype._initHooks || []; this.prototype._initHooks.push(init); }
n/a
associate = function ( alias, TargetClass, type ) { var association = this.associations.get( TargetClass ); if ( association ) { return false; } return new Association( this, TargetClass, alias, type ); }
n/a
belongsTo = function ( alias, TargetClass ) { return this.associate( alias, TargetClass, 1 ); }
n/a
construct = function () { return ClassUtil.construct( this, arguments ); }
n/a
deassociate = function ( TargetClass ) { var association = this.associations.get( TargetClass ); if ( ! association ) { return false; } association.unbind(); if( association.targetAssocation ) { association.targetAssociation.unbind(); association.unbindTargetAssociation(); } return true; }
n/a
extend = function ( props ) { var NewClass = origExtend.apply( this, arguments ), proto = NewClass.prototype, parentProto = NewClass.parent.prototype; if( typeof NewClass !== 'function' ) { return NewClass; } // merge options if they exist if ( parentProto.options ) { // Create prototyped options on class's prototype proto.options = ClassUtil.create( parentProto.options ); // Now extend from props if( props.options ) { Util.extend( proto.options, props.options ); } } proto.setOptions = function ( options ) { // If this object doesn't have options directly if ( ! this.hasOwnProperty('options') ) { // We should create it from a parent proto, or just a new object this.options = this.options ? ClassUtil.create( this.options ) : {}; } // Now extend from props Util.extend( this.options, options ); // Return always options object, someone could reuse any var with this // Example: function ( o ) { o = this.setOptions( o ); /* ... */ } return this.options; }; return NewClass; }
...
var Class = require( 'findhit-class' ),
Util = require( 'findhit-util' ),
crypto = require( 'crypto' ),
debug = require( 'debug' )( 'token-generator' );
var TokenGenerator = module.exports = Class.extend({
options: {
/**
* @option salt
* @required
...
hasMany = function ( alias, TargetClass ) { return this.associate( alias, TargetClass, Infinity ); }
n/a
hasOne = function ( alias, TargetClass ) { return this.associate( alias, TargetClass, 1 ); }
n/a
include = function (props) { Util.extend(this.prototype, props); }
n/a
mergeOptions = function ( options ) { return Util.extend( this.prototype.options, options ); }
n/a
mixin = function (props) { Util.extend(this.prototype, props); }
n/a
callDestroyHooks = function () { if ( this._destroyHooksCalled ) { return; } if ( parentProto.callDestroyHooks ) { parentProto.callDestroyHooks.call(this); } this._destroyHooksCalled = true; for (var i = 0, len = proto._destroyHooks.length; i < len; i++) { proto._destroyHooks[i].call(this); } }
n/a
callInitHooks = function () { if ( this._initHooksCalled ) { return; } if ( parentProto ) { parentProto.callInitHooks.call(this); } this._initHooksCalled = true; for (var i = 0, len = proto._initHooks.length; i < len; i++) { proto._initHooks[i].call(this); } }
n/a
0 = function () { var connectors = {}; Object.defineProperty( this, "connectors", { enumerable: false, writable: true, value: connectors, }); // Inject a protected getter Object.defineProperty( connectors, "get", { enumerable: false, writable: false, value: Connector._get.bind( connectors ), }); }
n/a