Browse Source

Update README.md

pull/3/head
Brett Langdon 13 years ago
parent
commit
b101278cf9
1 changed files with 14 additions and 6 deletions
  1. +14
    -6
      README.md

+ 14
- 6
README.md View File

@ -11,13 +11,21 @@ npm install node-units
## Usage ## Usage
`node-units` comes with a few built in functions:
### Functions
* `importDB(file_name, cb)` - imports a custom unit database, `cb` takes a single argument `err` * `importDB(file_name, cb)` - imports a custom unit database, `cb` takes a single argument `err`
* `importDBSync(file_name)` - the sync version of `importDB` * `importDBSync(file_name)` - the sync version of `importDB`
* `getDB()` - returns he currently used database of units as an object * `getDB()` - returns he currently used database of units as an object
* `convert(type, value, from, to)` - converts `value` of `from` to `to`, returns the result or raises exception if conversion cannot be made * `convert(type, value, from, to)` - converts `value` of `from` to `to`, returns the result or raises exception if conversion cannot be made
### Properties
* `types` - `types` is an object containing constants for each unit group.
`types` with the default unit database looks like:
```javascript
{'TIME': 'time',
'VOLUME': 'volume'};
```
### Simple Usage ### Simple Usage
```javascript ```javascript
@ -34,9 +42,9 @@ units.convert(units.types.TIME, 5, 'day', 'second');
With `node-units` you can import custom unit definitions from files defined like the following: With `node-units` you can import custom unit definitions from files defined like the following:
``` ```
group: group:
long_name,longname,ln 1ln
another_unit,au 5ln
one_more,om 2au
long_name,longname,ln 1ln
another_unit,au 5ln
one_more,om 2au
``` ```
```javascript ```javascript
@ -73,4 +81,4 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 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.
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.

Loading…
Cancel
Save