Permalink
Browse files

Updated README and added LICENCE

  • Loading branch information...
1 parent 162c619 commit 0e4d423ad10e0ce94b3c603555e6501f86aaf8b2 @Raynos committed Nov 21, 2011
Showing with 66 additions and 33 deletions.
  1. +19 −0 LICENCE
  2. +47 −33 README.md
View
19 LICENCE
@@ -0,0 +1,19 @@
+Copyright (c) 2011 Raynos.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
View
80 README.md
@@ -1,34 +1,35 @@
-# pd <a name="_pd" href="#_pd"><small><sup>link</sup></small></a>
+# pd
-A small utility for writing OO javascript.
+Helping you do prototypical OO
-pd is short for property descriptor.
+## Example
-It converts objects into property descriptors. So you can create objects like:
+ var Animal = {
+ legs: 4,
+ walk: function () { ... }
+ };
- var o = Object.create(somePrototype, pd({
- "someProp": "someValue",
- get someGetter() {
-
- },
- set someSetter() {
-
- }
- }));
-
-## Blog posts <a name="Blog_posts" href="#Blog_posts"><small><sup>link</sup></small></a>
+ var Cat = pd.make(Animal, {
+ nyan: function () { ... },
+ constructor: function () { this.lives = 9; }
+ });
- - [Doing Object Oriented JavaScript][3]
- - [Doing OO JS part 2][5]
- - [Doing OO JS part 3][6]
+ var cat = pd.beget(Cat);
-## Examples <a name="Examples" href="#Examples"><small><sup>link</sup></small></a>
+## Motivation
- [OO utilities][7]
+ES5 OO is [verbose][8]
-## Documentation <a name="Documentation" href="#Documentation"><small><sup>link</sup></small></a>
+pd solves this with utilities and sugar.
-See the source >_>
+## Blog Posts
+
+ - [Doing Object Oriented JavaScript][3]
+ - [Doing OO JS part 2][5]
+ - [Doing OO JS part 3][6]
+ - [Improving ES5 OO][9]
+
+## Documentation
### pd (obj) <a name="pd" href="#pd"><small><sup>link</sup></small></a>
@@ -79,19 +80,19 @@ is the same as
pd.extend returns the first object you pass in.
-### pd.make (proto, props) <a name="pd.make" href="#pd.make"><small><sup>link</sup></small></a>
+### pd.make (proto, props...) <a name="pd.make" href="#pd.make"><small><sup>link</sup></small></a>
-pd.make takes a prototype and some properties, it creates a new instance of the prototype and extends
-that instances with the properties.
+pd.make takes a prototype and some properties, it creates a new instance of the prototype and extends that instances with the properties.
pd.make(Proto, {
prop: "42"
+ }, {
+ another_prop: 42
});
### pd.beget (proto, args..) <a name="pd.beget" href="#pd.beget"><small><sup>link</sup</small></a>
-pd.beget takes a prototype and creates a new instance of it. it will then call the constructor
-property of the new instance with the arguments and finally returns the object
+pd.beget takes a prototype and creates a new instance of it. it will then call the constructor property of the new instance with the arguments and finally returns the object
var Proto = {
method: function () {
@@ -102,7 +103,7 @@ property of the new instance with the arguments and finally returns the object
}
};
- var o = pd.new(Proto, 42); // "constructed", 42
+ var o = pd.beget(Proto, 42); // "constructed", 42
console.log(Proto.isPrototypeOf(o)); // true
o.method(); // "method"
@@ -131,9 +132,9 @@ Example:
- Object.prototype.make (same as pd.make)
- Object.prototype.extend (same as pd.extend)
-An example of `.new` which only takes arguments
+An example of `.beget` which only takes arguments
- var instance = Proto.new(42)
+ var instance = Proto.beget(42)
An example of `.make` which only extends it with one argument
@@ -164,11 +165,24 @@ Example:
};
}());
+## Installation
+
+npm install pd
+
+## Test
+
+node tests/pd-test.js
+
+## Contributors
+
+ - Raynos
+ - Gozala
+
+## MIT Licenced
- [1]: http://raynos.github.com/pd/docs/pd.html
- [2]: http://raynos.github.com/vows-fluent/docs/vows-fluent.html
[3]: http://raynos.org/blog/4/Doing-Object-Oriented-JavaScript
[4]: http://www.2ality.com/2011/06/prototypes-as-classes.html
[5]: http://raynos.org/blog/5/Doing-Object-Oriented-Javascript---part-2
[6]: http://raynos.org/blog/7/Doing-Object-Oriented-Javascript---part-3
- [7]: https://gist.github.com/1352801
+ [8]: https://gist.github.com/1384024
+ [9]: http://raynos.org/blog/17/Improving-ES5-OO-with-pd

0 comments on commit 0e4d423

Please sign in to comment.