Skip to content

Commit

Permalink
docs: add results for each example
Browse files Browse the repository at this point in the history
  • Loading branch information
retrofox committed Dec 6, 2012
1 parent 495ae1e commit 288d7d6
Showing 1 changed file with 38 additions and 6 deletions.
44 changes: 38 additions & 6 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,37 +37,69 @@ var heroes = [

// returns an object with number key
var heroesObject = toObject(heroes);
/*
{
0: { first: 'Manuel', last: 'Belgrano' },
1: { first: 'Juan Jose', last: 'San Martin' },
2: { first: 'Hipolito', last: 'Bouchard' },
3: { first: 'Martin Miguel', last: 'de Güemes' }
}
*/

// return an object with first value as key
var heroesObject = toObject(heroes, 'first');
/*
{
'Manuel': { first: 'Manuel', last: 'Belgrano' },
'Juan Jose': { first: 'Juan Jose', last: 'San Martin' },
'Hipolito': { first: 'Hipolito', last: 'Bouchard' },
'Martin Miguel': { first: 'Martin Miguel', last: 'de Güemes' }
}
*/

// return an object with first value as key and remove the key
var heroesObject = toObject(heroes, 'first', true);
/*
{
'Manuel': { last: 'Belgrano' },
'Juan Jose': { last: 'San Martin' },
'Hipolito': { last: 'Bouchard' },
'Martin Miguel': { last: 'de Güemes' }
}
*/

// return an object with first value modified as key
var heroesObject = toObject(heroes, 'first', function(key){
return key.toLowerCase().replace(/\s/i, '_');
});
/*
{
manuel: { first: 'Manuel', last: 'Belgrano' },
juan_jose: { first: 'Juan Jose', last: 'San Martin' },
hipolito: { first: 'Hipolito', last: 'Bouchard' },
martin_miguel: { first: 'Martin Miguel', last: 'de Güemes' }
}
*/
```

## Running tests
## Tests

Make sure dependencies are installed:
Download testing dependecies

```
$ npm install
npm install
```

Then run:
Run tests

```
$ make test
make test
```

# License

(The MIT License)
Copyright(c) 2012 Damian Suarez <[email protected]>
Copyright(c) 2012 Damian Suarez &lt;[email protected]&gt;

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Expand Down

0 comments on commit 288d7d6

Please sign in to comment.