{"bugs":{"url":"https://github.com/UsabilityDynamics/abstract/issues"},"dist":{"shasum":"1b4b2810692c4960acb746da65af0e4407e7f3e9","tarball":"https://registry.npmjs.org/abstract/-/abstract-0.0.3.tgz","integrity":"sha512-ODqiJelS+FTNpm2b7lA+5J93Us+v4Uy8JwAj+UOOjR3dXEybXrwUTblqD8tVJJtNytW2U2Ybe7/nI9fXMw7x2A==","signatures":[{"sig":"MEUCIC0LlM61L4dZqO0LzCHvWyAFbuG7Qx/DZy7mWF6WuR0iAiEA5NBCY1mngweDfO6G+OkB22a7lAKIQU3TxZJCXDxCKBc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"./lib/abstract","name":"abstract","_from":".","author":{"url":"http://usabilitydynamics.com","name":"Usability Dynamics","email":"info@usabilitydynamics.com"},"readme":"Abstract.js\n-----------\nThe Abstract library is used for rapidly developing JavaScript prototypal \"Models\" and \"Instances\".\nEach new Model can be defined by you as needed within a special context which allows you to rapidly \ndefine complex constructors.\n\n    - Model Factory: Method in which you configure the Prototype Constructor and Instance Factory\n    - Instance Factory: Method within the Model Factory that is called on every Instance creation.\n    - Property Descriptors: Extended property descriptors.\n    \nBasic Usage\n===========\nThie is a basic example of creating a Model and then instantiating it.\n\n    // Require Module\n    var TCP_Proxy = require( 'abstract' ).createModel( function TCP_Proxy() {\n    \n      // Define a method for handling some task\n      function TaskWorker( task, fn ) {\n        \n        if( task.type === 'start_server' ) {\n          setTimeout( function() { fn(); }, 1000 );\n        }\n        \n      }\n      \n      // Create task queue shared by all instances\n      this.queue = require( 'async' ).queue( TaskWorker, 2 );\n      \n      // Run when all enqueued tasks are complete\n      this.queue.drain = function() {\n        console.log( 'All TCP Proxy queued tasks are processed.' );\n      }\n    \n      // Define Instance constructor, called on every initialization\n      this.defineConstructor( function( from, to ) {\n      \n        var self = this;\n        \n        // Set instance settings\n        this.set( 'from', from );\n        this.set( 'to', to );\n        \n        // Add to shared queue\n        this.queue.push({ type: 'start_server', from: from, to: to }, function( error ) {\n          console.log( \"TCP Server id %s forward from %s to %s started.\",  self.id, from, to );\n        });\n        \n      });\n      \n    });\n\n    // Instantiate 3 proxies\n    new TCP_Proxy( 7000, 7100 );\n    new TCP_Proxy( 8000, 8100 );\n    new TCP_Proxy( 9000, 9100 );\n    \n    // Monitor all events on all instances\n    TCP_Proxy.on( '*::error', console.error );\n    \n\nModule Methods\n==============\nIn addition to the Model method, used for creating Prototype models, the module exposes a variety of useful\nstatic methods that can be used outside of the Model context.\n\n    - Abstract.createModel( function MyPrototypeModel() {}): Creates a Model Factory environment.\n    - Abstract.create( prototype, properties ): Simple Object creation without a constructor.\n    - Abstract.defineProperty( target, property, descriptor ): Add single property.\n    - Abstract.defineProperties( target, properties ): Add multiple properties.\n\nIn the Abstract.Model example the MyPrototypeModel method is a method in which the actual model is configured.\nThe above methods are available within the Model Constructor, the \"target\" attribute is omitted since the\ncontext is set automatically when the methods are called via \"this\" object.\n\nModule Factory Methods\n======================\nThe below methods are available within the context of an Abstract.createModel( [fn] ) function.\n\n    - this.set( key, value ): Set meta key and value, will be used as defaults by instaces.\n    - this.get( key ): Get a value.\n    - this.defineInstance( function MyInstanceConstructor() {} ): Creates an Instance Factory environment.\n    - this.defineProperty( property, descriptor ): Add single property t othe instance prototype.\n    - this.defineProperties( properties ): Add multiple properties to the Instance prototype.\n    - this.addPrototype( prototype ): Insert prototype into prototype chain of the Instance object.\n\nInstance Factory Methods\n========================\nThe Abstract.prototype object contains properties that will be inherited by all Instances created from a Model.\nAll the default methods listen below are non-enumerable, but any methods you define for the Model will be\nenumerable by default, and wil overwrite any default methods.\n\n    - this.use( obj ): Inject external functionality into the context. Uses Abstract.addPrototype within context.\n    - this.mixin( obj ): Extends the Instance's prototype into the target object.\n    - this.extend( obj ): Extends the target object into the current instance.\n    - this.create( args ): Create an instance with provided args.\n    - this.set( key, value ): Set meta key and value.\n    - this.get( key ): Get key a value.\n\nProperty Descriptor Options\n===========================\nThe ECMA5 Object.defineProperty() method allows for advanced property settings, such as enumerability.\nThe Abstract modules allows for use of additional options in addition to the default options available\nvia Object.defineProperty().\n\nTo review, the standard ECMA5 options are:\n\n    - value: The value associated with the property. Can be any valid JavaScript value (number, object, function, etc) Defaults to undefined.\n    - get: A function which serves as a getter for the property, or undefined if there is no getter. The function return will be used as the value of property. Defaults to undefined.\n    - set: A function which serves as a setter for the property, or undefined if there is no setter. The function will receive as only argument the new value being assigned to the property. Defaults to undefined.\n    - configurable: true if and only if the type of this property descriptor may be changed and if the property may be deleted from the corresponding object. Defaults to false.\n    - enumerable: true if and only if this property shows up during enumeration of the properties on the corresponding object. Defaults to false.\n    - writable: True if and only if the value associated with the property may be changed with an assignment operator. Defaults to false.\n\nWhen using Abstract.defineProperty(), Abstract.create() or Abstract.defineProperties() the following options are also available:\n\n    - description: The plain-text description of the property.\n    - properties: Sets properties of the \"value\".\n    - watch: Configures the property value as watchable.\n\nThe additional options determine the way Model properties are handled and passed down to Instances.\nThe additional configuration is accessible via {YourObject}.meta.schema object. See Instance Meta section for more information.\n\n    - id: A random hash is generated on instantiation\n    - model: Set to the name of the constructor, e.g. \"MyPrototypeModel\" by default, used to determine \"path\".\n    - schema: Object containing the property schema generated from property descriptors.\n    - path: The prototype path to the current instance, e.g. Abstract.MyPrototypeModel.my_instance_id. (The Object.Function is omitted).\n\nEach Module and Instance must have a unique name which will be used to establish namespace and path.\nName will be generated from constructor's name if not specified.\n\nLicense\n=======\n\n(The MIT License)\n\nCopyright (c) 2013 Usability Dynamics, Inc. &lt;info@usabilitydynamics.com&gt;\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","scripts":{"test":"make test"},"_npmUser":{"name":"andy.potanin","email":"andy.potanin@usabilitydynamics.com"},"keywords":["object","module","class","prototype","events"],"repository":{"url":"https://github.com/UsabilityDynamics/abstract.git","type":"git"},"_npmVersion":"1.2.32","description":"Abstraction of JavaScript Objects.","maintainers":[{"name":"andy.potanin","email":"andy.potanin@usabilitydynamics.com"}],"contributors":[{"url":"http://usabilitydynamics.com","name":"Andy Potanin","email":"andy.potanin@usabilitydynamics.com"},{"url":"http://usabilitydynamics.com","name":"Ivan McCarthy","email":"ivan.mccarthy@usabilitydynamics.com"}],"dependencies":{"lodash":"*","object-settings":"*"},"readmeFilename":"Readme.md","devDependencies":{"Faker":"*","mocha":"*","colors":"*","should":"*","express":"*","request":"*","eventemitter2":"*"},"_id":"abstract@0.0.3","version":"0.0.3"}