Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

readme update

  • Loading branch information...
commit 2d4d599c1ad25025eb57cb6337596e5864bb4720 1 parent f4482e9
hij1nx authored

Showing 2 changed files with 16 additions and 5 deletions. Show diff stats Hide diff stats

  1. +13 1 README.md
  2. +3 4 test.js
14 README.md
Source Rendered
@@ -6,7 +6,19 @@ Subclass is a safe way to extend native types in Javascript.
6 6 Extending native types in Javascript will usually get you shot, drawn and quartered or beat-down by respectable developers. Don't do it... That said subclass gives you a real copy of the native objects and lets you go crazy with them without destroying the known universe. Complex objects with nifty convenience methods have their place and time. Safety aside, I strongly recommend using this library judiciously, Most things you want to do can be done without this special sugar.
7 7
8 8
9   - var IArray = Subclass.Array;
  9 +### A simple example in the browser
  10 +
  11 + var ISubclass = Subclass();
  12 + var IArray = ISubclass.Array;
  13 +
  14 + var a = IArray();
  15 +
  16 + a.push(10, 20);
  17 +
  18 +### a more advanced example on the server (which would also work in the brosers)
  19 +
  20 + var ISubclass = require('./subclass').Subclass();
  21 + var IArray = ISubclass.Array;
10 22
11 23 IArray.prototype.pluck = function(v) {
12 24 while(this.indexOf(v) != -1) {
7 test.js
... ... @@ -1,7 +1,6 @@
1 1
2   -var Subclass = require('./subclass').Subclass();
3   -
4   -var IArray = Subclass.Array;
  2 +var ISubclass = require('./subclass').Subclass();
  3 +var IArray = ISubclass.Array;
5 4
6 5 IArray.prototype.pluck = function(v) {
7 6 while(this.indexOf(v) != -1) {
@@ -18,7 +17,7 @@ IArray.prototype.spush = function(v) {
18 17 var a = IArray();
19 18 var b = IArray(1, 2, 3);
20 19
21   -a.spush(10);
  20 +a.push(10);
22 21 b.spush(2);
23 22
24 23 console.log('The native copies have some zaney new methods.');

0 comments on commit 2d4d599

Please sign in to comment.
Something went wrong with that request. Please try again.