Skip to content

Commit

Permalink
Improving readme.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gozala committed Jun 10, 2011
1 parent 45053a0 commit 67d1003
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions README.md
Expand Up @@ -7,24 +7,34 @@ runtime analog of types. Check out [docs] for more details.

npm install guards

## Require ##

// Full version inculding String / Number / Function guards.
var guards = require('https!raw.github.com/Gozala/guards/v0.2.0/guards.js')

// Core version without dependencies and type specific guards.
var guards = require('https!raw.github.com/Gozala/guards/v0.2.0/core.js')

## Example ##

var guards = require("guards");
var guards = require('https!raw.github.com/Gozala/guards/v0.2.0/guards.js')
var Point = guards.Schema({
x: guards.Number(0),
y: guards.Number(0)
});
})

function color(value) {
if (typeof value === "number" && value <= 255 && value >= 0)
return value
throw new TypeError("Color is a number between 0 and 255");
if (typeof value === "number" && value <= 255 && value >= 0) return value
throw new TypeError("Color is a number between 0 and 255")
}
var RGB = guards.Tuple([ color, color, color ]);

var RGB = guards.Tuple([ color, color, color ])
var Segment = guards.Schema({
start: Point,
end: Point,
color: RGB,
});
})

var segment = Segment({ end: { y: 23 }, color: [17, 255, 0] })
// { start: { x: 0, y: 0 }, end: { x: 0, y: 23 }, color: [ 17, 255, 0 ] }

Expand Down

0 comments on commit 67d1003

Please sign in to comment.