{"_id":"parent.js","_rev":"6-c2f372dbe83aceab61a80f5168b8a9bf","name":"parent.js","description":"Javascript inheritance for a 5 years old","dist-tags":{"latest":"0.0.4"},"versions":{"0.0.3":{"name":"parent.js","version":"0.0.3","description":"Javascript inheritance for a 5 years old","main":"parent.js","dependencies":{"bower":"^1.3.12"},"devDependencies":{"mocha":"^2.0.1"},"scripts":{"test":"mocha tests.js"},"repository":{"type":"git","url":"https://github.com/javidgon/parent.js.git"},"keywords":["inheritance","wrapper","humans"],"author":{"name":"Jose Vidal"},"license":"MIT","bugs":{"url":"https://github.com/javidgon/parent.js/issues"},"homepage":"https://github.com/javidgon/parent.js","gitHead":"9332797aea60b6f25278b9c5636019c4995aca13","_id":"parent.js@0.0.3","_shasum":"15749d42a0a0d63ba288ba030a48cfdbbc278f94","_from":".","_npmVersion":"1.4.23","_npmUser":{"name":"javidgon","email":"javidgon@gmail.com"},"maintainers":[{"name":"javidgon","email":"javidgon@gmail.com"}],"dist":{"shasum":"15749d42a0a0d63ba288ba030a48cfdbbc278f94","tarball":"https://registry.npmjs.org/parent.js/-/parent.js-0.0.3.tgz","integrity":"sha512-dIOrfagPnnoeq54r4WsnsBenQ28waMA3EKdKgD//JnH0WLZnYZCubOJDoA3MEdIezb3NirCf7JOKD4yB6m3uuA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIB/18QnPkPWOHDd6qMo7UfdbExPhrkEEEkSAtD3Mc8VEAiBQ2dHFRhG5RmLuk1qSZ0fzsIs/ksf3O5NGZPlKSwpuJw=="}]}},"0.0.4":{"name":"parent.js","version":"0.0.4","description":"Javascript inheritance for a 5 years old","main":"lib/parent.js","dependencies":{},"devDependencies":{"mocha":"^2.0.1","uglify-js":"^2.4.15"},"scripts":{"test":"mocha test/tests.js","minify":"uglifyjs -o lib/parent.min.js lib/parent.js"},"repository":{"type":"git","url":"https://github.com/javidgon/parent.js.git"},"keywords":["inheritance","wrapper","humans"],"author":{"name":"Jose Vidal"},"license":"MIT","bugs":{"url":"https://github.com/javidgon/parent.js/issues"},"homepage":"https://github.com/javidgon/parent.js","gitHead":"64fb561b3ec3f5afd24699b29148a55bbfa72cfc","_id":"parent.js@0.0.4","_shasum":"da3eef805e4cfe16601d4e410ee6b031448ccd80","_from":".","_npmVersion":"1.4.23","_npmUser":{"name":"javidgon","email":"javidgon@gmail.com"},"maintainers":[{"name":"javidgon","email":"javidgon@gmail.com"}],"dist":{"shasum":"da3eef805e4cfe16601d4e410ee6b031448ccd80","tarball":"https://registry.npmjs.org/parent.js/-/parent.js-0.0.4.tgz","integrity":"sha512-cVMX/0WU9Qu8DdgwmGicIYa1wUAvzS3JWrnXTk/oCvWAyGGT/iLYsV3Dn5ln+QMRBrqGaHC9Vxxe61QzZiwcjg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCABzYxcHxR9TcsUKOFEy77bpn+mQjr06rQatnfKN4E9wIhAOgc+ic1hnw3cRJCyjyivnMGVp4ek7SNyByFAGH1fMxq"}]}}},"readme":"parent.js\n=========\n[![Build Status](https://travis-ci.org/javidgon/parent.js.svg)](https://travis-ci.org/javidgon/parent.js)\n> Javascript inheritance for a 5 years old\n\n**Javascript** is great, we all know that. **Prototypal inheritance** is really powerful and some people can do awesome\nthings with that, but let's face it, it has its quirks. Also 99% of the time we only want to create `Classes` and do simple inheritance. It shouldn't be complicated or prone to errors.\n\n**Parent.js** is a micro library (less than 30 lines of code), that allows you to create javascript `Classes` (or in `js` terminology `function constructors`) and, at the same time, inherit easily from other Classes.\n\n## Use\n\nFor using this library, you just need to create your `Classes` with the following syntax:\n```javascript\nvar Person = Class({\n  // Methods go here...\n  ...\n}, <BaseClass>)\n```\n\nAnd this is it! Please keep in mind that `<BaseClass>` is optional. Not every class needs to inherit! :smirk:.\nLet's see more examples:\n\n```javascript\nvar Person = Class({\n  initialize: function (name, surname) {\n    this.name = name;\n    this.surname = surname;\n  },\n  sayHi: function () {\n    return 'Hi I\\'m a Person!!';\n  }\n});\n\nvar Student = Class({\n  initialize: function (name, surname, bachelor) {\n    this.super.initialize(name, surname);\n    this.bachelor = bachelor;\n  },\n  study: function () {\n    return 'I\\'m Studying!'\n    \n  },\n  sayHi: function () {\n    return 'Hi I\\'m a Student!!';\n  }\n}, Person);\n\nvar student = new Student('Jose', 'Vidal', 'Computer Science');\n\nconsole.dir(student.name, student.bachelor);\n// Output: \"Jose, Computer Science\" \n\nconsole.dir(student.sayHi());\n// Output: \"Hi I'm a Student!\" \n\nconsole.dir(student.super.sayHi());\n// Output: \"Hi I'm a Person!\" \n\nconsole.log(s1 instanceof Student);\n// Output: true \nconsole.log(s1 instanceof Person);\n// Output: true \n```\nYou can see how the use of `parent's methods` is trivial with the attribute `super` from the instances.\n\n## Advanced Use\nA nice feature is the possibility of creating `class` methods by prepending `__` (two underscores) to the name of the method.\n\n```javascript\nvar Person = Class({\n  initialize: function (name, surname) {\n    this.name = name;\n    this.surname = surname;\n  },\n  __thisIsAClassMethod: function () {\n    return 'Hi I\\'m a classmethod!';\n  },\n  thisIsAnInstanceMethod: function () {\n    return 'Hi I\\'m an instancemethod!';\n  }\n});\n\nvar person = new Person('Jose', 'Vidal');\n\n// Class:\nconsole.log(Person.thisIsAClassMethod());\n// Output: 'Hi I\\'m a classmethod!'\n\nconsole.log(Person.thisIsAnInstanceMethod());\n// Output: TypeError: undefined is not a function\n\n// Instance:\nconsole.log(person.thisIsAClassMethod());\n// Output: TypeError: undefined is not a function\n\nconsole.log(person.thisIsAnInstanceMethod());\n// Output: 'Hi I\\'m an instancemethod!'\n```\n\n## Installation\n\n```javascript\nbower install parent.js\n```\nor\n```javascript\nnpm install parent.js\n```\n\n**Enjoy!**\n\n## Contribute\n\nSimply make a PR.\n\n## Licente\n\nMIT\n","maintainers":[{"name":"javidgon","email":"javidgon@gmail.com"}],"time":{"modified":"2022-06-23T10:13:06.215Z","created":"2014-10-23T23:02:49.535Z","0.0.3":"2014-10-23T23:02:49.535Z","0.0.4":"2014-10-24T21:43:49.079Z"},"homepage":"https://github.com/javidgon/parent.js","keywords":["inheritance","wrapper","humans"],"repository":{"type":"git","url":"https://github.com/javidgon/parent.js.git"},"author":{"name":"Jose Vidal"},"bugs":{"url":"https://github.com/javidgon/parent.js/issues"},"license":"MIT","readmeFilename":"README.md"}