{"_id":"classes","_rev":"19-7834d8bffb412359db9e8a39f7f2cd31","name":"classes","description":"A classical inheritence model with support for mixins","dist-tags":{"latest":"0.3.0"},"versions":{"0.1.5":{"author":{"name":"James Brumond","email":"kbjr14@gmail.com","url":"http://jbrumond.me"},"name":"classes","description":"A classical inheritence model","version":"0.1.5","repository":{"type":"git","url":"git://github.com/kbjr/class.js.git"},"engines":{"node":"*"},"dependencies":{},"devDependencies":{},"_npmUser":{"name":"k","email":"kbjr14@gmail.com"},"_id":"classes@0.1.5","_engineSupported":true,"_npmVersion":"1.0.104","_nodeVersion":"v0.6.0","_defaultsLoaded":true,"dist":{"shasum":"b9bd6973a63049bf64576af2f49844af723289a1","tarball":"https://registry.npmjs.org/classes/-/classes-0.1.5.tgz","integrity":"sha512-FnrKYBLUjnKXPw42uIL+cIKTw8Jd3YycpLrJ3PMlSoWn1O1PqN8+ubpG110IXnWZvUHvgpvNj83HxAXCTAquYQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDbyDaqQOyLJ2nJjehMbgkqFwaLnKnbHnagnR16WP2VgAIhAKZ2Y2rt0RaMiTVb/zX/6DoR7BCI/DChMU6pkib1eBtN"}]},"maintainers":[{"name":"k","email":"kbjr14@gmail.com"}],"directories":{}},"0.1.6":{"author":{"name":"James Brumond","email":"kbjr14@gmail.com","url":"http://jbrumond.me"},"name":"classes","description":"A classical inheritence model","version":"0.1.6","repository":{"type":"git","url":"git://github.com/kbjr/class.js.git"},"main":"classes.js","engines":{"node":"*"},"dependencies":{},"devDependencies":{},"_npmUser":{"name":"k","email":"kbjr14@gmail.com"},"_id":"classes@0.1.6","_engineSupported":true,"_npmVersion":"1.0.104","_nodeVersion":"v0.6.0","_defaultsLoaded":true,"dist":{"shasum":"7e2a4be6232a17090caf30b669e90acfa6f4d84e","tarball":"https://registry.npmjs.org/classes/-/classes-0.1.6.tgz","integrity":"sha512-BzXSSltiI08oOgunpzQn25sMMyDGOzCnwue/vOolhsfQHsqzMXVN/VizyuddV6oYefC2/DZmS+7okWa7m2Bh4Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBnUdLl+Ew6m2Q2YicEVS/w9lyC0AdnvmAi3qEnZI2BXAiEAoCY4b9s3Cq7M5xcTgRY7Va8Z2rdOjKJ6xCD7+mPvKRM="}]},"maintainers":[{"name":"k","email":"kbjr14@gmail.com"}]},"0.2.0":{"author":{"name":"James Brumond","email":"james@jbrumond.me","url":"http://jbrumond.me"},"name":"classes","description":"A classical inheritence model with support for mixins","version":"0.2.0","repository":{"type":"git","url":"git://github.com/kbjr/class.js.git"},"main":"classes.js","engines":{"node":"*"},"dependencies":{},"devDependencies":{},"_npmUser":{"name":"k","email":"kbjr14@gmail.com"},"_id":"classes@0.2.0","optionalDependencies":{},"_engineSupported":true,"_npmVersion":"1.1.21","_nodeVersion":"v0.6.18","_defaultsLoaded":true,"dist":{"shasum":"7aef3cd0de764286d11c0cb07e771a2b13220cfc","tarball":"https://registry.npmjs.org/classes/-/classes-0.2.0.tgz","integrity":"sha512-LiiSECZ55rrrkKKGH9LQDXYDLOPajFxFwvWtlUghi6RSKwnAtz60C2FphEhOheANdwLSr2HLe8sJbpYtzwXkbw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDb4JSu/PZgjlknRH6Sij/y8Wt/ur+rvSN4Gv2uPVBWLwIhAJ9CSXX0SUF5/kOoRQK4xm1wsZAsdXLj1G1AKJRO3XH+"}]},"readme":"","maintainers":[{"name":"k","email":"kbjr14@gmail.com"}]},"0.2.1":{"author":{"name":"James Brumond","email":"james@jbrumond.me","url":"http://jbrumond.me"},"name":"classes","description":"A classical inheritence model with support for mixins","version":"0.2.1","repository":{"type":"git","url":"git://github.com/kbjr/class.js.git"},"main":"classes.js","engines":{"node":"*"},"dependencies":{},"devDependencies":{},"readme":"# class.js\n\nSimple but powerful classical inheritence for JavaScript.\n\n## Node.js install\n\n```bash\n$ npm install classes\n```\n\n## Basic Example\n\n```javascript\n// A general animal class\nClass('Animal', {\n    \n    construct: function(name) {\n        this.name = name;\n    },\n    \n    makeNoise: function(noise) {\n        alert(noise);\n    }\n    \n});\n\n// Create a class for making people\nClass('Person').Extends('Animal', {\n    \n    speak: function(sayWhat) {\n        this.makeNoise(this.name + ' says: \"' + sayWhat + '\"');\n    }\n    \n});\n\n// Create an instance of our person class\nvar james = new Person('James');\n\n// And make them talk\njames.speak('Hello, World');\n```\n\n## Extending Classes\n\nThere are multiple allowed syntaxes for extending classes, which you can choose at your preference.\n\n```javascript\n// Create a base class first\nClass('A', {\n    ...\n});\n\n// Using the Extends() syntax\nClass('B').Extends(A, {\n    ...\n});\n\n// Using the complex Class() syntax\nClass('B', A, {\n    ...\n});\n\n// Using the extend() syntax\nA.extend('B', {\n    ...\n});\n```\n\nAlso note, that when using the `Extends()` syntax or the complex `Class()` syntax, both a parent class _variable_ (`A`) or _string_ (`'A'`) is allowed, but if you use the string syntax, the parent class must exist on the namespace object.\n\n## Using Super\n\nYou can call the super of any method at any time. This is done using the `parent` method on your class methods.\n\n```javascript\nClass('A').Extends(SomeOtherClass, {\n    \n    method: function() {\n        // Call the method's super\n        this.method.parent(this);\n    },\n    \n    methodWithArgs: function(arg1) {\n        // Call this method's super, passing the argument along\n        this.methodWithArgs.parent(this, arg1);\n    },\n\n    anotherMethod: function() {\n        // Call the super, but pass in the arguments object\n        this.anotherMethod.parentApply(this, arguments);\n    },\n    \n});\n```\n\n## Creating Anonymous Classes\n\nUsing class.js, classes don't have to be assigned a name. You can also tell the `Class()` function to simply return the constructed class function by passing a falsey first param (like `Class(null)`) or by simply not giving one as seen below.\n\n```javascript\n// This class will automatically be declared at global.Animal\nClass('Animal', {\n    ...\n});\n\n// This class will not be declared globally, but instead just returned\nvar Snake = Class().Extends(Animal, {\n    ...\n});\n\n// A slightly cleaner syntax\nvar Snake = Animal.extend({\n    // ...\n})l\n```\n\n## Defining Classes in Non-Global Scope\n\nTo define a class, but assign it somewhere other that the global object, you pass in a two key array as the class name. The first value is the object to define the class on, and the second is the class name.\n\n```javascript\n// This is where we will put the class\nvar someObject = { };\n\n// Now define the class\nClass([someObject, 'Animal'], {\n    ...\n});\n\n// And use the class\nvar animal = new someObject.Animal();\n```\n\nThis is equivilent to the following:\n\n```javascript\nsomeObject.Animal = Class({\n\t...\n});\n```\n\n## Using Mixins\n\nAs of version 0.2.0, mixins are supported. It should be noted that mixins are __not__ the same as sub-class inheritence. A single class can implement both a parent class as well as mixins. Mixins are defined using the `Class.mixin` method.\n\n```javascript\nClass.mixin('CanFoo', {\n\t\n\tfoo: function() {\n\t\talert('Foo!');\n\t}\n\t\n});\n```\n\nOnce created, a mixin is used with the `uses` method when defining a class.\n\n```javascript\nClass('Thing').Uses([ 'CanFoo' ], {\n\t\n\t// ...\n\t\n});\n\nvar thing = new Thing();\nthing.foo();\n```\n\nMixins are different from inheritence in the sense that they do no add to the inheritence chain, they simply extend the current class with certain functionality. You cannot use `instanceof` to determine mixin inheritence because classes are not instances of mixins; In fact, there is no such thing as an _instance_ of a mixin, they are just objects.\n\n## Using Namespaces\n\nBefore version 0.2.0, all new classes and mixins were defined, by default, on the global object, and if you wanted to define one elsewhere, you would have to use either anonymous classes or the array syntax (eg. `Class([exports, 'Foo'], ...)`). There is now a new way of defining namespaced classes that should prove useful, especially in the case of Node.js.\n\n```javascript\nvar Class = require('classes').Class;\nClass.namespace(exports);\n\nClass('Foo', {\n\t\n\t// ...\n\t\n});\n\nvar foo = new exports.Foo();\n```\n\nThe `Class.namespace()` function sets the default namespace, allowing shorter, more readable class declarations. Simply call `Class.namespace(exports)` at the top of your modules and your classes will automatically be defined in the correct space.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n","readmeFilename":"readme.md","_id":"classes@0.2.1","dist":{"shasum":"e946c6947d9176fddab040b833fb5157b8684a86","tarball":"https://registry.npmjs.org/classes/-/classes-0.2.1.tgz","integrity":"sha512-enqp5Nxide8LqDoAfPVingi5Wo6cxGwO7jWQu6CNvYq0YqIakwhy+8O3taUTkcSIJD/0SuBfpqhZqq1LWWwSow==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDoVVbQH04MoGgX642pdGGiSqnhn6xTot8KJ9oQyL5I2gIgaP+w01gKpmDlbXOMoAFOnABxfoUQ6wJgZoYNJYJ4sb8="}]},"_npmVersion":"1.1.65","_npmUser":{"name":"k","email":"kbjr14@gmail.com"},"maintainers":[{"name":"k","email":"kbjr14@gmail.com"}]},"0.2.2":{"author":{"name":"James Brumond","email":"james@jbrumond.me","url":"http://jbrumond.me"},"name":"classes","description":"A classical inheritence model with support for mixins","version":"0.2.2","repository":{"type":"git","url":"git://github.com/kbjr/class.js.git"},"main":"classes.js","engines":{"node":"*"},"dependencies":{},"devDependencies":{},"readme":"# class.js\n\nSimple but powerful classical inheritence for JavaScript.\n\n## Node.js install\n\n```bash\n$ npm install classes\n```\n\nIf using Node.js, you may want to make classes global using code such as this near the beginning of your application.\n\n```javascript\nglobal.Class = require('classes').Class;\n```\n\n## Basic Example\n\n```javascript\n// If using Node.js, the module needs to be required (unless global as shown above)\nvar Class = require('classes').Class;\n\n// A general animal class\nClass('Animal', {\n    \n    construct: function(name) {\n        this.name = name;\n    },\n    \n    makeNoise: function(noise) {\n        alert(noise);\n    }\n    \n});\n\n// Create a class for making people\nClass('Person').Extends('Animal', {\n    \n    speak: function(sayWhat) {\n        this.makeNoise(this.name + ' says: \"' + sayWhat + '\"');\n    }\n    \n});\n\n// Create an instance of our person class\nvar james = new Person('James');\n\n// And make them talk\njames.speak('Hello, World');\n```\n\n## Extending Classes\n\nThere are multiple allowed syntaxes for extending classes, which you can choose at your preference.\n\n```javascript\n// Create a base class first\nClass('A', {\n    ...\n});\n\n// Using the Extends() syntax\nClass('B').Extends(A, {\n    ...\n});\n\n// Using the complex Class() syntax\nClass('B', A, {\n    ...\n});\n\n// Using the extend() syntax\nA.extend('B', {\n    ...\n});\n```\n\nAlso note, that when using the `Extends()` syntax or the complex `Class()` syntax, both a parent class _variable_ (`A`) or _string_ (`'A'`) is allowed, but if you use the string syntax, the parent class must exist on the namespace object.\n\n## Using Super\n\nYou can call the super of any method at any time. This is done using the `parent` method on your class methods.\n\n```javascript\nClass('A').Extends(SomeOtherClass, {\n    \n    method: function() {\n        // Call the method's super\n        this.method.parent(this);\n    },\n    \n    methodWithArgs: function(arg1) {\n        // Call this method's super, passing the argument along\n        this.methodWithArgs.parent(this, arg1);\n    },\n\n    anotherMethod: function() {\n        // Call the super, but pass in the arguments object\n        this.anotherMethod.parentApply(this, arguments);\n    },\n    \n});\n```\n\n## Creating Anonymous Classes\n\nUsing class.js, classes don't have to be assigned a name. You can also tell the `Class()` function to simply return the constructed class function by passing a falsey first param (like `Class(null)`) or by simply not giving one as seen below.\n\n```javascript\n// This class will automatically be declared at global.Animal\nClass('Animal', {\n    ...\n});\n\n// This class will not be declared globally, but instead just returned\nvar Snake = Class().Extends(Animal, {\n    ...\n});\n\n// A slightly cleaner syntax\nvar Snake = Animal.extend({\n    // ...\n});\n```\n\n## Defining Classes in Non-Global Scope\n\nTo define a class, but assign it somewhere other that the global object, you pass in a two key array as the class name. The first value is the object to define the class on, and the second is the class name.\n\n```javascript\n// This is where we will put the class\nvar someObject = { };\n\n// Now define the class\nClass([someObject, 'Animal'], {\n    ...\n});\n\n// And use the class\nvar animal = new someObject.Animal();\n```\n\nThis is equivilent to the following:\n\n```javascript\nsomeObject.Animal = Class({\n\t...\n});\n```\n\n## Using Mixins\n\nAs of version 0.2.0, mixins are supported. It should be noted that mixins are __not__ the same as sub-class inheritence. A single class can implement both a parent class as well as mixins. Mixins are defined using the `Class.mixin` method.\n\n```javascript\nClass.mixin('CanFoo', {\n\t\n\tfoo: function() {\n\t\talert('Foo!');\n\t}\n\t\n});\n```\n\nOnce created, a mixin is used with the `uses` method when defining a class.\n\n```javascript\nClass('Thing').Uses([ 'CanFoo' ], {\n\t\n\t// ...\n\t\n});\n\nvar thing = new Thing();\nthing.foo();\n```\n\nMixins are different from inheritence in the sense that they do no add to the inheritence chain, they simply extend the current class with certain functionality. You cannot use `instanceof` to determine mixin inheritence because classes are not instances of mixins; In fact, there is no such thing as an _instance_ of a mixin, they are just objects.\n\n## Using Namespaces\n\nBefore version 0.2.0, all new classes and mixins were defined, by default, on the global object, and if you wanted to define one elsewhere, you would have to use either anonymous classes or the array syntax (eg. `Class([exports, 'Foo'], ...)`). There is now a new way of defining namespaced classes that should prove useful, especially in the case of Node.js.\n\n```javascript\nvar Class = require('classes').Class;\nClass.namespace(exports);\n\nClass('Foo', {\n\t\n\t// ...\n\t\n});\n\nvar foo = new exports.Foo();\n```\n\nThe `Class.namespace()` function sets the default namespace, allowing shorter, more readable class declarations. Simply call `Class.namespace(exports)` at the top of your modules and your classes will automatically be defined in the correct space.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n","readmeFilename":"readme.md","_id":"classes@0.2.2","dist":{"shasum":"498528787fcd4e42b0103b3f86adf973e8072d13","tarball":"https://registry.npmjs.org/classes/-/classes-0.2.2.tgz","integrity":"sha512-T5nseCihI5/Ssz0K9i9uP63A7gkZuWHFZjRfRRP1DQ9i1+0A21t/Uka9ILCnhs9hNrfh0/2mnqmMFfcsOk+oqw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDmtOw2cG7kttBf//Ftb8Ao/cs9LFXrpCr/WDBFmv8crAIhAMasWgIoePrr8KH2RGarKtm20A8CO3TbHFgHcZdMzem0"}]},"_npmVersion":"1.1.69","_npmUser":{"name":"k","email":"kbjr14@gmail.com"},"maintainers":[{"name":"k","email":"kbjr14@gmail.com"}]},"0.3.0":{"author":{"name":"James Brumond","email":"james@jbrumond.me","url":"http://jbrumond.me"},"name":"classes","description":"A classical inheritence model with support for mixins","version":"0.3.0","repository":{"type":"git","url":"git://github.com/kbjr/class.js.git"},"main":"classes.js","engines":{"node":"*"},"dependencies":{},"devDependencies":{},"readme":"# class.js\n\nSimple but powerful classical inheritence for JavaScript.\n\n## Node.js install\n\n```bash\n$ npm install classes\n```\n\nIf using Node.js, you may want to make classes global using code such as this near the beginning of your application.\n\n```javascript\nglobal.Class = require('classes').Class;\n```\n\n## Basic Example\n\n```javascript\n// If using Node.js, the module needs to be required (unless global as shown above)\nvar Class = require('classes').Class;\n\n// A general animal class\nClass('Animal', {\n    \n    construct: function(name) {\n        this.name = name;\n    },\n    \n    makeNoise: function(noise) {\n        alert(noise);\n    }\n    \n});\n\n// Create a class for making people\nClass('Person').Extends('Animal', {\n    \n    speak: function(sayWhat) {\n        this.makeNoise(this.name + ' says: \"' + sayWhat + '\"');\n    }\n    \n});\n\n// Create an instance of our person class\nvar james = new Person('James');\n\n// And make them talk\njames.speak('Hello, World');\n```\n\n## Extending Classes\n\nThere are multiple allowed syntaxes for extending classes, which you can choose at your preference.\n\n```javascript\n// Create a base class first\nClass('A', {\n    ...\n});\n\n// Using the Extends() syntax\nClass('B').Extends(A, {\n    ...\n});\n\n// Using the complex Class() syntax\nClass('B', A, {\n    ...\n});\n\n// Using the extend() syntax\nA.extend('B', {\n    ...\n});\n```\n\nAlso note, that when using the `Extends()` syntax or the complex `Class()` syntax, both a parent class _variable_ (`A`) or _string_ (`'A'`) is allowed, but if you use the string syntax, the parent class must exist on the namespace object.\n\n## Using Super\n\nYou can call the super of any method at any time. This is done using the `parent` method on your class methods.\n\n```javascript\nClass('A').Extends(SomeOtherClass, {\n    \n    method: function() {\n        // Call the method's super\n        this.method.parent(this);\n    },\n    \n    methodWithArgs: function(arg1) {\n        // Call this method's super, passing the argument along\n        this.methodWithArgs.parent(this, arg1);\n    },\n\n    anotherMethod: function() {\n        // Call the super, but pass in the arguments object\n        this.anotherMethod.parentApply(this, arguments);\n    },\n    \n});\n```\n\n## Creating Anonymous Classes\n\nUsing class.js, classes don't have to be assigned a name. You can also tell the `Class()` function to simply return the constructed class function by passing a falsey first param (like `Class(null)`) or by simply not giving one as seen below.\n\n```javascript\n// This class will automatically be declared at global.Animal\nClass('Animal', {\n    ...\n});\n\n// This class will not be declared globally, but instead just returned\nvar Snake = Class().Extends(Animal, {\n    ...\n});\n\n// A slightly cleaner syntax\nvar Snake = Animal.extend({\n    // ...\n});\n```\n\n## Defining Classes in Non-Global Scope\n\nTo define a class, but assign it somewhere other that the global object, you pass in a two key array as the class name. The first value is the object to define the class on, and the second is the class name.\n\n```javascript\n// This is where we will put the class\nvar someObject = { };\n\n// Now define the class\nClass([someObject, 'Animal'], {\n    ...\n});\n\n// And use the class\nvar animal = new someObject.Animal();\n```\n\nThis is equivilent to the following:\n\n```javascript\nsomeObject.Animal = Class({\n\t...\n});\n```\n\n## Using Mixins\n\nAs of version 0.2.0, mixins are supported. It should be noted that mixins are __not__ the same as sub-class inheritence. A single class can implement both a parent class as well as mixins. Mixins are defined using the `Class.mixin` method.\n\n```javascript\nClass.mixin('CanFoo', {\n\t\n\tfoo: function() {\n\t\talert('Foo!');\n\t}\n\t\n});\n```\n\nOnce created, a mixin is used with the `uses` method when defining a class.\n\n```javascript\nClass('Thing').Uses([ 'CanFoo' ], {\n\t\n\t// ...\n\t\n});\n\nvar thing = new Thing();\nthing.foo();\n```\n\nMixins are different from inheritence in the sense that they do no add to the inheritence chain, they simply extend the current class with certain functionality. You cannot use `instanceof` to determine mixin inheritence because classes are not instances of mixins; In fact, there is no such thing as an _instance_ of a mixin, they are just objects.\n\n## Using Namespaces\n\nBefore version 0.2.0, all new classes and mixins were defined, by default, on the global object, and if you wanted to define one elsewhere, you would have to use either anonymous classes or the array syntax (eg. `Class([exports, 'Foo'], ...)`). There is now a new way of defining namespaced classes that should prove useful, especially in the case of Node.js.\n\n```javascript\nvar Class = require('classes').Class;\nClass.namespace(exports);\n\nClass('Foo', {\n\t\n\t// ...\n\t\n});\n\nvar foo = new exports.Foo();\n```\n\nThe `Class.namespace()` function sets the default namespace, allowing shorter, more readable class declarations. Simply call `Class.namespace(exports)` at the top of your modules and your classes will automatically be defined in the correct space.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n","readmeFilename":"readme.md","_id":"classes@0.3.0","dist":{"shasum":"16e6033749ead443b1c54520341291708d9b678f","tarball":"https://registry.npmjs.org/classes/-/classes-0.3.0.tgz","integrity":"sha512-/6sfwnV5C00Z5gK26LOdxNfzeuYvNlWtVTGREYqAtyLizdoMxO4idl3WYl9qXzlViGALFhzX3UzST4lLCdAjSg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIH6+mGcQs87EfX/nZoyygUhngWp4MZGu1/rvNvrsAYcyAiBP0VuwuH4oq8rF3udOzrnoqdrFxyRVvRa+xTQ/hegQLw=="}]},"_npmVersion":"1.1.69","_npmUser":{"name":"k","email":"kbjr14@gmail.com"},"maintainers":[{"name":"k","email":"kbjr14@gmail.com"}]}},"readme":null,"maintainers":[{"name":"k","email":"kbjr14@gmail.com"}],"time":{"modified":"2022-06-13T06:05:59.215Z","created":"2011-11-17T06:48:01.977Z","0.1.5":"2011-11-17T06:48:08.383Z","0.1.6":"2011-11-18T12:36:00.490Z","0.2.0":"2012-06-03T21:57:18.470Z","0.2.1":"2012-11-18T22:19:32.944Z","0.2.2":"2012-12-27T03:42:54.988Z","0.3.0":"2013-01-18T23:32:59.638Z"},"author":{"name":"James Brumond","email":"james@jbrumond.me","url":"http://jbrumond.me"},"repository":{"type":"git","url":"git://github.com/kbjr/class.js.git"},"users":{"dodoss":true}}